feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
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.util.LocatorImpl;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
class Annotation implements Annotations<ElementWrapper,LocatorImpl,CommentListImpl> {
|
||||
|
||||
private final DAnnotation a = new DAnnotation();
|
||||
|
||||
public void addAttribute(String ns, String localName, String prefix, String value, LocatorImpl loc) throws BuildException {
|
||||
a.attributes.put(new QName(ns,localName,prefix),
|
||||
new DAnnotation.Attribute(ns,localName,prefix,value,loc));
|
||||
}
|
||||
|
||||
public void addElement(ElementWrapper ea) throws BuildException {
|
||||
a.contents.add(ea.element);
|
||||
}
|
||||
|
||||
public void addComment(CommentListImpl comments) throws BuildException {
|
||||
}
|
||||
|
||||
public void addLeadingComment(CommentListImpl comments) throws BuildException {
|
||||
}
|
||||
|
||||
DAnnotation getResult() {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
import com.sun.xml.internal.rngom.ast.builder.CommentList;
|
||||
import com.sun.xml.internal.rngom.ast.builder.BuildException;
|
||||
import com.sun.xml.internal.rngom.ast.util.LocatorImpl;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
final class CommentListImpl implements CommentList<LocatorImpl> {
|
||||
public void addComment(String value, LocatorImpl loc) throws BuildException {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
193
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/DAnnotation.java
Normal file
193
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/DAnnotation.java
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
import org.xml.sax.Locator;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Annotation.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DAnnotation {
|
||||
|
||||
/**
|
||||
* Instance reserved to be empty.
|
||||
*/
|
||||
static final DAnnotation EMPTY = new DAnnotation();
|
||||
|
||||
/**
|
||||
* Keyed by QName.
|
||||
*/
|
||||
final Map<QName,Attribute> attributes = new HashMap<QName,Attribute>();
|
||||
|
||||
/**
|
||||
* List of nested elements.
|
||||
*/
|
||||
final List<Element> contents = new ArrayList<Element>();
|
||||
|
||||
/**
|
||||
* Attribute.
|
||||
*/
|
||||
public static class Attribute {
|
||||
private final String ns;
|
||||
private final String localName;
|
||||
private final String prefix;
|
||||
|
||||
private String value;
|
||||
private Locator loc;
|
||||
|
||||
public Attribute(String ns, String localName, String prefix) {
|
||||
this.ns = ns;
|
||||
this.localName = localName;
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public Attribute(String ns, String localName, String prefix, String value, Locator loc) {
|
||||
this.ns = ns;
|
||||
this.localName = localName;
|
||||
this.prefix = prefix;
|
||||
this.value = value;
|
||||
this.loc = loc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the namespace URI of this attribute.
|
||||
*
|
||||
* @return
|
||||
* can be empty (to represent the default namespace), but never null.
|
||||
*/
|
||||
public String getNs() {
|
||||
return ns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local name of this attribute.
|
||||
*
|
||||
* @return
|
||||
* always non-null.
|
||||
*/
|
||||
public String getLocalName() {
|
||||
return localName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the prefix of thie attribute.
|
||||
*
|
||||
* @return
|
||||
* null if this attribute didn't have a prefix.
|
||||
*/
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attribute value.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location in the source schema file where this annotation was present.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*/
|
||||
public Locator getLoc() {
|
||||
return loc;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attribute of a given name.
|
||||
*
|
||||
* @param nsUri
|
||||
* can be empty but must not be null.
|
||||
* @return
|
||||
* null if no such attribute is found.
|
||||
*/
|
||||
public Attribute getAttribute( String nsUri, String localName ) {
|
||||
return getAttribute(new QName(nsUri,localName));
|
||||
}
|
||||
|
||||
public Attribute getAttribute( QName n ) {
|
||||
return attributes.get(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the read-only view of all the attributes.
|
||||
*
|
||||
* @return
|
||||
* can be empty but never null.
|
||||
* the returned map is read-only.
|
||||
*/
|
||||
public Map<QName,Attribute> getAttributes() {
|
||||
return Collections.unmodifiableMap(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the read-only view of all the child elements of this annotation.
|
||||
*
|
||||
* @return
|
||||
* can be empty but never null.
|
||||
* the returned list is read-only.
|
||||
*/
|
||||
public List<Element> getChildren() {
|
||||
return Collections.unmodifiableList(contents);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
import com.sun.xml.internal.rngom.nc.NameClass;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DAttributePattern extends DXmlTokenPattern {
|
||||
public DAttributePattern(NameClass name) {
|
||||
super(name);
|
||||
}
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onAttribute(this);
|
||||
}
|
||||
}
|
||||
@@ -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.digested;
|
||||
|
||||
/**
|
||||
* <choice> pattern.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DChoicePattern extends DContainerPattern {
|
||||
public boolean isNullable() {
|
||||
for( DPattern p=firstChild(); p!=null; p=p.next )
|
||||
if(p.isNullable())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public <V> V accept( DPatternVisitor<V> visitor ) {
|
||||
return visitor.onChoice(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
/**
|
||||
* A pattern that can contain other patterns.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public abstract class DContainerPattern extends DPattern implements Iterable<DPattern> {
|
||||
private DPattern head;
|
||||
private DPattern tail;
|
||||
|
||||
public DPattern firstChild() {
|
||||
return head;
|
||||
}
|
||||
|
||||
public DPattern lastChild() {
|
||||
return tail;
|
||||
}
|
||||
|
||||
public int countChildren() {
|
||||
int i=0;
|
||||
for( DPattern p=firstChild(); p!=null; p=p.next)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
|
||||
public Iterator<DPattern> iterator() {
|
||||
return new Iterator<DPattern>() {
|
||||
DPattern next = head;
|
||||
public boolean hasNext() {
|
||||
return next!=null;
|
||||
}
|
||||
|
||||
public DPattern next() {
|
||||
DPattern r = next;
|
||||
next = next.next;
|
||||
return r;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void add( DPattern child ) {
|
||||
if(tail==null) {
|
||||
child.prev = child.next = null;
|
||||
head = tail = child;
|
||||
} else {
|
||||
child.prev = tail;
|
||||
tail.next = child;
|
||||
child.next = null;
|
||||
tail = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.sun.xml.internal.rngom.digested;
|
||||
|
||||
import com.sun.xml.internal.rngom.ast.om.Location;
|
||||
import com.sun.xml.internal.rngom.parse.Context;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DDataPattern extends DPattern {
|
||||
DPattern except;
|
||||
|
||||
String datatypeLibrary;
|
||||
String type;
|
||||
|
||||
final List<Param> params = new ArrayList<Param>();
|
||||
|
||||
/**
|
||||
* Parameter to a data pattern.
|
||||
*/
|
||||
public final class Param {
|
||||
String name;
|
||||
String value;
|
||||
Context context;
|
||||
String ns;
|
||||
Location loc;
|
||||
Annotation anno;
|
||||
|
||||
public Param(String name, String value, Context context, String ns, Location loc, Annotation anno) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.context = context;
|
||||
this.ns = ns;
|
||||
this.loc = loc;
|
||||
this.anno = anno;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public String getNs() {
|
||||
return ns;
|
||||
}
|
||||
|
||||
public Location getLoc() {
|
||||
return loc;
|
||||
}
|
||||
|
||||
public Annotation getAnno() {
|
||||
return anno;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the datatype library URI.
|
||||
*
|
||||
* @return
|
||||
* Can be empty (which represents the built-in datatypes), but never null.
|
||||
*/
|
||||
public String getDatatypeLibrary() {
|
||||
return datatypeLibrary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the datatype name, such as "int" or "token".
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameters of this <data pattern.
|
||||
*
|
||||
* @return
|
||||
* can be empty but never null.
|
||||
*/
|
||||
public List<Param> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pattern that reprsents the <except> child of this data pattern.
|
||||
*
|
||||
* @return null if not exist.
|
||||
*/
|
||||
public DPattern getExcept() {
|
||||
return except;
|
||||
}
|
||||
|
||||
public boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onData(this);
|
||||
}
|
||||
}
|
||||
89
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/DDefine.java
Normal file
89
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/DDefine.java
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DDefine {
|
||||
private final String name;
|
||||
|
||||
private DPattern pattern;
|
||||
private Boolean nullable;
|
||||
DAnnotation annotation;
|
||||
|
||||
public DDefine(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public DPattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public DAnnotation getAnnotation() {
|
||||
if(annotation==null)
|
||||
return DAnnotation.EMPTY;
|
||||
return annotation;
|
||||
}
|
||||
|
||||
public void setPattern(DPattern pattern) {
|
||||
this.pattern = pattern;
|
||||
this.nullable = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the pattern block.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isNullable() {
|
||||
if(nullable==null)
|
||||
nullable = pattern.isNullable()?Boolean.TRUE:Boolean.FALSE;
|
||||
return nullable.booleanValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
import com.sun.xml.internal.rngom.nc.NameClass;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DElementPattern extends DXmlTokenPattern {
|
||||
public DElementPattern(NameClass name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onElement(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DEmptyPattern extends DPattern {
|
||||
public boolean isNullable() {
|
||||
return true;
|
||||
}
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onEmpty(this);
|
||||
}
|
||||
}
|
||||
@@ -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.digested;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <grammar> pattern, which is a collection of named patterns.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DGrammarPattern extends DPattern implements Iterable<DDefine> {
|
||||
private final Map<String,DDefine> patterns = new HashMap<String,DDefine>();
|
||||
|
||||
DPattern start;
|
||||
|
||||
/**
|
||||
* Gets the start pattern.
|
||||
*/
|
||||
public DPattern getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the named pattern by its name.
|
||||
*
|
||||
* @return
|
||||
* null if not found.
|
||||
*/
|
||||
public DDefine get( String name ) {
|
||||
return patterns.get(name);
|
||||
}
|
||||
|
||||
DDefine getOrAdd( String name ) {
|
||||
if(patterns.containsKey(name)) {
|
||||
return get(name);
|
||||
} else {
|
||||
DDefine d = new DDefine(name);
|
||||
patterns.put(name,d);
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates all the {@link DDefine}s in this grammar.
|
||||
*/
|
||||
public Iterator<DDefine> iterator() {
|
||||
return patterns.values().iterator();
|
||||
}
|
||||
|
||||
public boolean isNullable() {
|
||||
return start.isNullable();
|
||||
}
|
||||
|
||||
public <V> V accept( DPatternVisitor<V> visitor ) {
|
||||
return visitor.onGrammar(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DGroupPattern extends DContainerPattern {
|
||||
public boolean isNullable() {
|
||||
for( DPattern p=firstChild(); p!=null; p=p.next )
|
||||
if(!p.isNullable())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public <V> V accept( DPatternVisitor<V> visitor ) {
|
||||
return visitor.onGroup(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DInterleavePattern extends DContainerPattern {
|
||||
public boolean isNullable() {
|
||||
for( DPattern p=firstChild(); p!=null; p=p.next )
|
||||
if(!p.isNullable())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onInterleave(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DListPattern extends DUnaryPattern {
|
||||
public boolean isNullable() {
|
||||
return getChild().isNullable();
|
||||
}
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onList(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DMixedPattern extends DUnaryPattern {
|
||||
public boolean isNullable() {
|
||||
return getChild().isNullable();
|
||||
}
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onMixed(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DNotAllowedPattern extends DPattern {
|
||||
public boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onNotAllowed(this);
|
||||
}
|
||||
}
|
||||
195
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/DOMPrinter.java
Normal file
195
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/DOMPrinter.java
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.CDATASection;
|
||||
import org.w3c.dom.Comment;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DocumentFragment;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.EntityReference;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.ProcessingInstruction;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
/**
|
||||
* Printer of DOM to XML using StAX {@link XMLStreamWriter}.
|
||||
*
|
||||
* @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
|
||||
*/
|
||||
class DOMPrinter {
|
||||
protected XMLStreamWriter out;
|
||||
|
||||
public DOMPrinter(XMLStreamWriter out) {
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
public void print(Node node) throws XMLStreamException {
|
||||
switch (node.getNodeType()) {
|
||||
case Node.DOCUMENT_NODE:
|
||||
visitDocument((Document) node);
|
||||
break;
|
||||
case Node.DOCUMENT_FRAGMENT_NODE:
|
||||
visitDocumentFragment((DocumentFragment) node);
|
||||
break;
|
||||
case Node.ELEMENT_NODE:
|
||||
visitElement((Element) node);
|
||||
break;
|
||||
case Node.TEXT_NODE:
|
||||
visitText((Text) node);
|
||||
break;
|
||||
case Node.CDATA_SECTION_NODE:
|
||||
visitCDATASection((CDATASection) node);
|
||||
break;
|
||||
case Node.PROCESSING_INSTRUCTION_NODE:
|
||||
visitProcessingInstruction((ProcessingInstruction) node);
|
||||
break;
|
||||
case Node.ENTITY_REFERENCE_NODE:
|
||||
visitReference((EntityReference) node);
|
||||
break;
|
||||
case Node.COMMENT_NODE:
|
||||
visitComment((Comment) node);
|
||||
break;
|
||||
case Node.DOCUMENT_TYPE_NODE:
|
||||
break;
|
||||
case Node.ATTRIBUTE_NODE:
|
||||
case Node.ENTITY_NODE:
|
||||
default:
|
||||
throw new XMLStreamException("Unexpected DOM Node Type "
|
||||
+ node.getNodeType()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected void visitChildren(Node node)
|
||||
throws XMLStreamException {
|
||||
NodeList nodeList = node.getChildNodes();
|
||||
if (nodeList != null) {
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
print(nodeList.item(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void visitDocument(Document document)
|
||||
throws XMLStreamException {
|
||||
out.writeStartDocument();
|
||||
print(document.getDocumentElement());
|
||||
out.writeEndDocument();
|
||||
}
|
||||
|
||||
protected void visitDocumentFragment(DocumentFragment documentFragment)
|
||||
throws XMLStreamException {
|
||||
visitChildren(documentFragment);
|
||||
}
|
||||
|
||||
protected void visitElement(Element node)
|
||||
throws XMLStreamException {
|
||||
out.writeStartElement(node.getPrefix()
|
||||
, node.getLocalName()
|
||||
, node.getNamespaceURI()
|
||||
);
|
||||
NamedNodeMap attrs = node.getAttributes();
|
||||
for (int i = 0; i < attrs.getLength(); i++) {
|
||||
visitAttr((Attr) attrs.item(i));
|
||||
}
|
||||
visitChildren(node);
|
||||
out.writeEndElement();
|
||||
}
|
||||
|
||||
protected void visitAttr(Attr node)
|
||||
throws XMLStreamException {
|
||||
String name = node.getLocalName();
|
||||
if (name.equals("xmlns")) {
|
||||
out.writeDefaultNamespace(node.getNamespaceURI());
|
||||
} else {
|
||||
String prefix = node.getPrefix();
|
||||
if (prefix != null && prefix.equals("xmlns")) {
|
||||
out.writeNamespace(prefix, node.getNamespaceURI());
|
||||
} else if (prefix != null) {
|
||||
out.writeAttribute(prefix
|
||||
, node.getNamespaceURI()
|
||||
, name
|
||||
, node.getNodeValue()
|
||||
);
|
||||
} else {
|
||||
out.writeAttribute(node.getNamespaceURI()
|
||||
, name
|
||||
, node.getNodeValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void visitComment(Comment comment) throws XMLStreamException {
|
||||
out.writeComment(comment.getData());
|
||||
}
|
||||
|
||||
protected void visitText(Text node) throws XMLStreamException {
|
||||
out.writeCharacters(node.getNodeValue());
|
||||
}
|
||||
|
||||
protected void visitCDATASection(CDATASection cdata) throws XMLStreamException {
|
||||
out.writeCData(cdata.getNodeValue());
|
||||
}
|
||||
|
||||
protected void visitProcessingInstruction(ProcessingInstruction processingInstruction)
|
||||
throws XMLStreamException {
|
||||
out.writeProcessingInstruction(processingInstruction.getNodeName()
|
||||
, processingInstruction.getData()
|
||||
);
|
||||
}
|
||||
|
||||
protected void visitReference(EntityReference entityReference)
|
||||
throws XMLStreamException {
|
||||
visitChildren(entityReference);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DOneOrMorePattern extends DUnaryPattern {
|
||||
public boolean isNullable() {
|
||||
return getChild().isNullable();
|
||||
}
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onOneOrMore(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DOptionalPattern extends DUnaryPattern {
|
||||
public boolean isNullable() {
|
||||
return true;
|
||||
}
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onOptional(this);
|
||||
}
|
||||
}
|
||||
115
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/DPattern.java
Normal file
115
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/DPattern.java
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.sun.xml.internal.rngom.digested;
|
||||
|
||||
import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
|
||||
import com.sun.xml.internal.rngom.parse.Parseable;
|
||||
import org.xml.sax.Locator;
|
||||
|
||||
/**
|
||||
* Base class of all the patterns.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public abstract class DPattern implements ParsedPattern {
|
||||
|
||||
Locator location;
|
||||
DAnnotation annotation;
|
||||
/**
|
||||
* Used to chain the child patterns in a doubly-linked list.
|
||||
*/
|
||||
DPattern next;
|
||||
DPattern prev;
|
||||
|
||||
/**
|
||||
* Returns where the pattern is defined in the source code.
|
||||
*/
|
||||
public Locator getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the annotation associated with it.
|
||||
*
|
||||
* @return may be empty, but never be null.
|
||||
*/
|
||||
public DAnnotation getAnnotation() {
|
||||
if (annotation == null) {
|
||||
return DAnnotation.EMPTY;
|
||||
}
|
||||
return annotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this pattern is nullable.
|
||||
*
|
||||
* A nullable pattern is a pattern that can match the empty sequence.
|
||||
*/
|
||||
public abstract boolean isNullable();
|
||||
|
||||
public abstract <V> V accept(DPatternVisitor<V> visitor);
|
||||
|
||||
/**
|
||||
* Creates a {@link Parseable} object that reparses this pattern.
|
||||
*/
|
||||
public Parseable createParseable() {
|
||||
return new PatternParseable(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is {@link DElementPattern}.
|
||||
*/
|
||||
public final boolean isElement() {
|
||||
return this instanceof DElementPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is {@link DAttributePattern}.
|
||||
*/
|
||||
public final boolean isAttribute() {
|
||||
return this instanceof DAttributePattern;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public interface DPatternVisitor<V> {
|
||||
V onAttribute( DAttributePattern p );
|
||||
V onChoice( DChoicePattern p );
|
||||
V onData( DDataPattern p );
|
||||
V onElement( DElementPattern p );
|
||||
V onEmpty( DEmptyPattern p );
|
||||
V onGrammar( DGrammarPattern p );
|
||||
V onGroup( DGroupPattern p );
|
||||
V onInterleave( DInterleavePattern p );
|
||||
V onList( DListPattern p );
|
||||
V onMixed( DMixedPattern p );
|
||||
V onNotAllowed( DNotAllowedPattern p );
|
||||
V onOneOrMore( DOneOrMorePattern p );
|
||||
V onOptional( DOptionalPattern p );
|
||||
V onRef( DRefPattern p );
|
||||
V onText( DTextPattern p );
|
||||
V onValue( DValuePattern p );
|
||||
V onZeroOrMore( DZeroOrMorePattern p );
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DPatternWalker implements DPatternVisitor<Void> {
|
||||
public Void onAttribute(DAttributePattern p) {
|
||||
return onXmlToken(p);
|
||||
}
|
||||
|
||||
protected Void onXmlToken(DXmlTokenPattern p) {
|
||||
return onUnary(p);
|
||||
}
|
||||
|
||||
public Void onChoice(DChoicePattern p) {
|
||||
return onContainer(p);
|
||||
}
|
||||
|
||||
protected Void onContainer(DContainerPattern p) {
|
||||
for( DPattern c=p.firstChild(); c!=null; c=c.next )
|
||||
c.accept(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onData(DDataPattern p) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onElement(DElementPattern p) {
|
||||
return onXmlToken(p);
|
||||
}
|
||||
|
||||
public Void onEmpty(DEmptyPattern p) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onGrammar(DGrammarPattern p) {
|
||||
return p.getStart().accept(this);
|
||||
}
|
||||
|
||||
public Void onGroup(DGroupPattern p) {
|
||||
return onContainer(p);
|
||||
}
|
||||
|
||||
public Void onInterleave(DInterleavePattern p) {
|
||||
return onContainer(p);
|
||||
}
|
||||
|
||||
public Void onList(DListPattern p) {
|
||||
return onUnary(p);
|
||||
}
|
||||
|
||||
public Void onMixed(DMixedPattern p) {
|
||||
return onUnary(p);
|
||||
}
|
||||
|
||||
public Void onNotAllowed(DNotAllowedPattern p) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onOneOrMore(DOneOrMorePattern p) {
|
||||
return onUnary(p);
|
||||
}
|
||||
|
||||
public Void onOptional(DOptionalPattern p) {
|
||||
return onUnary(p);
|
||||
}
|
||||
|
||||
public Void onRef(DRefPattern p) {
|
||||
return p.getTarget().getPattern().accept(this);
|
||||
}
|
||||
|
||||
public Void onText(DTextPattern p) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onValue(DValuePattern p) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onZeroOrMore(DZeroOrMorePattern p) {
|
||||
return onUnary(p);
|
||||
}
|
||||
|
||||
protected Void onUnary(DUnaryPattern p) {
|
||||
return p.getChild().accept(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DRefPattern extends DPattern {
|
||||
private final DDefine target;
|
||||
|
||||
public DRefPattern(DDefine target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public boolean isNullable() {
|
||||
return target.isNullable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link DDefine} that this block refers to.
|
||||
*/
|
||||
public DDefine getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the target.
|
||||
*/
|
||||
public String getName() {
|
||||
return target.getName();
|
||||
}
|
||||
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onRef(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
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.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.ParsedPattern;
|
||||
import com.sun.xml.internal.rngom.ast.util.LocatorImpl;
|
||||
import com.sun.xml.internal.rngom.nc.NameClass;
|
||||
import com.sun.xml.internal.rngom.nc.NameClassBuilderImpl;
|
||||
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 org.w3c.dom.Document;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Parses as {@link Parseable} into a {@link DPattern}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DSchemaBuilderImpl implements SchemaBuilder
|
||||
<NameClass,DPattern,ElementWrapper,LocatorImpl,Annotation,CommentListImpl> {
|
||||
|
||||
private final NameClassBuilder ncb = new NameClassBuilderImpl();
|
||||
|
||||
/**
|
||||
* Used to parse annotations.
|
||||
*/
|
||||
private final Document dom;
|
||||
|
||||
public DSchemaBuilderImpl() {
|
||||
try {
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
dbf.setNamespaceAware(true);
|
||||
this.dom = dbf.newDocumentBuilder().newDocument();
|
||||
} catch (ParserConfigurationException e) {
|
||||
// impossible
|
||||
throw new InternalError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public NameClassBuilder getNameClassBuilder() throws BuildException {
|
||||
return ncb;
|
||||
}
|
||||
|
||||
static DPattern wrap( DPattern p, LocatorImpl loc, Annotation anno ) {
|
||||
p.location = loc;
|
||||
if(anno!=null)
|
||||
p.annotation = anno.getResult();
|
||||
return p;
|
||||
}
|
||||
|
||||
static DContainerPattern addAll( DContainerPattern parent, List<DPattern> children) {
|
||||
for (DPattern c : children)
|
||||
parent.add(c);
|
||||
return parent;
|
||||
}
|
||||
|
||||
static DUnaryPattern addBody( DUnaryPattern parent, ParsedPattern _body, LocatorImpl loc ) {
|
||||
parent.setChild( (DPattern)_body );
|
||||
return parent;
|
||||
}
|
||||
|
||||
public DPattern makeChoice(List<DPattern> patterns, LocatorImpl loc, Annotation anno) throws BuildException {
|
||||
return wrap(addAll(new DChoicePattern(),patterns),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeInterleave(List<DPattern> patterns, LocatorImpl loc, Annotation anno) throws BuildException {
|
||||
return wrap(addAll(new DInterleavePattern(),patterns),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeGroup(List<DPattern> patterns, LocatorImpl loc, Annotation anno) throws BuildException {
|
||||
return wrap(addAll(new DGroupPattern(),patterns),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeOneOrMore(DPattern p, LocatorImpl loc, Annotation anno) throws BuildException {
|
||||
return wrap(addBody(new DOneOrMorePattern(),p,loc),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeZeroOrMore(DPattern p, LocatorImpl loc, Annotation anno) throws BuildException {
|
||||
return wrap(addBody(new DZeroOrMorePattern(),p,loc),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeOptional(DPattern p, LocatorImpl loc, Annotation anno) throws BuildException {
|
||||
return wrap(addBody(new DOptionalPattern(),p,loc),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeList(DPattern p, LocatorImpl loc, Annotation anno) throws BuildException {
|
||||
return wrap(addBody(new DListPattern(),p,loc),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeMixed(DPattern p, LocatorImpl loc, Annotation anno) throws BuildException {
|
||||
return wrap(addBody(new DMixedPattern(),p,loc),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeEmpty(LocatorImpl loc, Annotation anno) {
|
||||
return wrap(new DEmptyPattern(),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeNotAllowed(LocatorImpl loc, Annotation anno) {
|
||||
return wrap(new DNotAllowedPattern(),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeText(LocatorImpl loc, Annotation anno) {
|
||||
return wrap(new DTextPattern(),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeAttribute(NameClass nc, DPattern p, LocatorImpl loc, Annotation anno) throws BuildException {
|
||||
return wrap(addBody(new DAttributePattern(nc),p,loc),loc,anno);
|
||||
}
|
||||
|
||||
public DPattern makeElement(NameClass nc, DPattern p, LocatorImpl loc, Annotation anno) throws BuildException {
|
||||
return wrap(addBody(new DElementPattern(nc),p,loc),loc,anno);
|
||||
}
|
||||
|
||||
public DataPatternBuilder makeDataPatternBuilder(String datatypeLibrary, String type, LocatorImpl loc) throws BuildException {
|
||||
return new DataPatternBuilderImpl(datatypeLibrary,type,loc);
|
||||
}
|
||||
|
||||
public DPattern makeValue(String datatypeLibrary, String type, String value, Context c, String ns, LocatorImpl loc, Annotation anno) throws BuildException {
|
||||
return wrap(new DValuePattern(datatypeLibrary,type,value,c.copy(),ns),loc,anno);
|
||||
}
|
||||
|
||||
public Grammar makeGrammar(Scope parent) {
|
||||
return new GrammarBuilderImpl(new DGrammarPattern(),parent,this);
|
||||
}
|
||||
|
||||
public DPattern annotate(DPattern p, Annotation anno) throws BuildException {
|
||||
// TODO: not sure when this is used
|
||||
return p;
|
||||
}
|
||||
|
||||
public DPattern annotateAfter(DPattern p, ElementWrapper e) throws BuildException {
|
||||
// TODO
|
||||
return p;
|
||||
}
|
||||
|
||||
public DPattern commentAfter(DPattern p, CommentListImpl comments) throws BuildException {
|
||||
// TODO
|
||||
return p;
|
||||
}
|
||||
|
||||
public DPattern makeExternalRef(Parseable current, String uri, String ns,
|
||||
Scope<DPattern, ElementWrapper, LocatorImpl, Annotation, CommentListImpl> scope, LocatorImpl loc, Annotation anno) throws BuildException, IllegalSchemaException {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
public LocatorImpl makeLocation(String systemId, int lineNumber, int columnNumber) {
|
||||
return new LocatorImpl(systemId,lineNumber,columnNumber);
|
||||
}
|
||||
|
||||
public Annotation makeAnnotations(CommentListImpl comments, Context context) {
|
||||
return new Annotation();
|
||||
}
|
||||
|
||||
public ElementAnnotationBuilder makeElementAnnotationBuilder(String ns, String localName, String prefix, LocatorImpl loc, CommentListImpl comments, Context context) {
|
||||
String qname;
|
||||
if(prefix==null)
|
||||
qname = localName;
|
||||
else
|
||||
qname = prefix+':'+localName;
|
||||
return new ElementAnnotationBuilderImpl(dom.createElementNS(ns,qname));
|
||||
}
|
||||
|
||||
public CommentListImpl makeCommentList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public DPattern makeErrorPattern() {
|
||||
return new DNotAllowedPattern();
|
||||
}
|
||||
|
||||
public boolean usesComments() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public DPattern expandPattern(DPattern p) throws BuildException, IllegalSchemaException {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DTextPattern extends DPattern {
|
||||
public boolean isNullable() {
|
||||
return true;
|
||||
}
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onText(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public abstract class DUnaryPattern extends DPattern {
|
||||
private DPattern child;
|
||||
|
||||
public DPattern getChild() {
|
||||
return child;
|
||||
}
|
||||
|
||||
public void setChild(DPattern child) {
|
||||
this.child = child;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
import com.sun.xml.internal.rngom.parse.Context;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DValuePattern extends DPattern {
|
||||
private String datatypeLibrary;
|
||||
private String type;
|
||||
private String value;
|
||||
private Context context;
|
||||
private String ns;
|
||||
|
||||
public DValuePattern(String datatypeLibrary, String type, String value, Context context, String ns) {
|
||||
this.datatypeLibrary = datatypeLibrary;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
this.context = context;
|
||||
this.ns = ns;
|
||||
}
|
||||
|
||||
public String getDatatypeLibrary() {
|
||||
return datatypeLibrary;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public String getNs() {
|
||||
return ns;
|
||||
}
|
||||
|
||||
public boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onValue(this);
|
||||
}
|
||||
}
|
||||
600
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/DXMLPrinter.java
Normal file
600
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/DXMLPrinter.java
Normal file
@@ -0,0 +1,600 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import com.sun.xml.internal.rngom.ast.builder.BuildException;
|
||||
import com.sun.xml.internal.rngom.ast.builder.SchemaBuilder;
|
||||
import com.sun.xml.internal.rngom.ast.util.CheckingSchemaBuilder;
|
||||
import com.sun.xml.internal.rngom.nc.NameClass;
|
||||
import com.sun.xml.internal.rngom.nc.NameClassVisitor;
|
||||
import com.sun.xml.internal.rngom.nc.SimpleNameClass;
|
||||
import com.sun.xml.internal.rngom.parse.Parseable;
|
||||
import com.sun.xml.internal.rngom.parse.compact.CompactParseable;
|
||||
import com.sun.xml.internal.rngom.parse.xml.SAXParseable;
|
||||
import com.sun.xml.internal.rngom.xml.util.WellKnownNamespaces;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/**
|
||||
* Printer of RELAX NG digested model to XML using StAX {@link XMLStreamWriter}.
|
||||
*
|
||||
* @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
|
||||
*/
|
||||
public class DXMLPrinter {
|
||||
protected XMLStreamWriter out;
|
||||
protected String indentStep = "\t";
|
||||
protected String newLine = System.getProperty("line.separator");
|
||||
protected int indent;
|
||||
protected boolean afterEnd = false;
|
||||
protected DXMLPrinterVisitor visitor;
|
||||
protected NameClassXMLPrinterVisitor ncVisitor;
|
||||
protected DOMPrinter domPrinter;
|
||||
|
||||
/**
|
||||
* @param out Output stream.
|
||||
*/
|
||||
public DXMLPrinter(XMLStreamWriter out) {
|
||||
this.out = out;
|
||||
this.visitor = new DXMLPrinterVisitor();
|
||||
this.ncVisitor = new NameClassXMLPrinterVisitor();
|
||||
this.domPrinter = new DOMPrinter(out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints grammar enclosed by start/end document.
|
||||
*
|
||||
* @param grammar
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public void printDocument(DGrammarPattern grammar) throws XMLStreamException {
|
||||
try {
|
||||
visitor.startDocument();
|
||||
visitor.on(grammar);
|
||||
visitor.endDocument();
|
||||
} catch (XMLWriterException e) {
|
||||
if (e.getCause() instanceof XMLStreamException) {
|
||||
throw (XMLStreamException) e.getCause();
|
||||
} else {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints XML fragment for the given pattern.
|
||||
*
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public void print(DPattern pattern) throws XMLStreamException {
|
||||
try {
|
||||
pattern.accept(visitor);
|
||||
} catch (XMLWriterException e) {
|
||||
if (e.getCause() instanceof XMLStreamException) {
|
||||
throw (XMLStreamException) e.getCause();
|
||||
} else {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints XML fragment for the given name class.
|
||||
*
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public void print(NameClass nc) throws XMLStreamException {
|
||||
try {
|
||||
nc.accept(ncVisitor);
|
||||
} catch (XMLWriterException e) {
|
||||
if (e.getCause() instanceof XMLStreamException) {
|
||||
throw (XMLStreamException) e.getCause();
|
||||
} else {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void print(Node node) throws XMLStreamException {
|
||||
domPrinter.print(node);
|
||||
}
|
||||
|
||||
protected class XMLWriterException extends RuntimeException {
|
||||
protected XMLWriterException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
|
||||
protected class XMLWriter {
|
||||
protected void newLine() {
|
||||
try {
|
||||
out.writeCharacters(newLine);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new XMLWriterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void indent() {
|
||||
try {
|
||||
for (int i = 0; i < indent; i++) {
|
||||
out.writeCharacters(indentStep);
|
||||
}
|
||||
} catch (XMLStreamException e) {
|
||||
throw new XMLWriterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void startDocument() {
|
||||
try {
|
||||
out.writeStartDocument();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new XMLWriterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void endDocument() {
|
||||
try {
|
||||
out.writeEndDocument();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new XMLWriterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public final void start(String element) {
|
||||
try {
|
||||
newLine();
|
||||
indent();
|
||||
out.writeStartElement(element);
|
||||
indent++;
|
||||
afterEnd = false;
|
||||
} catch (XMLStreamException e) {
|
||||
throw new XMLWriterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void end() {
|
||||
try {
|
||||
indent--;
|
||||
if (afterEnd) {
|
||||
newLine();
|
||||
indent();
|
||||
}
|
||||
out.writeEndElement();
|
||||
afterEnd = true;
|
||||
} catch (XMLStreamException e) {
|
||||
throw new XMLWriterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void attr(String prefix, String ns, String name, String value) {
|
||||
try {
|
||||
out.writeAttribute(prefix, ns, name, value);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new XMLWriterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void attr(String name, String value) {
|
||||
try {
|
||||
out.writeAttribute(name, value);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new XMLWriterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void ns(String prefix, String uri) {
|
||||
try {
|
||||
out.writeNamespace(prefix, uri);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new XMLWriterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void body(String text) {
|
||||
try {
|
||||
out.writeCharacters(text);
|
||||
afterEnd = false;
|
||||
} catch (XMLStreamException e) {
|
||||
throw new XMLWriterException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected class DXMLPrinterVisitor extends XMLWriter implements DPatternVisitor<Void> {
|
||||
protected void on(DPattern p) {
|
||||
p.accept(this);
|
||||
}
|
||||
|
||||
protected void unwrapGroup(DPattern p) {
|
||||
if (p instanceof DGroupPattern && p.getAnnotation() == DAnnotation.EMPTY) {
|
||||
for (DPattern d : (DGroupPattern) p) {
|
||||
on(d);
|
||||
}
|
||||
} else {
|
||||
on(p);
|
||||
}
|
||||
}
|
||||
|
||||
protected void unwrapChoice(DPattern p) {
|
||||
if (p instanceof DChoicePattern && p.getAnnotation() == DAnnotation.EMPTY) {
|
||||
for (DPattern d : (DChoicePattern) p) {
|
||||
on(d);
|
||||
}
|
||||
} else {
|
||||
on(p);
|
||||
}
|
||||
}
|
||||
|
||||
protected void on(NameClass nc) {
|
||||
if (nc instanceof SimpleNameClass) {
|
||||
QName qname = ((SimpleNameClass) nc).name;
|
||||
String name = qname.getLocalPart();
|
||||
if (!qname.getPrefix().equals("")) name = qname.getPrefix() + ":";
|
||||
attr("name", name);
|
||||
} else {
|
||||
nc.accept(ncVisitor);
|
||||
}
|
||||
}
|
||||
|
||||
protected void on(DAnnotation ann) {
|
||||
if (ann == DAnnotation.EMPTY) return;
|
||||
for (DAnnotation.Attribute attr : ann.getAttributes().values()) {
|
||||
attr(attr.getPrefix(), attr.getNs(), attr.getLocalName(), attr.getValue());
|
||||
}
|
||||
for (Element elem : ann.getChildren()) {
|
||||
try {
|
||||
newLine();
|
||||
indent();
|
||||
print(elem);
|
||||
}
|
||||
catch (XMLStreamException e) {
|
||||
throw new XMLWriterException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Void onAttribute(DAttributePattern p) {
|
||||
start("attribute");
|
||||
on(p.getName());
|
||||
on(p.getAnnotation());
|
||||
DPattern child = p.getChild();
|
||||
// do not print default value
|
||||
if (!(child instanceof DTextPattern)) {
|
||||
on(p.getChild());
|
||||
}
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onChoice(DChoicePattern p) {
|
||||
start("choice");
|
||||
on(p.getAnnotation());
|
||||
for (DPattern d : p) {
|
||||
on(d);
|
||||
}
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onData(DDataPattern p) {
|
||||
List<DDataPattern.Param> params = p.getParams();
|
||||
DPattern except = p.getExcept();
|
||||
start("data");
|
||||
attr("datatypeLibrary", p.getDatatypeLibrary());
|
||||
attr("type", p.getType());
|
||||
on(p.getAnnotation());
|
||||
for (DDataPattern.Param param : params) {
|
||||
start("param");
|
||||
attr("ns", param.getNs());
|
||||
attr("name", param.getName());
|
||||
body(param.getValue());
|
||||
end();
|
||||
}
|
||||
if (except != null) {
|
||||
start("except");
|
||||
unwrapChoice(except);
|
||||
end();
|
||||
}
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onElement(DElementPattern p) {
|
||||
start("element");
|
||||
on(p.getName());
|
||||
on(p.getAnnotation());
|
||||
unwrapGroup(p.getChild());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onEmpty(DEmptyPattern p) {
|
||||
start("empty");
|
||||
on(p.getAnnotation());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onGrammar(DGrammarPattern p) {
|
||||
start("grammar");
|
||||
ns(null, WellKnownNamespaces.RELAX_NG);
|
||||
on(p.getAnnotation());
|
||||
start("start");
|
||||
on(p.getStart());
|
||||
end();
|
||||
for (DDefine d : p) {
|
||||
start("define");
|
||||
attr("name", d.getName());
|
||||
on(d.getAnnotation());
|
||||
unwrapGroup(d.getPattern());
|
||||
end();
|
||||
}
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onGroup(DGroupPattern p) {
|
||||
start("group");
|
||||
on(p.getAnnotation());
|
||||
for (DPattern d : p) {
|
||||
on(d);
|
||||
}
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onInterleave(DInterleavePattern p) {
|
||||
start("interleave");
|
||||
on(p.getAnnotation());
|
||||
for (DPattern d : p) {
|
||||
on(d);
|
||||
}
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onList(DListPattern p) {
|
||||
start("list");
|
||||
on(p.getAnnotation());
|
||||
unwrapGroup(p.getChild());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onMixed(DMixedPattern p) {
|
||||
start("mixed");
|
||||
on(p.getAnnotation());
|
||||
unwrapGroup(p.getChild());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onNotAllowed(DNotAllowedPattern p) {
|
||||
start("notAllowed");
|
||||
on(p.getAnnotation());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onOneOrMore(DOneOrMorePattern p) {
|
||||
start("oneOrMore");
|
||||
on(p.getAnnotation());
|
||||
unwrapGroup(p.getChild());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onOptional(DOptionalPattern p) {
|
||||
start("optional");
|
||||
on(p.getAnnotation());
|
||||
unwrapGroup(p.getChild());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onRef(DRefPattern p) {
|
||||
start("ref");
|
||||
attr("name", p.getName());
|
||||
on(p.getAnnotation());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onText(DTextPattern p) {
|
||||
start("text");
|
||||
on(p.getAnnotation());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onValue(DValuePattern p) {
|
||||
start("value");
|
||||
if (!p.getNs().equals("")) attr("ns", p.getNs());
|
||||
attr("datatypeLibrary", p.getDatatypeLibrary());
|
||||
attr("type", p.getType());
|
||||
on(p.getAnnotation());
|
||||
body(p.getValue());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onZeroOrMore(DZeroOrMorePattern p) {
|
||||
start("zeroOrMore");
|
||||
on(p.getAnnotation());
|
||||
unwrapGroup(p.getChild());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected class NameClassXMLPrinterVisitor extends XMLWriter implements NameClassVisitor<Void> {
|
||||
public Void visitChoice(NameClass nc1, NameClass nc2) {
|
||||
// TODO: flatten nested choices
|
||||
start("choice");
|
||||
nc1.accept(this);
|
||||
nc2.accept(this);
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visitNsName(String ns) {
|
||||
start("nsName");
|
||||
attr("ns", ns);
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visitNsNameExcept(String ns, NameClass nc) {
|
||||
start("nsName");
|
||||
attr("ns", ns);
|
||||
start("except");
|
||||
nc.accept(this);
|
||||
end();
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visitAnyName() {
|
||||
start("anyName");
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visitAnyNameExcept(NameClass nc) {
|
||||
start("anyName");
|
||||
start("except");
|
||||
nc.accept(this);
|
||||
end();
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visitName(QName name) {
|
||||
start("name");
|
||||
if (!name.getPrefix().equals("")) {
|
||||
body(name.getPrefix() + ":");
|
||||
}
|
||||
body(name.getLocalPart());
|
||||
end();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visitNull() {
|
||||
throw new UnsupportedOperationException("visitNull");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Parseable p;
|
||||
|
||||
ErrorHandler eh = new DefaultHandler() {
|
||||
@Override
|
||||
public void error(SAXParseException e) throws SAXException {
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
// the error handler passed to Parseable will receive parsing errors.
|
||||
String path = new File(args[0]).toURL().toString();
|
||||
if (args[0].endsWith(".rng")) {
|
||||
p = new SAXParseable(new InputSource(path), eh);
|
||||
} else {
|
||||
p = new CompactParseable(new InputSource(path), eh);
|
||||
}
|
||||
|
||||
// the error handler passed to CheckingSchemaBuilder will receive additional
|
||||
// errors found during the RELAX NG restrictions check.
|
||||
// typically you'd want to pass in the same error handler,
|
||||
// as there's really no distinction between those two kinds of errors.
|
||||
SchemaBuilder sb = new CheckingSchemaBuilder(new DSchemaBuilderImpl(), eh);
|
||||
try {
|
||||
// run the parser
|
||||
DGrammarPattern grammar = (DGrammarPattern) p.parse(sb);
|
||||
OutputStream out = new FileOutputStream(args[1]);
|
||||
XMLOutputFactory factory = XMLOutputFactory.newInstance();
|
||||
factory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.TRUE);
|
||||
XMLStreamWriter output = factory.createXMLStreamWriter(out);
|
||||
DXMLPrinter printer = new DXMLPrinter(output);
|
||||
printer.printDocument(grammar);
|
||||
output.close();
|
||||
out.close();
|
||||
} catch (BuildException e) {
|
||||
if (e.getCause() instanceof SAXParseException) {
|
||||
SAXParseException se = (SAXParseException) e.getCause();
|
||||
System.out.println("("
|
||||
+ se.getLineNumber()
|
||||
+ ","
|
||||
+ se.getColumnNumber()
|
||||
+ "): "
|
||||
+ se.getMessage());
|
||||
return;
|
||||
} else
|
||||
// I found that Crimson doesn't show the proper stack trace
|
||||
// when a RuntimeException happens inside a SchemaBuilder.
|
||||
// the following code shows the actual exception that happened.
|
||||
if (e.getCause() instanceof SAXException) {
|
||||
SAXException se = (SAXException) e.getCause();
|
||||
if (se.getException() != null)
|
||||
se.getException().printStackTrace();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.digested;
|
||||
|
||||
import com.sun.xml.internal.rngom.nc.NameClass;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public abstract class DXmlTokenPattern extends DUnaryPattern {
|
||||
private final NameClass name;
|
||||
|
||||
public DXmlTokenPattern(NameClass name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name class of this element/attribute.
|
||||
*/
|
||||
public NameClass getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public final boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class DZeroOrMorePattern extends DUnaryPattern {
|
||||
public boolean isNullable() {
|
||||
return true;
|
||||
}
|
||||
public Object accept( DPatternVisitor visitor ) {
|
||||
return visitor.onZeroOrMore(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.sun.xml.internal.rngom.digested;
|
||||
|
||||
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;
|
||||
import org.xml.sax.Locator;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
final class DataPatternBuilderImpl implements DataPatternBuilder {
|
||||
|
||||
private final DDataPattern p;
|
||||
|
||||
public DataPatternBuilderImpl(String datatypeLibrary, String type, Location loc) {
|
||||
p = new DDataPattern();
|
||||
p.location = (Locator)loc;
|
||||
p.datatypeLibrary = datatypeLibrary;
|
||||
p.type = type;
|
||||
}
|
||||
|
||||
public void addParam(String name, String value, Context context, String ns, Location loc, Annotations anno) throws BuildException {
|
||||
p.params.add(p.new Param(name,value,context.copy(),ns,loc,(Annotation)anno));
|
||||
}
|
||||
|
||||
public void annotation(ParsedElementAnnotation ea) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public ParsedPattern makePattern(Location loc, Annotations anno) throws BuildException {
|
||||
return makePattern(null,loc,anno);
|
||||
}
|
||||
|
||||
public ParsedPattern makePattern(ParsedPattern except, Location loc, Annotations anno) throws BuildException {
|
||||
p.except = (DPattern)except;
|
||||
if (anno!=null) {
|
||||
p.annotation = ((Annotation)anno).getResult();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
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;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
class ElementAnnotationBuilderImpl implements ElementAnnotationBuilder {
|
||||
|
||||
private final Element e;
|
||||
|
||||
public ElementAnnotationBuilderImpl(Element e) {
|
||||
this.e = e;
|
||||
}
|
||||
|
||||
|
||||
public void addText(String value, Location loc, CommentList comments) throws BuildException {
|
||||
e.appendChild(e.getOwnerDocument().createTextNode(value));
|
||||
}
|
||||
|
||||
public ParsedElementAnnotation makeElementAnnotation() throws BuildException {
|
||||
return new ElementWrapper(e);
|
||||
}
|
||||
|
||||
public void addAttribute(String ns, String localName, String prefix, String value, Location loc) throws BuildException {
|
||||
e.setAttributeNS(ns,localName,value);
|
||||
}
|
||||
|
||||
public void addElement(ParsedElementAnnotation ea) throws BuildException {
|
||||
e.appendChild(((ElementWrapper)ea).element);
|
||||
}
|
||||
|
||||
public void addComment(CommentList comments) throws BuildException {
|
||||
}
|
||||
|
||||
public void addLeadingComment(CommentList comments) throws BuildException {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
final class ElementWrapper implements ParsedElementAnnotation {
|
||||
final Element element;
|
||||
|
||||
public ElementWrapper(Element e) {
|
||||
this.element = e;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.sun.xml.internal.rngom.digested;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.Grammar;
|
||||
import com.sun.xml.internal.rngom.ast.builder.Include;
|
||||
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.ParsedPattern;
|
||||
import com.sun.xml.internal.rngom.ast.util.LocatorImpl;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
class GrammarBuilderImpl implements Grammar, Div {
|
||||
|
||||
protected final DGrammarPattern grammar;
|
||||
|
||||
protected final Scope parent;
|
||||
|
||||
protected final DSchemaBuilderImpl sb;
|
||||
|
||||
/**
|
||||
* Additional top-level element annotations.
|
||||
* Can be null.
|
||||
*/
|
||||
private List<Element> additionalElementAnnotations;
|
||||
|
||||
public GrammarBuilderImpl(DGrammarPattern p, Scope parent, DSchemaBuilderImpl sb) {
|
||||
this.grammar = p;
|
||||
this.parent = parent;
|
||||
this.sb = sb;
|
||||
}
|
||||
|
||||
public ParsedPattern endGrammar(Location loc, Annotations anno) throws BuildException {
|
||||
// Harshit : Fixed possible NPE and issue in handling of annotations
|
||||
if (anno != null) {
|
||||
if (grammar.annotation != null) {
|
||||
grammar.annotation.contents.addAll(((Annotation) anno).getResult().contents);
|
||||
}
|
||||
}
|
||||
return grammar;
|
||||
}
|
||||
|
||||
public void endDiv(Location loc, Annotations anno) throws BuildException {
|
||||
}
|
||||
|
||||
public void define(String name, Combine combine, ParsedPattern pattern, Location loc, Annotations anno) throws BuildException {
|
||||
if(name==START) {
|
||||
grammar.start = (DPattern)pattern;
|
||||
} else {
|
||||
// TODO: handle combine
|
||||
DDefine d = grammar.getOrAdd(name);
|
||||
d.setPattern( (DPattern) pattern );
|
||||
if (anno!=null) {
|
||||
d.annotation = ((Annotation)anno).getResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void topLevelAnnotation(ParsedElementAnnotation ea) throws BuildException {
|
||||
// Harshit : Fixed issue in handling of annotations
|
||||
if (additionalElementAnnotations==null) {
|
||||
additionalElementAnnotations = new ArrayList<Element>();
|
||||
}
|
||||
additionalElementAnnotations.add(((ElementWrapper)ea).element);
|
||||
if (grammar.annotation==null) {
|
||||
grammar.annotation = new DAnnotation();
|
||||
}
|
||||
grammar.annotation.contents.addAll(additionalElementAnnotations);
|
||||
}
|
||||
|
||||
public void topLevelComment(CommentList comments) throws BuildException {
|
||||
}
|
||||
|
||||
public Div makeDiv() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Include makeInclude() {
|
||||
return new IncludeImpl(grammar,parent,sb);
|
||||
}
|
||||
|
||||
public ParsedPattern makeParentRef(String name, Location loc, Annotations anno) throws BuildException {
|
||||
return parent.makeRef(name,loc,anno);
|
||||
}
|
||||
|
||||
public ParsedPattern makeRef(String name, Location loc, Annotations anno) throws BuildException {
|
||||
return DSchemaBuilderImpl.wrap( new DRefPattern(grammar.getOrAdd(name)), (LocatorImpl)loc, (Annotation)anno );
|
||||
}
|
||||
}
|
||||
109
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/IncludeImpl.java
Normal file
109
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/IncludeImpl.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
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.builder.IncludedGrammar;
|
||||
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;
|
||||
import com.sun.xml.internal.rngom.parse.IllegalSchemaException;
|
||||
import com.sun.xml.internal.rngom.parse.Parseable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
final class IncludeImpl extends GrammarBuilderImpl implements Include {
|
||||
|
||||
private Set overridenPatterns = new HashSet();
|
||||
private boolean startOverriden = false;
|
||||
|
||||
public IncludeImpl(DGrammarPattern p, Scope parent, DSchemaBuilderImpl sb) {
|
||||
super(p, parent, sb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void define(String name, Combine combine, ParsedPattern pattern, Location loc, Annotations anno) throws BuildException {
|
||||
super.define(name, combine, pattern, loc, anno);
|
||||
if(name==START)
|
||||
startOverriden = true;
|
||||
else
|
||||
overridenPatterns.add(name);
|
||||
}
|
||||
|
||||
public void endInclude(Parseable current, String uri, String ns, Location loc, Annotations anno) throws BuildException, IllegalSchemaException {
|
||||
current.parseInclude(uri,sb,new IncludedGrammarImpl(grammar,parent,sb),ns);
|
||||
}
|
||||
|
||||
private class IncludedGrammarImpl extends GrammarBuilderImpl implements IncludedGrammar {
|
||||
public IncludedGrammarImpl(DGrammarPattern p, Scope parent, DSchemaBuilderImpl sb) {
|
||||
super(p, parent, sb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void define(String name, Combine combine, ParsedPattern pattern, Location loc, Annotations anno) throws BuildException {
|
||||
// check for overridden pattern
|
||||
if(name==START) {
|
||||
if(startOverriden)
|
||||
return;
|
||||
} else {
|
||||
if(overridenPatterns.contains(name))
|
||||
return;
|
||||
}
|
||||
// otherwise define
|
||||
super.define(name, combine, pattern, loc, anno);
|
||||
}
|
||||
|
||||
public ParsedPattern endIncludedGrammar(Location loc, Annotations anno) throws BuildException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
100
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/Main.java
Normal file
100
jdkSrc/jdk8/com/sun/xml/internal/rngom/digested/Main.java
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
import com.sun.xml.internal.rngom.ast.builder.BuildException;
|
||||
import com.sun.xml.internal.rngom.ast.builder.SchemaBuilder;
|
||||
import com.sun.xml.internal.rngom.ast.util.CheckingSchemaBuilder;
|
||||
import com.sun.xml.internal.rngom.parse.Parseable;
|
||||
import com.sun.xml.internal.rngom.parse.compact.CompactParseable;
|
||||
import com.sun.xml.internal.rngom.parse.xml.SAXParseable;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Parseable p;
|
||||
|
||||
ErrorHandler eh = new DefaultHandler() {
|
||||
@Override
|
||||
public void error(SAXParseException e) throws SAXException {
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
// the error handler passed to Parseable will receive parsing errors.
|
||||
if(args[0].endsWith(".rng"))
|
||||
p = new SAXParseable(new InputSource(args[0]),eh);
|
||||
else
|
||||
p = new CompactParseable(new InputSource(args[0]),eh);
|
||||
|
||||
// the error handler passed to CheckingSchemaBuilder will receive additional
|
||||
// errors found during the RELAX NG restrictions check.
|
||||
// typically you'd want to pass in the same error handler,
|
||||
// as there's really no distinction between those two kinds of errors.
|
||||
SchemaBuilder sb = new CheckingSchemaBuilder(new DSchemaBuilderImpl(),eh);
|
||||
try {
|
||||
// run the parser
|
||||
p.parse(sb);
|
||||
} catch( BuildException e ) {
|
||||
// I found that Crimson doesn't show the proper stack trace
|
||||
// when a RuntimeException happens inside a SchemaBuilder.
|
||||
// the following code shows the actual exception that happened.
|
||||
if( e.getCause() instanceof SAXException ) {
|
||||
SAXException se = (SAXException) e.getCause();
|
||||
if(se.getException()!=null)
|
||||
se.getException().printStackTrace();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
* 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.digested;
|
||||
|
||||
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.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.Location;
|
||||
import com.sun.xml.internal.rngom.ast.om.ParsedNameClass;
|
||||
import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
|
||||
import com.sun.xml.internal.rngom.nc.NameClass;
|
||||
import com.sun.xml.internal.rngom.parse.Parseable;
|
||||
import org.xml.sax.Locator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
final class PatternParseable implements Parseable {
|
||||
private final DPattern pattern;
|
||||
|
||||
public PatternParseable(DPattern p) {
|
||||
this.pattern = p;
|
||||
}
|
||||
|
||||
public ParsedPattern parse(SchemaBuilder sb) throws BuildException {
|
||||
return (ParsedPattern)pattern.accept(new Parser(sb));
|
||||
}
|
||||
|
||||
public ParsedPattern parseInclude(String uri, SchemaBuilder f, IncludedGrammar g, String inheritedNs) throws BuildException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ParsedPattern parseExternal(String uri, SchemaBuilder f, Scope s, String inheritedNs) throws BuildException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
private static class Parser implements DPatternVisitor<ParsedPattern> {
|
||||
private final SchemaBuilder sb;
|
||||
|
||||
public Parser(SchemaBuilder sb) {
|
||||
this.sb = sb;
|
||||
}
|
||||
|
||||
private Annotations parseAnnotation(DPattern p) {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
private Location parseLocation(DPattern p) {
|
||||
Locator l = p.getLocation();
|
||||
return sb.makeLocation(l.getSystemId(),l.getLineNumber(),l.getColumnNumber());
|
||||
}
|
||||
|
||||
private ParsedNameClass parseNameClass(NameClass name) {
|
||||
// TODO: reparse the name class
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ParsedPattern onAttribute(DAttributePattern p) {
|
||||
return sb.makeAttribute(
|
||||
parseNameClass(p.getName()),
|
||||
(ParsedPattern)p.getChild().accept(this),
|
||||
parseLocation(p),
|
||||
parseAnnotation(p) );
|
||||
}
|
||||
|
||||
public ParsedPattern onChoice(DChoicePattern p) {
|
||||
List<ParsedPattern> kids = new ArrayList<ParsedPattern>();
|
||||
for( DPattern c=p.firstChild(); c!=null; c=c.next )
|
||||
kids.add( (ParsedPattern)c.accept(this) );
|
||||
return sb.makeChoice(kids,parseLocation(p),null);
|
||||
}
|
||||
|
||||
public ParsedPattern onData(DDataPattern p) {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
public ParsedPattern onElement(DElementPattern p) {
|
||||
return sb.makeElement(
|
||||
parseNameClass(p.getName()),
|
||||
(ParsedPattern)p.getChild().accept(this),
|
||||
parseLocation(p),
|
||||
parseAnnotation(p) );
|
||||
}
|
||||
|
||||
public ParsedPattern onEmpty(DEmptyPattern p) {
|
||||
return sb.makeEmpty(
|
||||
parseLocation(p),
|
||||
parseAnnotation(p) );
|
||||
}
|
||||
|
||||
public ParsedPattern onGrammar(DGrammarPattern p) {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
public ParsedPattern onGroup(DGroupPattern p) {
|
||||
List<ParsedPattern> kids = new ArrayList<ParsedPattern>();
|
||||
for( DPattern c=p.firstChild(); c!=null; c=c.next )
|
||||
kids.add( (ParsedPattern)c.accept(this) );
|
||||
return sb.makeGroup(kids,parseLocation(p),null);
|
||||
}
|
||||
|
||||
public ParsedPattern onInterleave(DInterleavePattern p) {
|
||||
List<ParsedPattern> kids = new ArrayList<ParsedPattern>();
|
||||
for( DPattern c=p.firstChild(); c!=null; c=c.next )
|
||||
kids.add( (ParsedPattern)c.accept(this) );
|
||||
return sb.makeInterleave(kids,parseLocation(p),null);
|
||||
}
|
||||
|
||||
public ParsedPattern onList(DListPattern p) {
|
||||
return sb.makeList(
|
||||
(ParsedPattern)p.getChild().accept(this),
|
||||
parseLocation(p),
|
||||
parseAnnotation(p) );
|
||||
}
|
||||
|
||||
public ParsedPattern onMixed(DMixedPattern p) {
|
||||
return sb.makeMixed(
|
||||
(ParsedPattern)p.getChild().accept(this),
|
||||
parseLocation(p),
|
||||
parseAnnotation(p) );
|
||||
}
|
||||
|
||||
public ParsedPattern onNotAllowed(DNotAllowedPattern p) {
|
||||
return sb.makeNotAllowed(
|
||||
parseLocation(p),
|
||||
parseAnnotation(p) );
|
||||
}
|
||||
|
||||
public ParsedPattern onOneOrMore(DOneOrMorePattern p) {
|
||||
return sb.makeOneOrMore(
|
||||
(ParsedPattern)p.getChild().accept(this),
|
||||
parseLocation(p),
|
||||
parseAnnotation(p) );
|
||||
}
|
||||
|
||||
public ParsedPattern onOptional(DOptionalPattern p) {
|
||||
return sb.makeOptional(
|
||||
(ParsedPattern)p.getChild().accept(this),
|
||||
parseLocation(p),
|
||||
parseAnnotation(p) );
|
||||
}
|
||||
|
||||
public ParsedPattern onRef(DRefPattern p) {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
public ParsedPattern onText(DTextPattern p) {
|
||||
return sb.makeText(
|
||||
parseLocation(p),
|
||||
parseAnnotation(p) );
|
||||
}
|
||||
|
||||
public ParsedPattern onValue(DValuePattern p) {
|
||||
return sb.makeValue(
|
||||
p.getDatatypeLibrary(),
|
||||
p.getType(),
|
||||
p.getValue(),
|
||||
p.getContext(),
|
||||
p.getNs(),
|
||||
parseLocation(p),
|
||||
parseAnnotation(p) );
|
||||
}
|
||||
|
||||
public ParsedPattern onZeroOrMore(DZeroOrMorePattern p) {
|
||||
return sb.makeZeroOrMore(
|
||||
(ParsedPattern)p.getChild().accept(this),
|
||||
parseLocation(p),
|
||||
parseAnnotation(p) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user