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

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

View File

@@ -0,0 +1,80 @@
/*
* 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.nc;
import javax.xml.namespace.QName;
final class AnyNameClass extends NameClass {
protected AnyNameClass() {} // no instanciation
public boolean contains(QName name) {
return true;
}
public int containsSpecificity(QName name) {
return SPECIFICITY_ANY_NAME;
}
@Override
public boolean equals(Object obj) {
return obj==this;
}
@Override
public int hashCode() {
return AnyNameClass.class.hashCode();
}
public <V> V accept(NameClassVisitor<V> visitor) {
return visitor.visitAnyName();
}
public boolean isOpen() {
return true;
}
}

View File

@@ -0,0 +1,83 @@
/*
* 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.nc;
import javax.xml.namespace.QName;
public class AnyNameExceptNameClass extends NameClass {
private final NameClass nameClass;
public AnyNameExceptNameClass(NameClass nameClass) {
this.nameClass = nameClass;
}
public boolean contains(QName name) {
return !nameClass.contains(name);
}
public int containsSpecificity(QName name) {
return contains(name) ? SPECIFICITY_ANY_NAME : SPECIFICITY_NONE;
}
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof AnyNameExceptNameClass))
return false;
return nameClass.equals(((AnyNameExceptNameClass) obj).nameClass);
}
public int hashCode() {
return ~nameClass.hashCode();
}
public <V> V accept(NameClassVisitor<V> visitor) {
return visitor.visitAnyNameExcept(nameClass);
}
public boolean isOpen() {
return true;
}
}

View File

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

View File

@@ -0,0 +1,132 @@
/*
* 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.nc;
import com.sun.xml.internal.rngom.ast.om.ParsedNameClass;
import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
/**
* Name class is a set of {@link QName}s.
*/
public abstract class NameClass implements ParsedNameClass, Serializable {
static final int SPECIFICITY_NONE = -1;
static final int SPECIFICITY_ANY_NAME = 0;
static final int SPECIFICITY_NS_NAME = 1;
static final int SPECIFICITY_NAME = 2;
/**
* Returns true if the given {@link QName} is a valid name
* for this QName.
*/
public abstract boolean contains(QName name);
public abstract int containsSpecificity(QName name);
/**
* Visitor pattern support.
*/
public abstract <V> V accept(NameClassVisitor<V> visitor);
/**
* Returns true if the name class accepts infinite number of
* {@link QName}s.
*
* <p>
* Intuitively, this method returns true if the name class is
* some sort of wildcard.
*/
public abstract boolean isOpen();
/**
* If the name class is closed (IOW !{@link #isOpen()}),
* return the set of names in this name class. Otherwise the behavior
* is undefined.
*/
public Set<QName> listNames() {
final Set<QName> names = new HashSet<QName>();
accept(new NameClassWalker() {
@Override
public Void visitName(QName name) {
names.add(name);
return null;
}
});
return names;
}
/**
* Returns true if the intersection between this name class
* and the specified name class is non-empty.
*/
public final boolean hasOverlapWith( NameClass nc2 ) {
return OverlapDetector.overlap(this,nc2);
}
/** Sigleton instance that represents "anyName". */
public static final NameClass ANY = new AnyNameClass();
/**
* Sigleton instance that accepts no name.
*
* <p>
* This instance is useful when doing boolean arithmetic over
* name classes (such as computing an inverse of a given name class, etc),
* even though it can never appear in a RELAX NG surface syntax.
*
* <p>
* Internally, this instance is also used for:
* <ol>
* <li>Used to recover from errors during parsing.
* <li>Mark element patterns with &lt;notAllowed/> content model.
* </ol>
*/
public static final NameClass NULL = new NullNameClass();
}

View File

@@ -0,0 +1,119 @@
/*
* 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.nc;
import com.sun.xml.internal.rngom.ast.builder.Annotations;
import com.sun.xml.internal.rngom.ast.builder.BuildException;
import com.sun.xml.internal.rngom.ast.builder.CommentList;
import com.sun.xml.internal.rngom.ast.builder.NameClassBuilder;
import com.sun.xml.internal.rngom.ast.om.Location;
import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
import java.util.List;
/**
*
* @author
* Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public class NameClassBuilderImpl<
E extends ParsedElementAnnotation,
L extends Location,
A extends Annotations<E,L,CL>,
CL extends CommentList<L>> implements NameClassBuilder<NameClass,E,L,A,CL> {
@Override
public NameClass makeChoice(List<NameClass> nameClasses, L loc, A anno) {
NameClass result = nameClasses.get(0);
for (int i = 1; i < nameClasses.size(); i++) {
result = new ChoiceNameClass(result, nameClasses.get(i));
}
return result;
}
@Override
public NameClass makeName(String ns, String localName, String prefix, L loc, A anno) {
if (prefix == null) {
return new SimpleNameClass(ns, localName);
} else {
return new SimpleNameClass(ns, localName, prefix);
}
}
@Override
public NameClass makeNsName(String ns, L loc, A anno) {
return new NsNameClass(ns);
}
public NameClass makeNsName(String ns, NameClass except, L loc, A anno) {
return new NsNameExceptNameClass(ns, except);
}
public NameClass makeAnyName(L loc, A anno) {
return NameClass.ANY;
}
public NameClass makeAnyName(NameClass except, L loc, A anno) {
return new AnyNameExceptNameClass(except);
}
public NameClass makeErrorNameClass() {
return NameClass.NULL;
}
public NameClass annotate(NameClass nc, A anno) throws BuildException {
return nc;
}
public NameClass annotateAfter(NameClass nc, E e) throws BuildException {
return nc;
}
public NameClass commentAfter(NameClass nc, CL comments) throws BuildException {
return nc;
}
}

View File

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

View File

@@ -0,0 +1,83 @@
/*
* 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.nc;
import javax.xml.namespace.QName;
/**
* @author Kohsuke Kawaguchi
*/
public class NameClassWalker implements NameClassVisitor<Void> {
public Void visitChoice(NameClass nc1, NameClass nc2) {
nc1.accept(this);
return nc2.accept(this);
}
public Void visitNsName(String ns) {
return null;
}
public Void visitNsNameExcept(String ns, NameClass nc) {
return nc.accept(this);
}
public Void visitAnyName() {
return null;
}
public Void visitAnyNameExcept(NameClass nc) {
return nc.accept(this);
}
public Void visitName(QName name) {
return null;
}
public Void visitNull() {
return null;
}
}

View File

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

View File

@@ -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-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.nc;
import javax.xml.namespace.QName;
public class NsNameExceptNameClass extends NameClass {
private final NameClass nameClass;
private final String namespaceURI;
public NsNameExceptNameClass(String namespaceURI, NameClass nameClass) {
this.namespaceURI = namespaceURI;
this.nameClass = nameClass;
}
public boolean contains(QName name) {
return (this.namespaceURI.equals(name.getNamespaceURI())
&& !nameClass.contains(name));
}
public int containsSpecificity(QName name) {
return contains(name) ? SPECIFICITY_NS_NAME : SPECIFICITY_NONE;
}
@Override
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof NsNameExceptNameClass))
return false;
NsNameExceptNameClass other = (NsNameExceptNameClass)obj;
return (namespaceURI.equals(other.namespaceURI)
&& nameClass.equals(other.nameClass));
}
@Override
public int hashCode() {
return namespaceURI.hashCode() ^ nameClass.hashCode();
}
public <V> V accept(NameClassVisitor<V> visitor) {
return visitor.visitNsNameExcept(namespaceURI, nameClass);
}
public boolean isOpen() {
return true;
}
}

View File

@@ -0,0 +1,83 @@
/*
* 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.nc;
import javax.xml.namespace.QName;
final class NullNameClass extends NameClass {
protected NullNameClass() {
}
public boolean contains(QName name) {
return false;
}
public int containsSpecificity(QName name) {
return SPECIFICITY_NONE;
}
@Override
public int hashCode() {
return NullNameClass.class.hashCode();
}
@Override
public boolean equals(Object obj) {
return this==obj;
}
public <V> V accept(NameClassVisitor<V> visitor) {
return visitor.visitNull();
}
public boolean isOpen() {
return false;
}
private Object readResolve() {
return NameClass.NULL;
}
}

View File

@@ -0,0 +1,117 @@
/*
* 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.nc;
import javax.xml.namespace.QName;
class OverlapDetector implements NameClassVisitor<Void> {
private NameClass nc1;
private NameClass nc2;
private boolean overlaps = false;
static final String IMPOSSIBLE = "\u0000";
private OverlapDetector(NameClass nc1, NameClass nc2) {
this.nc1 = nc1;
this.nc2 = nc2;
nc1.accept(this);
nc2.accept(this);
}
private void probe(QName name) {
if (nc1.contains(name) && nc2.contains(name))
overlaps = true;
}
public Void visitChoice(NameClass nc1, NameClass nc2) {
nc1.accept(this);
nc2.accept(this);
return null;
}
public Void visitNsName(String ns) {
probe(new QName(ns, IMPOSSIBLE));
return null;
}
public Void visitNsNameExcept(String ns, NameClass ex) {
probe(new QName(ns, IMPOSSIBLE));
ex.accept(this);
return null;
}
public Void visitAnyName() {
probe(new QName(IMPOSSIBLE, IMPOSSIBLE));
return null;
}
public Void visitAnyNameExcept(NameClass ex) {
probe(new QName(IMPOSSIBLE, IMPOSSIBLE));
ex.accept(this);
return null;
}
public Void visitName(QName name) {
probe(name);
return null;
}
public Void visitNull() {
return null;
}
static boolean overlap(NameClass nc1, NameClass nc2) {
if (nc2 instanceof SimpleNameClass) {
SimpleNameClass snc = (SimpleNameClass) nc2;
return nc1.contains(snc.name);
}
if (nc1 instanceof SimpleNameClass) {
SimpleNameClass snc = (SimpleNameClass) nc1;
return nc2.contains(snc.name);
}
return new OverlapDetector(nc1, nc2).overlaps;
}
}

View File

@@ -0,0 +1,99 @@
/*
* 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.nc;
import javax.xml.namespace.QName;
public class SimpleNameClass extends NameClass {
public final QName name;
public SimpleNameClass(QName name) {
this.name = name;
}
public SimpleNameClass(String nsUri, String localPart) {
this(new QName(nsUri, localPart));
}
public SimpleNameClass(String nsUri, String localPart, String prefix) {
this(new QName(nsUri, localPart, prefix));
}
@Override
public boolean contains(QName name) {
return this.name.equals(name);
}
@Override
public int containsSpecificity(QName name) {
return contains(name) ? SPECIFICITY_NAME : SPECIFICITY_NONE;
}
@Override
public int hashCode() {
return name.hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof SimpleNameClass)) {
return false;
}
SimpleNameClass other = (SimpleNameClass) obj;
return name.equals(other.name);
}
@Override
public <V> V accept(NameClassVisitor<V> visitor) {
return visitor.visitName(name);
}
@Override
public boolean isOpen() {
return false;
}
}