feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,66 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse;
import java.util.Enumeration;
import org.relaxng.datatype.ValidationContext;
/**
* Provides contextual information.
*
* This is typically useful for parsing QNames.
*/
public interface Context extends ValidationContext {
/**
* Enumerates the prefixes bound to namespaces.
*/
Enumeration prefixes();
/**
* Returns the immutable snapshot of this {@link Context}.
*/
Context copy();
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse;
/**
* Signals a violation of the RELAX NG spec.
*/
public class IllegalSchemaException extends Exception { }

View File

@@ -0,0 +1,92 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse;
import com.sun.xml.internal.rngom.ast.builder.*;
import com.sun.xml.internal.rngom.ast.om.*;
/**
* An input that can be turned into a RELAX NG pattern.
*
* <p>
* This is either a RELAX NG schema in the XML format, or a RELAX NG
* schema in the compact syntax.
*/
public interface Parseable {
/**
* Parses this {@link Parseable} object into a RELAX NG pattern.
*
* @param sb
* The builder of the schema object model. This object
* dictates how the actual pattern is constructed.
*
* @return
* a parsed object. Always returns a non-null valid object.
*/
<P extends ParsedPattern> P parse(SchemaBuilder<?,P,?,?,?,?> sb) throws BuildException, IllegalSchemaException;
/**
* Called from {@link Include} in response to
* {@link Include#endInclude(Parseable, String, String, Location, Annotations)}
* to parse the included grammar.
*
* @param g
* receives the events from the included grammar.
*/
<P extends ParsedPattern> P parseInclude(String uri, SchemaBuilder<?,P,?,?,?,?> f, IncludedGrammar<P,?,?,?,?> g, String inheritedNs)
throws BuildException, IllegalSchemaException;
/**
* Called from {@link SchemaBuilder} in response to
* {@link SchemaBuilder#makeExternalRef(Parseable, String, String, Scope, Location, Annotations)}
* to parse the referenced grammar.
*
* @param f
* receives the events from the referenced grammar.
*/
<P extends ParsedPattern> P parseExternal(String uri, SchemaBuilder<?,P,?,?,?,?> f, Scope s, String inheritedNs)
throws BuildException, IllegalSchemaException;
}

View File

@@ -0,0 +1,138 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.compact;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PushbackInputStream;
import java.io.Reader;
import java.net.URL;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.IncludedGrammar;
import com.sun.xml.internal.rngom.ast.builder.SchemaBuilder;
import com.sun.xml.internal.rngom.ast.builder.Scope;
import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
import com.sun.xml.internal.rngom.parse.IllegalSchemaException;
import com.sun.xml.internal.rngom.parse.Parseable;
import com.sun.xml.internal.rngom.xml.util.EncodingMap;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
/**
* RELAX NG schema in the compact syntax.
*/
public class CompactParseable implements Parseable {
private final InputSource in;
private final ErrorHandler eh;
public CompactParseable(InputSource in, ErrorHandler eh) {
this.in = in;
this.eh = eh;
}
public ParsedPattern parse(SchemaBuilder sb) throws BuildException, IllegalSchemaException {
ParsedPattern p = new CompactSyntax(this, makeReader(in), in.getSystemId(), sb, eh, "").parse(null);
return sb.expandPattern(p);
}
public ParsedPattern parseInclude(String uri, SchemaBuilder sb, IncludedGrammar g, String inheritedNs)
throws BuildException, IllegalSchemaException {
InputSource tem = new InputSource(uri);
tem.setEncoding(in.getEncoding());
return new CompactSyntax(this, makeReader(tem), uri, sb, eh, inheritedNs).parseInclude(g);
}
public ParsedPattern parseExternal(String uri, SchemaBuilder sb, Scope scope, String inheritedNs)
throws BuildException, IllegalSchemaException {
InputSource tem = new InputSource(uri);
tem.setEncoding(in.getEncoding());
return new CompactSyntax(this, makeReader(tem), uri, sb, eh, inheritedNs).parse(scope);
}
private static final String UTF8 = EncodingMap.getJavaName("UTF-8");
private static final String UTF16 = EncodingMap.getJavaName("UTF-16");
private static Reader makeReader(InputSource is) throws BuildException {
try {
Reader r = is.getCharacterStream();
if (r == null) {
InputStream in = is.getByteStream();
if (in == null) {
String systemId = is.getSystemId();
in = new URL(systemId).openStream();
}
String encoding = is.getEncoding();
if (encoding == null) {
PushbackInputStream pb = new PushbackInputStream(in, 2);
encoding = detectEncoding(pb);
in = pb;
}
r = new InputStreamReader(in, encoding);
}
return r;
}
catch (IOException e) {
throw new BuildException(e);
}
}
static private String detectEncoding(PushbackInputStream in) throws IOException {
String encoding = UTF8;
int b1 = in.read();
if (b1 != -1) {
int b2 = in.read();
if (b2 != -1) {
in.unread(b2);
if ((b1 == 0xFF && b2 == 0xFE) || (b1 == 0xFE && b2 == 0xFF))
encoding = UTF16;
}
in.unread(b1);
}
return encoding;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,179 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/* Generated By:JavaCC: Do not edit this line. CompactSyntaxConstants.java */
package com.sun.xml.internal.rngom.parse.compact;
/**
* Token literal values and constants.
* Generated by org.javacc.parser.OtherFilesGen#start()
*/
public interface CompactSyntaxConstants {
/** End of File. */
int EOF = 0;
/** RegularExpression Id. */
int NEWLINE = 37;
/** RegularExpression Id. */
int NOT_NEWLINE = 38;
/** RegularExpression Id. */
int WS = 39;
/** RegularExpression Id. */
int DOCUMENTATION = 40;
/** RegularExpression Id. */
int DOCUMENTATION_CONTINUE = 41;
/** RegularExpression Id. */
int SINGLE_LINE_COMMENT = 42;
/** RegularExpression Id. */
int DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT = 43;
/** RegularExpression Id. */
int SINGLE_LINE_COMMENT_CONTINUE = 44;
/** RegularExpression Id. */
int BASE_CHAR = 45;
/** RegularExpression Id. */
int IDEOGRAPHIC = 46;
/** RegularExpression Id. */
int LETTER = 47;
/** RegularExpression Id. */
int COMBINING_CHAR = 48;
/** RegularExpression Id. */
int DIGIT = 49;
/** RegularExpression Id. */
int EXTENDER = 50;
/** RegularExpression Id. */
int NMSTART = 51;
/** RegularExpression Id. */
int NMCHAR = 52;
/** RegularExpression Id. */
int NCNAME = 53;
/** RegularExpression Id. */
int IDENTIFIER = 54;
/** RegularExpression Id. */
int ESCAPED_IDENTIFIER = 55;
/** RegularExpression Id. */
int PREFIX_STAR = 56;
/** RegularExpression Id. */
int PREFIXED_NAME = 57;
/** RegularExpression Id. */
int LITERAL = 58;
/** RegularExpression Id. */
int FANNOTATE = 59;
/** RegularExpression Id. */
int ILLEGAL_CHAR = 60;
/** Lexical state. */
int DEFAULT = 0;
/** Lexical state. */
int AFTER_SINGLE_LINE_COMMENT = 1;
/** Lexical state. */
int AFTER_DOCUMENTATION = 2;
/** Literal token values. */
String[] tokenImage = {
"<EOF>",
"\"[\"",
"\"=\"",
"\"&=\"",
"\"|=\"",
"\"start\"",
"\"div\"",
"\"include\"",
"\"~\"",
"\"]\"",
"\"grammar\"",
"\"{\"",
"\"}\"",
"\"namespace\"",
"\"default\"",
"\"inherit\"",
"\"datatypes\"",
"\"empty\"",
"\"text\"",
"\"notAllowed\"",
"\"|\"",
"\"&\"",
"\",\"",
"\"+\"",
"\"?\"",
"\"*\"",
"\"element\"",
"\"attribute\"",
"\"(\"",
"\")\"",
"\"-\"",
"\"list\"",
"\"mixed\"",
"\"external\"",
"\"parent\"",
"\"string\"",
"\"token\"",
"<NEWLINE>",
"<NOT_NEWLINE>",
"<WS>",
"<DOCUMENTATION>",
"<DOCUMENTATION_CONTINUE>",
"<SINGLE_LINE_COMMENT>",
"<DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT>",
"<SINGLE_LINE_COMMENT_CONTINUE>",
"<BASE_CHAR>",
"<IDEOGRAPHIC>",
"<LETTER>",
"<COMBINING_CHAR>",
"<DIGIT>",
"<EXTENDER>",
"<NMSTART>",
"<NMCHAR>",
"<NCNAME>",
"<IDENTIFIER>",
"<ESCAPED_IDENTIFIER>",
"<PREFIX_STAR>",
"<PREFIXED_NAME>",
"<LITERAL>",
"\">>\"",
"<ILLEGAL_CHAR>",
};
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.compact;
import java.io.IOException;
public class EOFException extends IOException {
}

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.compact;
class EscapeSyntaxException extends RuntimeException {
private final String key;
private final int lineNumber;
private final int columnNumber;
EscapeSyntaxException(String key, int lineNumber, int columnNumber) {
this.key = key;
this.lineNumber = lineNumber;
this.columnNumber = columnNumber;
}
String getKey() {
return key;
}
int getLineNumber() {
return lineNumber;
}
int getColumnNumber() {
return columnNumber;
}
}

View File

@@ -0,0 +1,662 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 5.0 */
/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.sun.xml.internal.rngom.parse.compact;
/**
* An implementation of interface CharStream, where the stream is assumed to
* contain only ASCII characters (with java-like unicode escape processing).
*/
public
class JavaCharStream
{
/** Whether parser is static. */
public static final boolean staticFlag = false;
static final int hexval(char c) throws java.io.IOException {
switch(c)
{
case '0' :
return 0;
case '1' :
return 1;
case '2' :
return 2;
case '3' :
return 3;
case '4' :
return 4;
case '5' :
return 5;
case '6' :
return 6;
case '7' :
return 7;
case '8' :
return 8;
case '9' :
return 9;
case 'a' :
case 'A' :
return 10;
case 'b' :
case 'B' :
return 11;
case 'c' :
case 'C' :
return 12;
case 'd' :
case 'D' :
return 13;
case 'e' :
case 'E' :
return 14;
case 'f' :
case 'F' :
return 15;
}
throw new java.io.IOException(); // Should never come here
}
/** Position in buffer. */
public int bufpos = -1;
int bufsize;
int available;
int tokenBegin;
protected int bufline[];
protected int bufcolumn[];
protected int column = 0;
protected int line = 1;
protected boolean prevCharIsCR = false;
protected boolean prevCharIsLF = false;
protected java.io.Reader inputStream;
protected char[] nextCharBuf;
protected char[] buffer;
protected int maxNextCharInd = 0;
protected int nextCharInd = -1;
protected int inBuf = 0;
protected int tabSize = 8;
protected void setTabSize(int i) { tabSize = i; }
protected int getTabSize(int i) { return tabSize; }
protected void ExpandBuff(boolean wrapAround)
{
char[] newbuffer = new char[bufsize + 2048];
int newbufline[] = new int[bufsize + 2048];
int newbufcolumn[] = new int[bufsize + 2048];
try
{
if (wrapAround)
{
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
buffer = newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
bufline = newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
bufcolumn = newbufcolumn;
bufpos += (bufsize - tokenBegin);
}
else
{
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
buffer = newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
bufline = newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
bufcolumn = newbufcolumn;
bufpos -= tokenBegin;
}
}
catch (Throwable t)
{
throw new Error(t.getMessage());
}
available = (bufsize += 2048);
tokenBegin = 0;
}
protected void FillBuff() throws java.io.IOException
{
int i;
if (maxNextCharInd == 4096)
maxNextCharInd = nextCharInd = 0;
try {
if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
4096 - maxNextCharInd)) == -1)
{
inputStream.close();
throw new java.io.IOException();
}
else
maxNextCharInd += i;
return;
}
catch(java.io.IOException e) {
if (bufpos != 0)
{
--bufpos;
backup(0);
}
else
{
bufline[bufpos] = line;
bufcolumn[bufpos] = column;
}
throw e;
}
}
protected char ReadByte() throws java.io.IOException
{
if (++nextCharInd >= maxNextCharInd)
FillBuff();
return nextCharBuf[nextCharInd];
}
/** @return starting character for token. */
public char BeginToken() throws java.io.IOException
{
if (inBuf > 0)
{
--inBuf;
if (++bufpos == bufsize)
bufpos = 0;
tokenBegin = bufpos;
return buffer[bufpos];
}
tokenBegin = 0;
bufpos = -1;
return readChar();
}
protected void AdjustBuffSize()
{
if (available == bufsize)
{
if (tokenBegin > 2048)
{
bufpos = 0;
available = tokenBegin;
}
else
ExpandBuff(false);
}
else if (available > tokenBegin)
available = bufsize;
else if ((tokenBegin - available) < 2048)
ExpandBuff(true);
else
available = tokenBegin;
}
protected void UpdateLineColumn(char c)
{
column++;
if (prevCharIsLF)
{
prevCharIsLF = false;
line += (column = 1);
}
else if (prevCharIsCR)
{
prevCharIsCR = false;
if (c == '\n')
{
prevCharIsLF = true;
}
else
line += (column = 1);
}
switch (c)
{
case '\r' :
prevCharIsCR = true;
break;
case '\n' :
prevCharIsLF = true;
break;
case '\t' :
column--;
column += (tabSize - (column % tabSize));
break;
default :
break;
}
bufline[bufpos] = line;
bufcolumn[bufpos] = column;
}
/** Read a character. */
public char readChar() throws java.io.IOException
{
if (inBuf > 0)
{
--inBuf;
if (++bufpos == bufsize)
bufpos = 0;
return buffer[bufpos];
}
char c;
if (++bufpos == available)
AdjustBuffSize();
if ((buffer[bufpos] = c = ReadByte()) == '\\')
{
UpdateLineColumn(c);
int backSlashCnt = 1;
for (;;) // Read all the backslashes
{
if (++bufpos == available)
AdjustBuffSize();
try
{
if ((buffer[bufpos] = c = ReadByte()) != '\\')
{
UpdateLineColumn(c);
// found a non-backslash char.
if ((c == 'u') && ((backSlashCnt & 1) == 1))
{
if (--bufpos < 0)
bufpos = bufsize - 1;
break;
}
backup(backSlashCnt);
return '\\';
}
}
catch(java.io.IOException e)
{
// We are returning one backslash so we should only backup (count-1)
if (backSlashCnt > 1)
backup(backSlashCnt-1);
return '\\';
}
UpdateLineColumn(c);
backSlashCnt++;
}
// Here, we have seen an odd number of backslash's followed by a 'u'
try
{
while ((c = ReadByte()) == 'u')
++column;
buffer[bufpos] = c = (char)(hexval(c) << 12 |
hexval(ReadByte()) << 8 |
hexval(ReadByte()) << 4 |
hexval(ReadByte()));
column += 4;
}
catch(java.io.IOException e)
{
throw new Error("Invalid escape character at line " + line +
" column " + column + ".");
}
if (backSlashCnt == 1)
return c;
else
{
backup(backSlashCnt - 1);
return '\\';
}
}
else
{
UpdateLineColumn(c);
return c;
}
}
@Deprecated
/**
* @deprecated
* @see #getEndColumn
*/
public int getColumn() {
return bufcolumn[bufpos];
}
@Deprecated
/**
* @deprecated
* @see #getEndLine
*/
public int getLine() {
return bufline[bufpos];
}
/** Get end column. */
public int getEndColumn() {
return bufcolumn[bufpos];
}
/** Get end line. */
public int getEndLine() {
return bufline[bufpos];
}
/** @return column of token start */
public int getBeginColumn() {
return bufcolumn[tokenBegin];
}
/** @return line number of token start */
public int getBeginLine() {
return bufline[tokenBegin];
}
/** Retreat. */
public void backup(int amount) {
inBuf += amount;
if ((bufpos -= amount) < 0)
bufpos += bufsize;
}
/** Constructor. */
public JavaCharStream(java.io.Reader dstream,
int startline, int startcolumn, int buffersize)
{
inputStream = dstream;
line = startline;
column = startcolumn - 1;
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
nextCharBuf = new char[4096];
}
/** Constructor. */
public JavaCharStream(java.io.Reader dstream,
int startline, int startcolumn)
{
this(dstream, startline, startcolumn, 4096);
}
/** Constructor. */
public JavaCharStream(java.io.Reader dstream)
{
this(dstream, 1, 1, 4096);
}
/** Reinitialise. */
public void ReInit(java.io.Reader dstream,
int startline, int startcolumn, int buffersize)
{
inputStream = dstream;
line = startline;
column = startcolumn - 1;
if (buffer == null || buffersize != buffer.length)
{
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
nextCharBuf = new char[4096];
}
prevCharIsLF = prevCharIsCR = false;
tokenBegin = inBuf = maxNextCharInd = 0;
nextCharInd = bufpos = -1;
}
/** Reinitialise. */
public void ReInit(java.io.Reader dstream,
int startline, int startcolumn)
{
ReInit(dstream, startline, startcolumn, 4096);
}
/** Reinitialise. */
public void ReInit(java.io.Reader dstream)
{
ReInit(dstream, 1, 1, 4096);
}
/** Constructor. */
public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
{
this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
}
/** Constructor. */
public JavaCharStream(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
/** Constructor. */
public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
int startcolumn) throws java.io.UnsupportedEncodingException
{
this(dstream, encoding, startline, startcolumn, 4096);
}
/** Constructor. */
public JavaCharStream(java.io.InputStream dstream, int startline,
int startcolumn)
{
this(dstream, startline, startcolumn, 4096);
}
/** Constructor. */
public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
{
this(dstream, encoding, 1, 1, 4096);
}
/** Constructor. */
public JavaCharStream(java.io.InputStream dstream)
{
this(dstream, 1, 1, 4096);
}
/** Reinitialise. */
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
{
ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
}
/** Reinitialise. */
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
}
/** Reinitialise. */
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
int startcolumn) throws java.io.UnsupportedEncodingException
{
ReInit(dstream, encoding, startline, startcolumn, 4096);
}
/** Reinitialise. */
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn)
{
ReInit(dstream, startline, startcolumn, 4096);
}
/** Reinitialise. */
public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
{
ReInit(dstream, encoding, 1, 1, 4096);
}
/** Reinitialise. */
public void ReInit(java.io.InputStream dstream)
{
ReInit(dstream, 1, 1, 4096);
}
/** @return token image as String */
public String GetImage()
{
if (bufpos >= tokenBegin)
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
else
return new String(buffer, tokenBegin, bufsize - tokenBegin) +
new String(buffer, 0, bufpos + 1);
}
/** @return suffix */
public char[] GetSuffix(int len)
{
char[] ret = new char[len];
if ((bufpos + 1) >= len)
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
else
{
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
len - bufpos - 1);
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
}
return ret;
}
/** Set buffers back to null when finished. */
public void Done()
{
nextCharBuf = null;
buffer = null;
bufline = null;
bufcolumn = null;
}
/**
* Method to adjust line and column numbers for the start of a token.
*/
public void adjustBeginLineColumn(int newLine, int newCol)
{
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
}
else
{
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
int nextColDiff = 0, columnDiff = 0;
while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
{
bufline[j] = newLine;
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
bufcolumn[j] = newCol + columnDiff;
columnDiff = nextColDiff;
i++;
}
if (i < len)
{
bufline[j] = newLine++;
bufcolumn[j] = newCol + columnDiff;
while (i++ < len)
{
if (bufline[j = start % bufsize] != bufline[++start % bufsize])
bufline[j] = newLine++;
else
bufline[j] = newLine;
}
}
line = bufline[j];
column = bufcolumn[j];
}
}
/* JavaCC - OriginalChecksum=d4510307ecc248a96e4d3455ebf92ff3 (do not edit this line) */

View File

@@ -0,0 +1,232 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
/* JavaCCOptions:KEEP_LINE_COL=null */
package com.sun.xml.internal.rngom.parse.compact;
/**
* This exception is thrown when parse errors are encountered.
* You can explicitly create objects of this exception type by
* calling the method generateParseException in the generated
* parser.
*
* You can modify this class to customize your error reporting
* mechanisms so long as you retain the public fields.
*/
public class ParseException extends Exception {
/**
* The version identifier for this Serializable class.
* Increment only if the <i>serialized</i> form of the
* class changes.
*/
private static final long serialVersionUID = 1L;
/**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
* a new object of this type with the fields "currentToken",
* "expectedTokenSequences", and "tokenImage" set.
*/
public ParseException(Token currentTokenVal,
int[][] expectedTokenSequencesVal,
String[] tokenImageVal
)
{
super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));
currentToken = currentTokenVal;
expectedTokenSequences = expectedTokenSequencesVal;
tokenImage = tokenImageVal;
}
/**
* The following constructors are for use by you for whatever
* purpose you can think of. Constructing the exception in this
* manner makes the exception behave in the normal way - i.e., as
* documented in the class "Throwable". The fields "errorToken",
* "expectedTokenSequences", and "tokenImage" do not contain
* relevant information. The JavaCC generated code does not use
* these constructors.
*/
public ParseException() {
super();
}
/** Constructor with message. */
public ParseException(String message) {
super(message);
}
/**
* This is the last token that has been consumed successfully. If
* this object has been created due to a parse error, the token
* followng this token will (therefore) be the first error token.
*/
public Token currentToken;
/**
* Each entry in this array is an array of integers. Each array
* of integers represents a sequence of tokens (by their ordinal
* values) that is expected at this point of the parse.
*/
public int[][] expectedTokenSequences;
/**
* This is a reference to the "tokenImage" array of the generated
* parser within which the parse error occurred. This array is
* defined in the generated ...Constants interface.
*/
public String[] tokenImage;
/**
* It uses "currentToken" and "expectedTokenSequences" to generate a parse
* error message and returns it. If this object has been created
* due to a parse error, and you do not catch it (it gets thrown
* from the parser) the correct error message
* gets displayed.
*/
private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
if (maxSize < expectedTokenSequences[i].length) {
maxSize = expectedTokenSequences[i].length;
}
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
}
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected.append("...");
}
expected.append(eol).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
for (int i = 0; i < maxSize; i++) {
if (i != 0) retval += " ";
if (tok.kind == 0) {
retval += tokenImage[0];
break;
}
retval += " " + tokenImage[tok.kind];
retval += " \"";
retval += add_escapes(tok.image);
retval += " \"";
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
retval += "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
} else {
retval += "Was expecting one of:" + eol + " ";
}
retval += expected.toString();
return retval;
}
/**
* The end of line string for this machine.
*/
protected String eol = System.getProperty("line.separator", "\n");
/**
* Used to convert raw characters to their escaped version
* when these raw version cannot be used as part of an ASCII
* string literal.
*/
static String add_escapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
case '\t':
retval.append("\\t");
continue;
case '\n':
retval.append("\\n");
continue;
case '\f':
retval.append("\\f");
continue;
case '\r':
retval.append("\\r");
continue;
case '\"':
retval.append("\\\"");
continue;
case '\'':
retval.append("\\\'");
continue;
case '\\':
retval.append("\\\\");
continue;
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
continue;
}
}
return retval.toString();
}
}
/* JavaCC - OriginalChecksum=bd9c46050b4c34811443efbf89741eef (do not edit this line) */

View File

@@ -0,0 +1,176 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.sun.xml.internal.rngom.parse.compact;
/**
* Describes the input token stream.
*/
public class Token implements java.io.Serializable {
/**
* The version identifier for this Serializable class.
* Increment only if the <i>serialized</i> form of the
* class changes.
*/
private static final long serialVersionUID = 1L;
/**
* An integer that describes the kind of this token. This numbering
* system is determined by JavaCCParser, and a table of these numbers is
* stored in the file ...Constants.java.
*/
public int kind;
/** The line number of the first character of this Token. */
public int beginLine;
/** The column number of the first character of this Token. */
public int beginColumn;
/** The line number of the last character of this Token. */
public int endLine;
/** The column number of the last character of this Token. */
public int endColumn;
/**
* The string image of the token.
*/
public String image;
/**
* A reference to the next regular (non-special) token from the input
* stream. If this is the last token from the input stream, or if the
* token manager has not read tokens beyond this one, this field is
* set to null. This is true only if this token is also a regular
* token. Otherwise, see below for a description of the contents of
* this field.
*/
public Token next;
/**
* This field is used to access special tokens that occur prior to this
* token, but after the immediately preceding regular (non-special) token.
* If there are no such special tokens, this field is set to null.
* When there are more than one such special token, this field refers
* to the last of these special tokens, which in turn refers to the next
* previous special token through its specialToken field, and so on
* until the first special token (whose specialToken field is null).
* The next fields of special tokens refer to other special tokens that
* immediately follow it (without an intervening regular token). If there
* is no such token, this field is null.
*/
public Token specialToken;
/**
* An optional attribute value of the Token.
* Tokens which are not used as syntactic sugar will often contain
* meaningful values that will be used later on by the compiler or
* interpreter. This attribute value is often different from the image.
* Any subclass of Token that actually wants to return a non-null value can
* override this method as appropriate.
*/
public Object getValue() {
return null;
}
/**
* No-argument constructor
*/
public Token() {}
/**
* Constructs a new token for the specified Image.
*/
public Token(int kind)
{
this(kind, null);
}
/**
* Constructs a new token for the specified Image and Kind.
*/
public Token(int kind, String image)
{
this.kind = kind;
this.image = image;
}
/**
* Returns the image.
*/
public String toString()
{
return image;
}
/**
* Returns a new Token object, by default. However, if you want, you
* can create and return subclass objects based on the value of ofKind.
* Simply add the cases to the switch for all those special cases.
* For example, if you have a subclass of Token called IDToken that
* you want to create if ofKind is ID, simply add something like :
*
* case MyParserConstants.ID : return new IDToken(ofKind, image);
*
* to the following switch statement. Then you can cast matchedToken
* variable to the appropriate type and use sit in your lexical actions.
*/
public static Token newToken(int ofKind, String image)
{
switch(ofKind)
{
default : return new Token(ofKind, image);
}
}
public static Token newToken(int ofKind)
{
return newToken(ofKind, null);
}
}
/* JavaCC - OriginalChecksum=07395369f4a62ea6ce44cc3487e30e69 (do not edit this line) */

View File

@@ -0,0 +1,192 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
/* JavaCCOptions: */
package com.sun.xml.internal.rngom.parse.compact;
/** Token Manager Error. */
public class TokenMgrError extends Error
{
/**
* The version identifier for this Serializable class.
* Increment only if the <i>serialized</i> form of the
* class changes.
*/
private static final long serialVersionUID = 1L;
/*
* Ordinals for various reasons why an Error of this type can be thrown.
*/
/**
* Lexical error occurred.
*/
static final int LEXICAL_ERROR = 0;
/**
* An attempt was made to create a second instance of a static token manager.
*/
static final int STATIC_LEXER_ERROR = 1;
/**
* Tried to change to an invalid lexical state.
*/
static final int INVALID_LEXICAL_STATE = 2;
/**
* Detected (and bailed out of) an infinite loop in the token manager.
*/
static final int LOOP_DETECTED = 3;
/**
* Indicates the reason why the exception is thrown. It will have
* one of the above 4 values.
*/
int errorCode;
/**
* Replaces unprintable characters by their escaped (or unicode escaped)
* equivalents in the given string
*/
protected static final String addEscapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
case '\t':
retval.append("\\t");
continue;
case '\n':
retval.append("\\n");
continue;
case '\f':
retval.append("\\f");
continue;
case '\r':
retval.append("\\r");
continue;
case '\"':
retval.append("\\\"");
continue;
case '\'':
retval.append("\\\'");
continue;
case '\\':
retval.append("\\\\");
continue;
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
continue;
}
}
return retval.toString();
}
/**
* Returns a detailed message for the Error when it is thrown by the
* token manager to indicate a lexical error.
* Parameters :
* EOFSeen : indicates if EOF caused the lexical error
* curLexState : lexical state in which this error occurred
* errorLine : line number when the error occurred
* errorColumn : column number when the error occurred
* errorAfter : prefix that was seen before this error occurred
* curchar : the offending character
* Note: You can customize the lexical error message by modifying this method.
*/
protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
return("Lexical error at line " +
errorLine + ", column " +
errorColumn + ". Encountered: " +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
"after : \"" + addEscapes(errorAfter) + "\"");
}
/**
* You can also modify the body of this method to customize your error messages.
* For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
* of end-users concern, so you can return something like :
*
* "Internal Error : Please file a bug report .... "
*
* from this method for such cases in the release version of your parser.
*/
public String getMessage() {
return super.getMessage();
}
/*
* Constructors of various flavors follow.
*/
/** No arg constructor. */
public TokenMgrError() {
}
/** Constructor with message and reason. */
public TokenMgrError(String message, int reason) {
super(message);
errorCode = reason;
}
/** Full Constructor. */
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
/* JavaCC - OriginalChecksum=1d6588bf7a27100c05b06541f6175759 (do not edit this line) */

View File

@@ -0,0 +1,594 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2012
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/* Generated By:JavaCC: Do not edit this line. UCode_UCodeESC_CharStream.java Version 0.7pre6 */
/* The previous line keeps JavaCC quiet. In fact, the JavaCC generated file
has been edited to fix some bugs. */
package com.sun.xml.internal.rngom.parse.compact;
import com.sun.xml.internal.rngom.util.Utf16;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import java.io.IOException;
/**
* An implementation of interface CharStream, where the stream is assumed to
* contain 16-bit unicode characters.
*/
public final class UCode_UCodeESC_CharStream {
public static final boolean staticFlag = false;
static final int hexval(char c) {
switch (c) {
case '0':
return 0;
case '1':
return 1;
case '2':
return 2;
case '3':
return 3;
case '4':
return 4;
case '5':
return 5;
case '6':
return 6;
case '7':
return 7;
case '8':
return 8;
case '9':
return 9;
case 'a':
case 'A':
return 10;
case 'b':
case 'B':
return 11;
case 'c':
case 'C':
return 12;
case 'd':
case 'D':
return 13;
case 'e':
case 'E':
return 14;
case 'f':
case 'F':
return 15;
}
return -1;
}
public int bufpos = -1;
int bufsize;
int available;
int tokenBegin;
private int bufline[];
private int bufcolumn[];
private int column = 0;
private int line = 1;
private java.io.Reader inputStream;
private boolean closed = false;
private boolean prevCharIsLF = false;
private char[] nextCharBuf;
private char[] buffer;
private int maxNextCharInd = 0;
private int nextCharInd = -1;
private int inBuf = 0;
private final void ExpandBuff(boolean wrapAround) {
char[] newbuffer = new char[bufsize + 2048];
int newbufline[] = new int[bufsize + 2048];
int newbufcolumn[] = new int[bufsize + 2048];
if (wrapAround) {
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
System.arraycopy(buffer, 0, newbuffer,
bufsize - tokenBegin, bufpos);
buffer = newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
bufline = newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
bufcolumn = newbufcolumn;
bufpos += (bufsize - tokenBegin);
} else {
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
buffer = newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
bufline = newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
bufcolumn = newbufcolumn;
bufpos -= tokenBegin;
}
available = (bufsize += 2048);
tokenBegin = 0;
}
private final void FillBuff() throws EOFException {
int i;
if (maxNextCharInd == 4096) {
maxNextCharInd = nextCharInd = 0;
}
if (closed) {
throw new EOFException();
}
try {
if ((i = inputStream.read(nextCharBuf, maxNextCharInd, 4096 - maxNextCharInd)) == -1) {
closed = true;
inputStream.close();
throw new EOFException();
} else {
maxNextCharInd += i;
}
} catch (IOException e) {
throw new BuildException(e);
}
}
private final char ReadChar() throws EOFException {
if (++nextCharInd >= maxNextCharInd) {
FillBuff();
}
return nextCharBuf[nextCharInd];
}
private final char PeekChar() throws EOFException {
char c = ReadChar();
--nextCharInd;
return c;
}
public final char BeginToken() throws EOFException {
if (inBuf > 0) {
--inBuf;
return buffer[tokenBegin = (bufpos == bufsize - 1) ? (bufpos = 0)
: ++bufpos];
}
tokenBegin = 0;
bufpos = -1;
return readChar();
}
private final void AdjustBuffSize() {
if (available == bufsize) {
if (tokenBegin > 2048) {
bufpos = 0;
available = tokenBegin;
} else {
ExpandBuff(false);
}
} else if (available > tokenBegin) {
available = bufsize;
} else if ((tokenBegin - available) < 2048) {
ExpandBuff(true);
} else {
available = tokenBegin;
}
}
private final void UpdateLineColumn(char c) {
column++;
if (prevCharIsLF) {
prevCharIsLF = false;
line += (column = 1);
}
switch (c) {
case NEWLINE_MARKER:
prevCharIsLF = true;
break;
case '\t':
column--;
column += (8 - (column & 07));
break;
default:
break;
}
bufline[bufpos] = line;
bufcolumn[bufpos] = column;
}
private static final char NEWLINE_MARKER = '\u0000';
public final char readChar() throws EOFException {
if (inBuf > 0) {
--inBuf;
return buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos];
}
char c;
try {
c = ReadChar();
switch (c) {
case '\r':
c = NEWLINE_MARKER;
try {
if (PeekChar() == '\n') {
ReadChar();
}
} catch (EOFException e) {
}
break;
case '\n':
c = NEWLINE_MARKER;
break;
case '\t':
break;
default:
if (c >= 0x20) {
if (Utf16.isSurrogate(c)) {
if (Utf16.isSurrogate2(c)) {
throw new EscapeSyntaxException("illegal_surrogate_pair", line, column + 1);
}
if (++bufpos == available) {
AdjustBuffSize();
}
buffer[bufpos] = c;
// UpdateLineColumn(c);
try {
c = ReadChar();
} catch (EOFException e) {
throw new EscapeSyntaxException("illegal_surrogate_pair", line, column + 1);
}
if (!Utf16.isSurrogate2(c)) {
throw new EscapeSyntaxException("illegal_surrogate_pair", line, column + 2);
}
}
break;
}
// fall through
case '\uFFFE':
case '\uFFFF':
throw new EscapeSyntaxException("illegal_char_code", line, column + 1);
}
} catch (EOFException e) {
if (bufpos == -1) {
if (++bufpos == available) {
AdjustBuffSize();
}
bufline[bufpos] = line;
bufcolumn[bufpos] = column;
}
throw e;
}
if (++bufpos == available) {
AdjustBuffSize();
}
buffer[bufpos] = c;
UpdateLineColumn(c);
try {
if (c != '\\' || PeekChar() != 'x') {
return c;
}
} catch (EOFException e) {
return c;
}
int xCnt = 1;
for (;;) {
ReadChar();
if (++bufpos == available) {
AdjustBuffSize();
}
buffer[bufpos] = 'x';
UpdateLineColumn('x');
try {
c = PeekChar();
} catch (EOFException e) {
backup(xCnt);
return '\\';
}
if (c == '{') {
ReadChar();
column++;
// backup past the 'x's
bufpos -= xCnt;
if (bufpos < 0) {
bufpos += bufsize;
}
break;
}
if (c != 'x') {
backup(xCnt);
return '\\';
}
xCnt++;
}
try {
int scalarValue = hexval(ReadChar());
column++;
if (scalarValue < 0) {
throw new EscapeSyntaxException("illegal_hex_digit", line, column);
}
while ((c = ReadChar()) != '}') {
column++;
int n = hexval(c);
if (n < 0) {
throw new EscapeSyntaxException("illegal_hex_digit", line, column);
}
scalarValue <<= 4;
scalarValue |= n;
if (scalarValue >= 0x110000) {
throw new EscapeSyntaxException("char_code_too_big", line, column);
}
}
column++; // for the '}'
if (scalarValue <= 0xFFFF) {
c = (char) scalarValue;
switch (c) {
case '\n':
case '\r':
case '\t':
break;
default:
if (c >= 0x20 && !Utf16.isSurrogate(c)) {
break;
}
// fall through
case '\uFFFE':
case '\uFFFF':
throw new EscapeSyntaxException("illegal_char_code_ref", line, column);
}
buffer[bufpos] = c;
return c;
}
c = Utf16.surrogate1(scalarValue);
buffer[bufpos] = c;
int bufpos1 = bufpos;
if (++bufpos == bufsize) {
bufpos = 0;
}
buffer[bufpos] = Utf16.surrogate2(scalarValue);
bufline[bufpos] = bufline[bufpos1];
bufcolumn[bufpos] = bufcolumn[bufpos1];
backup(1);
return c;
} catch (EOFException e) {
throw new EscapeSyntaxException("incomplete_escape", line, column);
}
}
/**
* @deprecated @see #getEndColumn
*/
public final int getColumn() {
return bufcolumn[bufpos];
}
/**
* @deprecated @see #getEndLine
*/
public final int getLine() {
return bufline[bufpos];
}
public final int getEndColumn() {
return bufcolumn[bufpos];
}
public final int getEndLine() {
return bufline[bufpos];
}
public final int getBeginColumn() {
return bufcolumn[tokenBegin];
}
public final int getBeginLine() {
return bufline[tokenBegin];
}
public final void backup(int amount) {
inBuf += amount;
if ((bufpos -= amount) < 0) {
bufpos += bufsize;
}
}
public UCode_UCodeESC_CharStream(java.io.Reader dstream,
int startline, int startcolumn, int buffersize) {
inputStream = dstream;
line = startline;
column = startcolumn - 1;
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
nextCharBuf = new char[4096];
skipBOM();
}
public UCode_UCodeESC_CharStream(java.io.Reader dstream,
int startline, int startcolumn) {
this(dstream, startline, startcolumn, 4096);
}
public void ReInit(java.io.Reader dstream,
int startline, int startcolumn, int buffersize) {
inputStream = dstream;
closed = false;
line = startline;
column = startcolumn - 1;
if (buffer == null || buffersize != buffer.length) {
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
nextCharBuf = new char[4096];
}
prevCharIsLF = false;
tokenBegin = inBuf = maxNextCharInd = 0;
nextCharInd = bufpos = -1;
skipBOM();
}
public void ReInit(java.io.Reader dstream,
int startline, int startcolumn) {
ReInit(dstream, startline, startcolumn, 4096);
}
public UCode_UCodeESC_CharStream(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize) {
this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
public UCode_UCodeESC_CharStream(java.io.InputStream dstream, int startline,
int startcolumn) {
this(dstream, startline, startcolumn, 4096);
}
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize) {
ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn) {
ReInit(dstream, startline, startcolumn, 4096);
}
static private final char BOM = '\ufeff';
private void skipBOM() {
try {
if (PeekChar() == BOM) {
ReadChar();
}
} catch (EOFException e) {
}
}
public final String GetImage() {
if (bufpos >= tokenBegin) {
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
} else {
return new String(buffer, tokenBegin, bufsize - tokenBegin)
+ new String(buffer, 0, bufpos + 1);
}
}
public final char[] GetSuffix(int len) {
char[] ret = new char[len];
if ((bufpos + 1) >= len) {
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
} else {
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
len - bufpos - 1);
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
}
return ret;
}
public void Done() {
nextCharBuf = null;
buffer = null;
bufline = null;
bufcolumn = null;
}
/**
* Method to adjust line and column numbers for the start of a token.<BR>
*/
public void adjustBeginLineColumn(int newLine, int newCol) {
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin) {
len = bufpos - tokenBegin + inBuf + 1;
} else {
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
int nextColDiff, columnDiff = 0;
while (i < len
&& bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) {
bufline[j] = newLine;
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
bufcolumn[j] = newCol + columnDiff;
columnDiff = nextColDiff;
i++;
}
if (i < len) {
bufline[j] = newLine++;
bufcolumn[j] = newCol + columnDiff;
while (i++ < len) {
if (bufline[j = start % bufsize] != bufline[++start % bufsize]) {
bufline[j] = newLine++;
} else {
bufline[j] = newLine;
}
}
}
line = bufline[j];
column = bufcolumn[j];
}
}

View File

@@ -0,0 +1,92 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.Annotations;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.CommentList;
import com.sun.xml.internal.rngom.ast.om.Location;
import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
class AnnotationsHost extends Base implements Annotations {
final Annotations lhs;
final Annotations rhs;
AnnotationsHost( Annotations lhs, Annotations rhs ) {
this.lhs = lhs;
this.rhs = rhs;
}
public void addAttribute(String ns, String localName, String prefix,
String value, Location _loc) throws BuildException {
LocationHost loc = cast(_loc);
lhs.addAttribute(ns, localName, prefix, value, loc.lhs);
rhs.addAttribute(ns, localName, prefix, value, loc.rhs);
}
public void addComment(CommentList _comments) throws BuildException {
CommentListHost comments = (CommentListHost) _comments;
lhs.addComment(comments==null?null:comments.lhs);
rhs.addComment(comments==null?null:comments.rhs);
}
public void addElement(ParsedElementAnnotation _ea) throws BuildException {
ParsedElementAnnotationHost ea = (ParsedElementAnnotationHost) _ea;
lhs.addElement(ea.lhs);
rhs.addElement(ea.rhs);
}
public void addLeadingComment(CommentList _comments) throws BuildException {
CommentListHost comments = (CommentListHost) _comments;
lhs.addLeadingComment(comments.lhs);
rhs.addLeadingComment(comments.rhs);
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.Annotations;
import com.sun.xml.internal.rngom.ast.om.Location;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public class Base {
protected AnnotationsHost cast( Annotations ann ) {
if(ann==null)
return nullAnnotations;
else
return (AnnotationsHost)ann;
}
protected LocationHost cast( Location loc ) {
if(loc==null)
return nullLocation;
else
return (LocationHost)loc;
}
private static final AnnotationsHost nullAnnotations = new AnnotationsHost(null,null);
private static final LocationHost nullLocation = new LocationHost(null,null);
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.CommentList;
import com.sun.xml.internal.rngom.ast.om.Location;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
class CommentListHost extends Base implements CommentList {
final CommentList lhs;
final CommentList rhs;
CommentListHost(CommentList lhs, CommentList rhs) {
this.lhs = lhs;
this.rhs = rhs;
}
public void addComment(String value, Location _loc) throws BuildException {
LocationHost loc = cast(_loc);
if(lhs!=null)
lhs.addComment(value,loc.lhs);
if(rhs!=null)
rhs.addComment(value,loc.rhs);
}
}

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.Annotations;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.DataPatternBuilder;
import com.sun.xml.internal.rngom.ast.om.Location;
import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
import com.sun.xml.internal.rngom.parse.Context;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
final class DataPatternBuilderHost extends Base implements DataPatternBuilder {
final DataPatternBuilder lhs;
final DataPatternBuilder rhs;
DataPatternBuilderHost( DataPatternBuilder lhs, DataPatternBuilder rhs ) {
this.lhs = lhs;
this.rhs = rhs;
}
public void addParam(String name, String value, Context context, String ns, Location _loc, Annotations _anno) throws BuildException {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
lhs.addParam( name, value, context, ns, loc.lhs, anno.lhs );
rhs.addParam( name, value, context, ns, loc.rhs, anno.rhs );
}
public void annotation(ParsedElementAnnotation _ea) {
ParsedElementAnnotationHost ea = (ParsedElementAnnotationHost) _ea;
lhs.annotation(ea.lhs);
rhs.annotation(ea.rhs);
}
public ParsedPattern makePattern(Location _loc, Annotations _anno) throws BuildException {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makePattern( loc.lhs, anno.lhs ),
rhs.makePattern( loc.rhs, anno.rhs ));
}
public ParsedPattern makePattern(ParsedPattern _except, Location _loc, Annotations _anno) throws BuildException {
ParsedPatternHost except = (ParsedPatternHost) _except;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makePattern(except.lhs, loc.lhs, anno.lhs),
rhs.makePattern(except.rhs, loc.rhs, anno.rhs));
}
}

View File

@@ -0,0 +1,76 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.Annotations;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.Div;
import com.sun.xml.internal.rngom.ast.om.Location;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public class DivHost extends GrammarSectionHost implements Div {
private final Div lhs;
private final Div rhs;
DivHost(Div lhs, Div rhs) {
super(lhs, rhs);
this.lhs = lhs;
this.rhs = rhs;
}
public void endDiv(Location _loc, Annotations _anno) throws BuildException {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
lhs.endDiv( loc.lhs, anno.lhs );
rhs.endDiv( loc.rhs, anno.rhs );
}
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.CommentList;
import com.sun.xml.internal.rngom.ast.builder.ElementAnnotationBuilder;
import com.sun.xml.internal.rngom.ast.om.Location;
import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
final class ElementAnnotationBuilderHost extends AnnotationsHost implements ElementAnnotationBuilder {
final ElementAnnotationBuilder lhs;
final ElementAnnotationBuilder rhs;
ElementAnnotationBuilderHost( ElementAnnotationBuilder lhs, ElementAnnotationBuilder rhs ) {
super(lhs,rhs);
this.lhs = lhs;
this.rhs = rhs;
}
public void addText(String value, Location _loc, CommentList _comments) throws BuildException {
LocationHost loc = cast(_loc);
CommentListHost comments = (CommentListHost) _comments;
lhs.addText( value, loc.lhs, comments==null?null:comments.lhs );
rhs.addText( value, loc.rhs, comments==null?null:comments.rhs );
}
public ParsedElementAnnotation makeElementAnnotation() throws BuildException {
return new ParsedElementAnnotationHost(
lhs.makeElementAnnotation(),
rhs.makeElementAnnotation() );
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.Annotations;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.Grammar;
import com.sun.xml.internal.rngom.ast.om.Location;
import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
/**
* Wraps {@link Grammar} and provides error checking.
*
* <p>
* The following errors are checked by this host:
*
* <ol>
* <li>referenced to undefined patterns.
* </ol>
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public class GrammarHost extends ScopeHost implements Grammar {
final Grammar lhs;
final Grammar rhs;
public GrammarHost(Grammar lhs,Grammar rhs) {
super(lhs,rhs);
this.lhs = lhs;
this.rhs = rhs;
}
public ParsedPattern endGrammar(Location _loc, Annotations _anno) throws BuildException {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.endGrammar(loc.lhs, anno.lhs),
rhs.endGrammar(loc.rhs, anno.rhs));
}
}

View File

@@ -0,0 +1,106 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.Annotations;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.CommentList;
import com.sun.xml.internal.rngom.ast.builder.Div;
import com.sun.xml.internal.rngom.ast.builder.GrammarSection;
import com.sun.xml.internal.rngom.ast.builder.Include;
import com.sun.xml.internal.rngom.ast.om.Location;
import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public class GrammarSectionHost extends Base implements GrammarSection {
private final GrammarSection lhs;
private final GrammarSection rhs;
GrammarSectionHost( GrammarSection lhs, GrammarSection rhs ) {
this.lhs = lhs;
this.rhs = rhs;
if(lhs==null || rhs==null)
throw new IllegalArgumentException();
}
public void define(String name, Combine combine, ParsedPattern _pattern,
Location _loc, Annotations _anno) throws BuildException {
ParsedPatternHost pattern = (ParsedPatternHost) _pattern;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
lhs.define(name, combine, pattern.lhs, loc.lhs, anno.lhs);
rhs.define(name, combine, pattern.rhs, loc.rhs, anno.rhs);
}
public Div makeDiv() {
return new DivHost( lhs.makeDiv(), rhs.makeDiv() );
}
public Include makeInclude() {
Include l = lhs.makeInclude();
if(l==null) return null;
return new IncludeHost( l, rhs.makeInclude() );
}
public void topLevelAnnotation(ParsedElementAnnotation _ea) throws BuildException {
ParsedElementAnnotationHost ea = (ParsedElementAnnotationHost) _ea;
lhs.topLevelAnnotation(ea==null?null:ea.lhs);
rhs.topLevelAnnotation(ea==null?null:ea.rhs);
}
public void topLevelComment(CommentList _comments) throws BuildException {
CommentListHost comments = (CommentListHost) _comments;
lhs.topLevelComment(comments==null?null:comments.lhs);
rhs.topLevelComment(comments==null?null:comments.rhs);
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.Annotations;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.Include;
import com.sun.xml.internal.rngom.ast.om.Location;
import com.sun.xml.internal.rngom.parse.IllegalSchemaException;
import com.sun.xml.internal.rngom.parse.Parseable;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public class IncludeHost extends GrammarSectionHost implements Include {
private final Include lhs;
private final Include rhs;
IncludeHost(Include lhs, Include rhs) {
super(lhs, rhs);
this.lhs = lhs;
this.rhs = rhs;
}
public void endInclude(Parseable current, String uri, String ns, Location _loc, Annotations _anno) throws BuildException, IllegalSchemaException {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
lhs.endInclude( current, uri, ns, loc.lhs, anno.lhs );
rhs.endInclude( current, uri, ns, loc.rhs, anno.rhs );
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.om.Location;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
final class LocationHost implements Location {
final Location lhs;
final Location rhs;
LocationHost( Location lhs, Location rhs ) {
this.lhs = lhs;
this.rhs = rhs;
}
}

View File

@@ -0,0 +1,165 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.Annotations;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.CommentList;
import com.sun.xml.internal.rngom.ast.builder.NameClassBuilder;
import com.sun.xml.internal.rngom.ast.om.Location;
import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
import com.sun.xml.internal.rngom.ast.om.ParsedNameClass;
import java.util.List;
import java.util.ArrayList;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
final class NameClassBuilderHost extends Base implements NameClassBuilder {
final NameClassBuilder lhs;
final NameClassBuilder rhs;
NameClassBuilderHost( NameClassBuilder lhs, NameClassBuilder rhs ) {
this.lhs = lhs;
this.rhs = rhs;
}
public ParsedNameClass annotate(ParsedNameClass _nc, Annotations _anno) throws BuildException {
ParsedNameClassHost nc = (ParsedNameClassHost) _nc;
AnnotationsHost anno = cast(_anno);
return new ParsedNameClassHost(
lhs.annotate(nc.lhs, anno.lhs),
rhs.annotate(nc.rhs, anno.rhs) );
}
public ParsedNameClass annotateAfter(ParsedNameClass _nc, ParsedElementAnnotation _e) throws BuildException {
ParsedNameClassHost nc = (ParsedNameClassHost) _nc;
ParsedElementAnnotationHost e = (ParsedElementAnnotationHost) _e;
return new ParsedNameClassHost(
lhs.annotateAfter(nc.lhs, e.lhs),
rhs.annotateAfter(nc.rhs, e.rhs));
}
public ParsedNameClass commentAfter(ParsedNameClass _nc, CommentList _comments) throws BuildException {
ParsedNameClassHost nc = (ParsedNameClassHost) _nc;
CommentListHost comments = (CommentListHost) _comments;
return new ParsedNameClassHost(
lhs.commentAfter(nc.lhs, comments==null?null:comments.lhs),
rhs.commentAfter(nc.rhs, comments==null?null:comments.rhs));
}
public ParsedNameClass makeChoice(List _nameClasses, Location _loc, Annotations _anno) {
List<ParsedNameClass> lnc = new ArrayList<ParsedNameClass>();
List<ParsedNameClass> rnc = new ArrayList<ParsedNameClass>();
for( int i=0; i<_nameClasses.size(); i++ ) {
lnc.add(((ParsedNameClassHost)_nameClasses.get(i)).lhs);
rnc.add(((ParsedNameClassHost)_nameClasses.get(i)).rhs);
}
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedNameClassHost(
lhs.makeChoice( lnc, loc.lhs, anno.lhs ),
rhs.makeChoice( rnc, loc.rhs, anno.rhs ) );
}
public ParsedNameClass makeName(String ns, String localName, String prefix, Location _loc, Annotations _anno) {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedNameClassHost(
lhs.makeName( ns, localName, prefix, loc.lhs, anno.lhs ),
rhs.makeName( ns, localName, prefix, loc.rhs, anno.rhs ) );
}
public ParsedNameClass makeNsName(String ns, Location _loc, Annotations _anno) {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedNameClassHost(
lhs.makeNsName( ns, loc.lhs, anno.lhs ),
rhs.makeNsName( ns, loc.rhs, anno.rhs ) );
}
public ParsedNameClass makeNsName(String ns, ParsedNameClass _except, Location _loc, Annotations _anno) {
ParsedNameClassHost except = (ParsedNameClassHost) _except;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedNameClassHost(
lhs.makeNsName( ns, except.lhs, loc.lhs, anno.lhs ),
rhs.makeNsName( ns, except.rhs, loc.rhs, anno.rhs ) );
}
public ParsedNameClass makeAnyName(Location _loc, Annotations _anno) {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedNameClassHost(
lhs.makeAnyName( loc.lhs, anno.lhs ),
rhs.makeAnyName( loc.rhs, anno.rhs ) );
}
public ParsedNameClass makeAnyName(ParsedNameClass _except, Location _loc, Annotations _anno) {
ParsedNameClassHost except = (ParsedNameClassHost) _except;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedNameClassHost(
lhs.makeAnyName( except.lhs, loc.lhs, anno.lhs ),
rhs.makeAnyName( except.rhs, loc.rhs, anno.rhs ) );
}
public ParsedNameClass makeErrorNameClass() {
return new ParsedNameClassHost( lhs.makeErrorNameClass(), rhs.makeErrorNameClass() );
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
final class ParsedElementAnnotationHost implements ParsedElementAnnotation {
final ParsedElementAnnotation lhs;
final ParsedElementAnnotation rhs;
ParsedElementAnnotationHost( ParsedElementAnnotation lhs, ParsedElementAnnotation rhs ) {
this.lhs = lhs;
this.rhs = rhs;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.om.ParsedNameClass;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
final class ParsedNameClassHost implements ParsedNameClass {
final ParsedNameClass lhs;
final ParsedNameClass rhs;
ParsedNameClassHost( ParsedNameClass lhs, ParsedNameClass rhs ) {
this.lhs = lhs;
this.rhs = rhs;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public class ParsedPatternHost implements ParsedPattern {
public final ParsedPattern lhs;
public final ParsedPattern rhs;
ParsedPatternHost( ParsedPattern lhs, ParsedPattern rhs ) {
this.lhs = lhs;
this.rhs = rhs;
}
}

View File

@@ -0,0 +1,372 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.Annotations;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.CommentList;
import com.sun.xml.internal.rngom.ast.builder.DataPatternBuilder;
import com.sun.xml.internal.rngom.ast.builder.ElementAnnotationBuilder;
import com.sun.xml.internal.rngom.ast.builder.Grammar;
import com.sun.xml.internal.rngom.ast.builder.NameClassBuilder;
import com.sun.xml.internal.rngom.ast.builder.SchemaBuilder;
import com.sun.xml.internal.rngom.ast.builder.Scope;
import com.sun.xml.internal.rngom.ast.om.Location;
import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
import com.sun.xml.internal.rngom.ast.om.ParsedNameClass;
import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
import com.sun.xml.internal.rngom.parse.Context;
import com.sun.xml.internal.rngom.parse.IllegalSchemaException;
import com.sun.xml.internal.rngom.parse.Parseable;
import java.util.List;
import java.util.ArrayList;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public class SchemaBuilderHost extends Base implements SchemaBuilder {
final SchemaBuilder lhs;
final SchemaBuilder rhs;
public SchemaBuilderHost( SchemaBuilder lhs, SchemaBuilder rhs ) {
this.lhs = lhs;
this.rhs = rhs;
}
public ParsedPattern annotate(ParsedPattern _p, Annotations _anno)
throws BuildException {
ParsedPatternHost p = (ParsedPatternHost) _p;
AnnotationsHost a = cast(_anno);
return new ParsedPatternHost(
lhs.annotate(p.lhs, a.lhs),
rhs.annotate(p.lhs, a.lhs) );
}
public ParsedPattern annotateAfter(ParsedPattern _p,
ParsedElementAnnotation _e) throws BuildException {
ParsedPatternHost p = (ParsedPatternHost) _p;
ParsedElementAnnotationHost e = (ParsedElementAnnotationHost) _e;
return new ParsedPatternHost(
lhs.annotateAfter(p.lhs, e.lhs),
rhs.annotateAfter(p.rhs, e.rhs));
}
public ParsedPattern commentAfter(ParsedPattern _p, CommentList _comments)
throws BuildException {
ParsedPatternHost p = (ParsedPatternHost) _p;
CommentListHost comments = (CommentListHost) _comments;
return new ParsedPatternHost(
lhs.commentAfter(p.lhs, comments==null?null:comments.lhs),
rhs.commentAfter(p.rhs, comments==null?null:comments.rhs));
}
public ParsedPattern expandPattern(ParsedPattern _p) throws BuildException, IllegalSchemaException {
ParsedPatternHost p = (ParsedPatternHost) _p;
return new ParsedPatternHost(
lhs.expandPattern(p.lhs),
rhs.expandPattern(p.rhs));
}
public NameClassBuilder getNameClassBuilder() throws BuildException {
return new NameClassBuilderHost( lhs.getNameClassBuilder(), rhs.getNameClassBuilder() );
}
public Annotations makeAnnotations(CommentList _comments, Context context) {
CommentListHost comments = (CommentListHost) _comments;
Annotations l = lhs.makeAnnotations((comments!=null)?comments.lhs:null, context);
Annotations r = rhs.makeAnnotations((comments!=null)?comments.rhs:null, context);
if(l==null || r==null)
throw new IllegalArgumentException("annotations cannot be null");
return new AnnotationsHost(l,r);
}
public ParsedPattern makeAttribute(ParsedNameClass _nc, ParsedPattern _p,
Location _loc, Annotations _anno) throws BuildException {
ParsedNameClassHost nc = (ParsedNameClassHost) _nc;
ParsedPatternHost p = (ParsedPatternHost) _p;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeAttribute(nc.lhs, p.lhs, loc.lhs, anno.lhs),
rhs.makeAttribute(nc.rhs, p.rhs, loc.rhs, anno.rhs));
}
public ParsedPattern makeChoice(List patterns,
Location _loc, Annotations _anno) throws BuildException {
List<ParsedPattern> lp = new ArrayList<ParsedPattern>();
List<ParsedPattern> rp = new ArrayList<ParsedPattern>();
for( int i=0; i<patterns.size(); i++ ) {
lp.add( ((ParsedPatternHost)patterns.get(i)).lhs);
rp.add( ((ParsedPatternHost)patterns.get(i)).rhs);
}
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeChoice(lp, loc.lhs, anno.lhs),
rhs.makeChoice(rp, loc.rhs, anno.rhs));
}
public CommentList makeCommentList() {
return new CommentListHost(
lhs.makeCommentList(),
rhs.makeCommentList() );
}
public DataPatternBuilder makeDataPatternBuilder(String datatypeLibrary,
String type, Location _loc) throws BuildException {
LocationHost loc = cast(_loc);
return new DataPatternBuilderHost(
lhs.makeDataPatternBuilder(datatypeLibrary, type, loc.lhs),
rhs.makeDataPatternBuilder(datatypeLibrary, type, loc.rhs) );
}
public ParsedPattern makeElement(ParsedNameClass _nc, ParsedPattern _p,
Location _loc, Annotations _anno) throws BuildException {
ParsedNameClassHost nc = (ParsedNameClassHost) _nc;
ParsedPatternHost p = (ParsedPatternHost) _p;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeElement(nc.lhs, p.lhs, loc.lhs, anno.lhs),
rhs.makeElement(nc.rhs, p.rhs, loc.rhs, anno.rhs));
}
public ElementAnnotationBuilder makeElementAnnotationBuilder(String ns,
String localName, String prefix, Location _loc, CommentList _comments,
Context context) {
LocationHost loc = cast(_loc);
CommentListHost comments = (CommentListHost) _comments;
return new ElementAnnotationBuilderHost(
lhs.makeElementAnnotationBuilder(ns, localName, prefix, loc.lhs, comments==null?null:comments.lhs, context),
rhs.makeElementAnnotationBuilder(ns, localName, prefix, loc.rhs, comments==null?null:comments.rhs, context) );
}
public ParsedPattern makeEmpty(Location _loc, Annotations _anno) {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeEmpty(loc.lhs, anno.lhs),
rhs.makeEmpty(loc.rhs, anno.rhs));
}
public ParsedPattern makeErrorPattern() {
return new ParsedPatternHost(
lhs.makeErrorPattern(),
rhs.makeErrorPattern() );
}
public ParsedPattern makeExternalRef(Parseable current, String uri,
String ns, Scope _scope, Location _loc, Annotations _anno)
throws BuildException, IllegalSchemaException {
ScopeHost scope = (ScopeHost) _scope;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeExternalRef(current, uri, ns, scope.lhs, loc.lhs, anno.lhs),
rhs.makeExternalRef(current, uri, ns, scope.rhs, loc.rhs, anno.rhs) );
}
public Grammar makeGrammar(Scope _parent) {
ScopeHost parent = (ScopeHost) _parent;
return new GrammarHost(
lhs.makeGrammar((parent!=null)?parent.lhs:null),
rhs.makeGrammar((parent!=null)?parent.rhs:null) );
}
public ParsedPattern makeGroup(List patterns,
Location _loc, Annotations _anno) throws BuildException {
List<ParsedPattern> lp = new ArrayList<ParsedPattern>();
List<ParsedPattern> rp = new ArrayList<ParsedPattern>();
for( int i=0; i<patterns.size(); i++ ) {
lp.add( ((ParsedPatternHost)patterns.get(i)).lhs);
rp.add( ((ParsedPatternHost)patterns.get(i)).rhs);
}
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeGroup(lp, loc.lhs, anno.lhs),
rhs.makeGroup(rp, loc.rhs, anno.rhs));
}
public ParsedPattern makeInterleave(List patterns,
Location _loc, Annotations _anno) throws BuildException {
List<ParsedPattern> lp = new ArrayList<ParsedPattern>();
List<ParsedPattern> rp = new ArrayList<ParsedPattern>();
for( int i=0; i<patterns.size(); i++ ) {
lp.add( ((ParsedPatternHost)patterns.get(i)).lhs);
rp.add( ((ParsedPatternHost)patterns.get(i)).rhs);
}
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeInterleave(lp, loc.lhs, anno.lhs),
rhs.makeInterleave(rp, loc.rhs, anno.rhs));
}
public ParsedPattern makeList(ParsedPattern _p, Location _loc,
Annotations _anno) throws BuildException {
ParsedPatternHost p = (ParsedPatternHost) _p;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeList(p.lhs, loc.lhs, anno.lhs),
rhs.makeList(p.rhs, loc.rhs, anno.rhs));
}
public Location makeLocation(String systemId, int lineNumber,
int columnNumber) {
return new LocationHost(
lhs.makeLocation(systemId, lineNumber, columnNumber),
rhs.makeLocation(systemId, lineNumber, columnNumber));
}
public ParsedPattern makeMixed(ParsedPattern _p, Location _loc,
Annotations _anno) throws BuildException {
ParsedPatternHost p = (ParsedPatternHost) _p;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeMixed(p.lhs, loc.lhs, anno.lhs),
rhs.makeMixed(p.rhs, loc.rhs, anno.rhs));
}
public ParsedPattern makeNotAllowed(Location _loc, Annotations _anno) {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeNotAllowed(loc.lhs, anno.lhs),
rhs.makeNotAllowed(loc.rhs, anno.rhs));
}
public ParsedPattern makeOneOrMore(ParsedPattern _p, Location _loc,
Annotations _anno) throws BuildException {
ParsedPatternHost p = (ParsedPatternHost) _p;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeOneOrMore(p.lhs, loc.lhs, anno.lhs),
rhs.makeOneOrMore(p.rhs, loc.rhs, anno.rhs));
}
public ParsedPattern makeZeroOrMore(ParsedPattern _p, Location _loc,
Annotations _anno) throws BuildException {
ParsedPatternHost p = (ParsedPatternHost) _p;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeZeroOrMore(p.lhs, loc.lhs, anno.lhs),
rhs.makeZeroOrMore(p.rhs, loc.rhs, anno.rhs));
}
public ParsedPattern makeOptional(ParsedPattern _p, Location _loc,
Annotations _anno) throws BuildException {
ParsedPatternHost p = (ParsedPatternHost) _p;
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeOptional(p.lhs, loc.lhs, anno.lhs),
rhs.makeOptional(p.rhs, loc.rhs, anno.rhs));
}
public ParsedPattern makeText(Location _loc, Annotations _anno) {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeText(loc.lhs, anno.lhs),
rhs.makeText(loc.rhs, anno.rhs));
}
public ParsedPattern makeValue(String datatypeLibrary, String type,
String value, Context c, String ns, Location _loc, Annotations _anno)
throws BuildException {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeValue(datatypeLibrary,type,value,c,ns,loc.lhs,anno.lhs),
rhs.makeValue(datatypeLibrary,type,value,c,ns,loc.rhs,anno.rhs));
}
public boolean usesComments() {
return lhs.usesComments() || rhs.usesComments();
}
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.host;
import com.sun.xml.internal.rngom.ast.builder.Annotations;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.Scope;
import com.sun.xml.internal.rngom.ast.om.Location;
import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public class ScopeHost extends GrammarSectionHost implements Scope {
protected final Scope lhs;
protected final Scope rhs;
protected ScopeHost( Scope lhs, Scope rhs ) {
super(lhs,rhs);
this.lhs = lhs;
this.rhs = rhs;
}
public ParsedPattern makeParentRef(String name, Location _loc, Annotations _anno) throws BuildException {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeParentRef(name, loc.lhs, anno.lhs),
rhs.makeParentRef(name, loc.rhs, anno.rhs));
}
public ParsedPattern makeRef(String name, Location _loc, Annotations _anno) throws BuildException {
LocationHost loc = cast(_loc);
AnnotationsHost anno = cast(_anno);
return new ParsedPatternHost(
lhs.makeRef(name, loc.lhs, anno.lhs),
rhs.makeRef(name, loc.rhs, anno.rhs));
}
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.xml;
import org.xml.sax.DTDHandler;
import org.xml.sax.SAXException;
import org.relaxng.datatype.ValidationContext;
import java.util.Hashtable;
public abstract class DtdContext implements DTDHandler, ValidationContext {
private final Hashtable notationTable;
private final Hashtable unparsedEntityTable;
public DtdContext() {
notationTable = new Hashtable();
unparsedEntityTable = new Hashtable();
}
public DtdContext(DtdContext dc) {
notationTable = dc.notationTable;
unparsedEntityTable = dc.unparsedEntityTable;
}
public void notationDecl(String name, String publicId, String systemId)
throws SAXException {
notationTable.put(name, name);
}
public void unparsedEntityDecl(
String name,
String publicId,
String systemId,
String notationName)
throws SAXException {
unparsedEntityTable.put(name, name);
}
public boolean isNotation(String notationName) {
return notationTable.get(notationName) != null;
}
public boolean isUnparsedEntity(String entityName) {
return unparsedEntityTable.get(entityName) != null;
}
public void clearDtdContext() {
notationTable.clear();
unparsedEntityTable.clear();
}
}

View File

@@ -0,0 +1,149 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (C) 2004-2011
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.sun.xml.internal.rngom.parse.xml;
import java.io.IOException;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.IncludedGrammar;
import com.sun.xml.internal.rngom.ast.builder.SchemaBuilder;
import com.sun.xml.internal.rngom.ast.builder.Scope;
import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
import com.sun.xml.internal.rngom.parse.IllegalSchemaException;
import com.sun.xml.internal.rngom.parse.Parseable;
import com.sun.xml.internal.rngom.xml.sax.JAXPXMLReaderCreator;
import com.sun.xml.internal.rngom.xml.sax.XMLReaderCreator;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
/**
* RELAX NG schema in the XML syntax.
*
*/
public class SAXParseable implements Parseable {
private final InputSource in;
final XMLReaderCreator xrc;
final ErrorHandler eh;
public SAXParseable(InputSource in, ErrorHandler eh, XMLReaderCreator xrc) {
this.xrc = xrc;
this.eh = eh;
this.in = in;
}
public SAXParseable(InputSource in, ErrorHandler eh) {
this(in,eh,new JAXPXMLReaderCreator());
}
public ParsedPattern parse(SchemaBuilder schemaBuilder) throws BuildException, IllegalSchemaException {
try {
XMLReader xr = xrc.createXMLReader();
SchemaParser sp = new SchemaParser(this, xr, eh, schemaBuilder, null, null,"");
xr.parse(in);
ParsedPattern p = sp.getParsedPattern();
return schemaBuilder.expandPattern(p);
}
catch (SAXException e) {
throw toBuildException(e);
}
catch (IOException e) {
throw new BuildException(e);
}
}
public ParsedPattern parseInclude(String uri, SchemaBuilder schemaBuilder, IncludedGrammar g, String inheritedNs)
throws BuildException, IllegalSchemaException {
try {
XMLReader xr = xrc.createXMLReader();
SchemaParser sp = new SchemaParser(this, xr, eh, schemaBuilder, g, g, inheritedNs);
xr.parse(makeInputSource(xr, uri));
return sp.getParsedPattern();
}
catch (SAXException e) {
throw SAXParseable.toBuildException(e);
}
catch (IOException e) {
throw new BuildException(e);
}
}
public ParsedPattern parseExternal(String uri, SchemaBuilder schemaBuilder, Scope s, String inheritedNs)
throws BuildException, IllegalSchemaException {
try {
XMLReader xr = xrc.createXMLReader();
SchemaParser sp = new SchemaParser(this, xr, eh, schemaBuilder, null, s, inheritedNs);
xr.parse(makeInputSource(xr, uri));
return sp.getParsedPattern();
}
catch (SAXException e) {
throw SAXParseable.toBuildException(e);
}
catch (IOException e) {
throw new BuildException(e);
}
}
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException {
EntityResolver er = xr.getEntityResolver();
if (er != null) {
InputSource inputSource = er.resolveEntity(null, systemId);
if (inputSource != null)
return inputSource;
}
return new InputSource(systemId);
}
static BuildException toBuildException(SAXException e) {
Exception inner = e.getException();
if (inner instanceof BuildException)
throw (BuildException)inner;
throw new BuildException(e);
}
}

File diff suppressed because it is too large Load Diff