jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [16/24] jena git commit: JENA-1537: Remove dependency on Xerces. Import needed code
Date Fri, 04 May 2018 09:03:17 GMT
http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDelegate.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
new file mode 100644
index 0000000..f75cd1f
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.dv.xs;
+
+import org.apache.jena.ext.xerces.impl.dv.*;
+import org.apache.jena.ext.xerces.xs.*;
+
+/**
+ * Base class for XSSimpleType wrapper implementations.
+ * 
+ * @xerces.internal
+ * 
+ * @version $Id: XSSimpleTypeDelegate.java 1024038 2010-10-18 22:06:35Z sandygao $
+ */
+public class XSSimpleTypeDelegate
+    implements XSSimpleType {
+
+    protected final XSSimpleType type;
+    
+    public XSSimpleTypeDelegate(XSSimpleType type) {
+        if (type == null) {
+            throw new NullPointerException();
+        }
+        this.type = type;
+    }
+    
+    public XSSimpleType getWrappedXSSimpleType() {
+        return type;
+    }
+
+    @Override
+    public XSObjectList getAnnotations() {
+        return type.getAnnotations();
+    }
+
+    @Override
+    public boolean getBounded() {
+        return type.getBounded();
+    }
+
+    @Override
+    public short getBuiltInKind() {
+        return type.getBuiltInKind();
+    }
+
+    @Override
+    public short getDefinedFacets() {
+        return type.getDefinedFacets();
+    }
+
+    @Override
+    public XSObjectList getFacets() {
+        return type.getFacets();
+    }
+
+    @Override
+    public XSObject getFacet(int facetType) {
+        return type.getFacet(facetType);
+    }
+
+    @Override
+    public boolean getFinite() {
+        return type.getFinite();
+    }
+
+    @Override
+    public short getFixedFacets() {
+        return type.getFixedFacets();
+    }
+
+    @Override
+    public XSSimpleTypeDefinition getItemType() {
+        return type.getItemType();
+    }
+
+    @Override
+    public StringList getLexicalEnumeration() {
+        return type.getLexicalEnumeration();
+    }
+
+    @Override
+    public String getLexicalFacetValue(short facetName) {
+        return type.getLexicalFacetValue(facetName);
+    }
+
+    @Override
+    public StringList getLexicalPattern() {
+        return type.getLexicalPattern();
+    }
+
+    @Override
+    public XSObjectList getMemberTypes() {
+        return type.getMemberTypes();
+    }
+
+    @Override
+    public XSObjectList getMultiValueFacets() {
+        return type.getMultiValueFacets();
+    }
+
+    @Override
+    public boolean getNumeric() {
+        return type.getNumeric();
+    }
+
+    @Override
+    public short getOrdered() {
+        return type.getOrdered();
+    }
+
+    @Override
+    public XSSimpleTypeDefinition getPrimitiveType() {
+        return type.getPrimitiveType();
+    }
+
+    @Override
+    public short getVariety() {
+        return type.getVariety();
+    }
+
+    @Override
+    public boolean isDefinedFacet(short facetName) {
+        return type.isDefinedFacet(facetName);
+    }
+
+    @Override
+    public boolean isFixedFacet(short facetName) {
+        return type.isFixedFacet(facetName);
+    }
+
+    @Override
+    public boolean derivedFrom(String namespace, String name, short derivationMethod) {
+        return type.derivedFrom(namespace, name, derivationMethod);
+    }
+
+    @Override
+    public boolean derivedFromType(XSTypeDefinition ancestorType, short derivationMethod) {
+        return type.derivedFromType(ancestorType, derivationMethod);
+    }
+
+    @Override
+    public boolean getAnonymous() {
+        return type.getAnonymous();
+    }
+
+    @Override
+    public XSTypeDefinition getBaseType() {
+        return type.getBaseType();
+    }
+
+    @Override
+    public short getFinal() {
+        return type.getFinal();
+    }
+
+    @Override
+    public short getTypeCategory() {
+        return type.getTypeCategory();
+    }
+
+    @Override
+    public boolean isFinal(short restriction) {
+        return type.isFinal(restriction);
+    }
+
+    @Override
+    public String getName() {
+        return type.getName();
+    }
+
+    @Override
+    public String getNamespace() {
+        return type.getNamespace();
+    }
+
+    @Override
+    public XSNamespaceItem getNamespaceItem() {
+        return type.getNamespaceItem();
+    }
+
+    @Override
+    public short getType() {
+        return type.getType();
+    }
+
+    @Override
+    public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context) 
+        throws InvalidDatatypeFacetException {
+        type.applyFacets(facets, presentFacet, fixedFacet, context);
+    }
+
+    @Override
+    public short getPrimitiveKind() {
+        return type.getPrimitiveKind();
+    }
+
+    @Override
+    public short getWhitespace() throws DatatypeException {
+        return type.getWhitespace();
+    }
+
+    @Override
+    public boolean isEqual(Object value1, Object value2) {
+        return type.isEqual(value1, value2);
+    }
+
+    @Override
+    public boolean isIDType() {
+        return type.isIDType();
+    }
+
+    @Override
+    public void validate(ValidationContext context, ValidatedInfo validatedInfo) 
+        throws InvalidDatatypeValueException {
+        type.validate(context, validatedInfo);
+    }
+
+    @Override
+    public Object validate(String content, ValidationContext context, ValidatedInfo validatedInfo) 
+        throws InvalidDatatypeValueException {
+        return type.validate(content, context, validatedInfo);
+    }
+
+    @Override
+    public Object validate(Object content, ValidationContext context, ValidatedInfo validatedInfo) 
+        throws InvalidDatatypeValueException {
+        return type.validate(content, context, validatedInfo);
+    }
+    
+    @Override
+    public String toString() {
+        return type.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearDV.java
new file mode 100644
index 0000000..0c094f5
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearDV.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.dv.xs;
+
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+
+/**
+ * Validator for <gYear> datatype (W3C Schema Datatypes)
+ *
+ * @xerces.internal 
+ *
+ * @author Elena Litani
+ * @author Gopal Sharma, SUN Microsystem Inc.
+ *
+ * @version $Id: YearDV.java 937741 2010-04-25 04:25:46Z mrglavas $
+ */
+
+public class YearDV extends AbstractDateTimeDV {
+
+    /**
+     * Convert a string to a compiled form
+     *
+     * @param  content The lexical representation of time
+     * @return a valid and normalized time object
+     */
+    @Override
+    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
+        try{
+            return parse(content);
+        } catch(Exception ex){
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gYear"});
+        }
+    }
+
+    /**
+     * Parses, validates and computes normalized version of gYear object
+     *
+     * @param str    The lexical representation of year object CCYY
+     *               with possible time zone Z or (-),(+)hh:mm
+     * @return normalized date representation
+     * @exception SchemaDateTimeException Invalid lexical representation
+     */
+    protected DateTimeData parse(String str) throws SchemaDateTimeException{
+        DateTimeData date = new DateTimeData(str, this);
+        int len = str.length();
+
+        // check for preceding '-' sign
+        int start = 0;
+        if (str.charAt(0)=='-') {
+            start = 1;
+        }
+        int sign = findUTCSign(str, start, len);
+        
+        final int length = ((sign == -1) ? len : sign) - start;
+        if (length < 4) {
+            throw new RuntimeException("Year must have 'CCYY' format");
+        }
+        else if (length > 4 && str.charAt(start) == '0') {
+            throw new RuntimeException("Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden");
+        }
+        
+        if (sign == -1) {
+            date.year=parseIntYear(str, len);
+        }
+        else {
+            date.year=parseIntYear(str, sign);
+            getTimeZone (str, date, sign, len);
+        }
+
+        //initialize values
+        date.month=MONTH;
+        date.day=1;
+
+        //validate and normalize
+        validateDateTime(date);
+
+        //save unnormalized values
+        saveUnnormalized(date);
+        
+        if ( date.utc!=0 && date.utc!='Z' ) {
+            normalize(date);
+        }
+        date.position = 0;
+        return date;
+    }
+
+    /**
+     * Converts year object representation to String
+     *
+     * @param date   year object
+     * @return lexical representation of month: CCYY with optional time zone sign
+     */
+    @Override
+    protected String dateToString(DateTimeData date) {
+        StringBuffer message = new StringBuffer(5);
+        append(message, date.year, 4);
+        append(message, (char)date.utc, 0);
+        return message.toString();
+    }
+    
+    @Override
+    protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
+        return datatypeFactory.newXMLGregorianCalendar(date.unNormYear, DatatypeConstants.FIELD_UNDEFINED, 
+                DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, 
+                DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, 
+                date.hasTimeZone() ? date.timezoneHr * 60 + date.timezoneMin : DatatypeConstants.FIELD_UNDEFINED);
+    }
+}
+
+

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearMonthDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearMonthDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearMonthDV.java
new file mode 100644
index 0000000..507ddc1
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearMonthDV.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.dv.xs;
+
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+
+/**
+ * Validator for &lt;gYearMonth&gt; datatype (W3C Schema Datatypes)
+ *
+ * @xerces.internal 
+ *
+ * @author Elena Litani
+ * @author Gopal Sharma, SUN Microsystem Inc.
+ *
+ * @version $Id: YearMonthDV.java 937741 2010-04-25 04:25:46Z mrglavas $
+ */
+public class YearMonthDV extends AbstractDateTimeDV{
+
+    /**
+     * Convert a string to a compiled form
+     *
+     * @param  content The lexical representation of gYearMonth
+     * @return a valid and normalized gYearMonth object
+     */
+    @Override
+    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
+        try{
+            return parse(content);
+        } catch(Exception ex){
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gYearMonth"});
+        }
+    }
+
+    /**
+     * Parses, validates and computes normalized version of gYearMonth object
+     *
+     * @param str    The lexical representation of gYearMonth object CCYY-MM
+     *               with possible time zone Z or (-),(+)hh:mm
+     * @return normalized date representation
+     * @exception SchemaDateTimeException Invalid lexical representation
+     */
+    protected DateTimeData parse(String str) throws SchemaDateTimeException{
+        DateTimeData date = new DateTimeData(str, this);
+        int len = str.length();
+
+        // get date
+        int end = getYearMonth(str, 0, len, date);
+        date.day = DAY;
+        parseTimeZone (str, end, len, date);
+
+        //validate and normalize
+
+        validateDateTime(date);
+
+        //save unnormalized values
+        saveUnnormalized(date);
+        
+        if ( date.utc!=0 && date.utc!='Z' ) {
+            normalize(date);
+        }
+        date.position = 0;
+        return date;
+    }
+
+    @Override
+    protected String dateToString(DateTimeData date) {
+        StringBuffer message = new StringBuffer(25);
+        append(message, date.year, 4);
+        message.append('-');
+        append(message, date.month, 2);
+        append(message, (char)date.utc, 0);
+        return message.toString();
+    }
+    
+    @Override
+    protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
+        return datatypeFactory.newXMLGregorianCalendar(date.unNormYear, date.unNormMonth, DatatypeConstants.FIELD_UNDEFINED, 
+                DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, 
+                DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, 
+                date.hasTimeZone() ? date.timezoneHr * 60 + date.timezoneMin : DatatypeConstants.FIELD_UNDEFINED);
+    }
+}
+
+

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearMonthDurationDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearMonthDurationDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearMonthDurationDV.java
new file mode 100644
index 0000000..980f410
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/YearMonthDurationDV.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.dv.xs;
+
+import java.math.BigInteger;
+
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.Duration;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+
+/**
+ * Used to validate the <yearMonthDuration> type
+ *
+ * @xerces.internal  
+ * 
+ * @author Ankit Pasricha, IBM
+ *  
+ * @version $Id: YearMonthDurationDV.java 937741 2010-04-25 04:25:46Z mrglavas $
+ */
+class YearMonthDurationDV extends DurationDV {
+    
+    @Override
+    public Object getActualValue(String content, ValidationContext context)
+        throws InvalidDatatypeValueException {
+        try {
+            return parse(content, DurationDV.YEARMONTHDURATION_TYPE);
+        } 
+        catch (Exception ex) {
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "yearMonthDuration"});
+        }
+    }
+    
+    @Override
+    protected Duration getDuration(DateTimeData date) {
+        int sign = 1;
+        if ( date.year<0 || date.month<0) {
+            sign = -1;
+        }
+        return datatypeFactory.newDuration(sign == 1, 
+                date.year != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.year):null, 
+                date.month != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.month):null, 
+                null,
+                null,
+                null,
+                null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ConfigurableValidationState.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ConfigurableValidationState.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ConfigurableValidationState.java
new file mode 100644
index 0000000..22ca02c
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ConfigurableValidationState.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.validation;
+
+/**
+ * <p>An extension of ValidationState which can be configured to turn 
+ * off checking for ID/IDREF errors and unparsed entity errors.</p>
+ * 
+ * @xerces.internal
+ *
+ * @author Peter McCracken, IBM
+ * @version $Id: ConfigurableValidationState.java 449320 2006-09-23 22:37:56Z mrglavas $
+ */
+@SuppressWarnings("all")
+public final class ConfigurableValidationState extends ValidationState {
+    
+    /**
+     * Whether to check for ID/IDREF errors
+     */
+    private boolean fIdIdrefChecking;
+    
+    /**
+     * Whether to check for unparsed entity errors
+     */
+    private boolean fUnparsedEntityChecking;
+    
+    /**
+     * Creates a new ConfigurableValidationState.
+     * By default, error checking for both ID/IDREFs 
+     * and unparsed entities are turned on.
+     */
+    public ConfigurableValidationState() {
+        super();
+        fIdIdrefChecking = true;
+        fUnparsedEntityChecking = true;
+    }
+    
+    /**
+     * Turns checking for ID/IDREF errors on and off.
+     * @param setting true to turn on error checking,
+     *                 false to turn off error checking
+     */
+    public void setIdIdrefChecking(boolean setting) {
+        fIdIdrefChecking = setting;
+    }
+    
+    /**
+     * Turns checking for unparsed entity errors on and off.
+     * @param setting true to turn on error checking,
+     *                 false to turn off error checking
+     */
+    public void setUnparsedEntityChecking(boolean setting) {
+        fUnparsedEntityChecking = setting;
+    }
+    
+    /**
+     * Checks if all IDREFs have a corresponding ID.
+     * @return null, if ID/IDREF checking is turned off
+     *         otherwise, returns the value of the super implementation
+     */
+    public String checkIDRefID() {
+        return (fIdIdrefChecking) ? super.checkIDRefID() : null;
+    }
+    
+    /**
+     * Checks if an ID has already been declared.
+     * @return false, if ID/IDREF checking is turned off
+     *         otherwise, returns the value of the super implementation
+     */
+    public boolean isIdDeclared(String name) {
+        return (fIdIdrefChecking) ? super.isIdDeclared(name) : false;
+    }
+    
+    /**
+     * Checks if an entity is declared.
+     * @return true, if unparsed entity checking is turned off
+     *         otherwise, returns the value of the super implementation
+     */
+    public boolean isEntityDeclared(String name) {
+        return (fUnparsedEntityChecking) ? super.isEntityDeclared(name) : true;
+    }
+    
+    /**
+     * Checks if an entity is unparsed.
+     * @return true, if unparsed entity checking is turned off
+     *         otherwise, returns the value of the super implementation
+     */
+    public boolean isEntityUnparsed(String name) {
+        return (fUnparsedEntityChecking) ? super.isEntityUnparsed(name) : true;
+    }
+    
+    /**
+     * Adds the ID, if ID/IDREF checking is enabled.
+     * @param name the ID to add
+     */
+    public void addId(String name) {
+        if (fIdIdrefChecking) {
+            super.addId(name);
+        }
+    }
+    
+    /**
+     * Adds the IDREF, if ID/IDREF checking is enabled.
+     * @param name the IDREF to add
+     */
+    public void addIdRef(String name) {
+        if (fIdIdrefChecking) {
+            super.addIdRef(name);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/EntityState.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/EntityState.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/EntityState.java
new file mode 100644
index 0000000..ce06fa2
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/EntityState.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.validation;
+
+
+/**
+ * The entity state interface defines methods that must be implemented
+ * by components that store information about entity declarations, as well as by
+ * entity validator that will need to validate attributes of type entity.
+ * 
+ * @xerces.internal
+ * 
+ * @author Elena Litani, IBM
+ * @version $Id: EntityState.java 446719 2006-09-15 20:32:39Z mrglavas $
+ */
+public interface EntityState {
+    /**
+     * Query method to check if entity with this name was declared.
+     * 
+     * @param name
+     * @return true if name is a declared entity
+     */
+    public boolean isEntityDeclared (String name);
+
+    /**
+     * Query method to check if entity is unparsed.
+     * 
+     * @param name
+     * @return true if name is an unparsed entity
+     */
+    public boolean isEntityUnparsed (String name);
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationManager.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationManager.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationManager.java
new file mode 100644
index 0000000..70f0a61
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationManager.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.validation;
+
+import java.util.ArrayList;
+
+/**
+ * ValidationManager is a coordinator property for validators in the 
+ * pipeline. Each validator must know how to interact with
+ * this property. Validators are not required to know what kind of 
+ * other validators present in the pipeline, but should understand
+ * that there are others and that some coordination is required.
+ * 
+ * @xerces.internal
+ * 
+ * @author Elena Litani, IBM
+ * @version $Id: ValidationManager.java 606491 2007-12-22 21:00:53Z mrglavas $
+ */
+@SuppressWarnings("all")
+public class ValidationManager {
+
+    protected final ArrayList fVSs = new ArrayList();
+    protected boolean fGrammarFound = false;
+
+    // used by the DTD validator to tell other components that it has a
+    // cached DTD in hand so there's no reason to 
+    // scan external subset or entity decls.
+    protected boolean fCachedDTD = false;    
+    
+    /**
+     * Each validator should call this method to add its ValidationState into
+     * the validation manager.
+     */
+    public final void addValidationState(ValidationState vs) {
+        fVSs.add(vs);
+    }
+
+    /**
+     * Set the information required to validate entity values.
+     */
+    public final void setEntityState(EntityState state) {
+        for (int i = fVSs.size()-1; i >= 0; i--) {
+            ((ValidationState)fVSs.get(i)).setEntityState(state);
+        }
+    }
+    
+    public final void setGrammarFound(boolean grammar){
+        fGrammarFound = grammar;
+    }
+        
+    public final boolean isGrammarFound(){
+        return fGrammarFound;
+    }
+
+    public final void setCachedDTD(boolean cachedDTD) {
+        fCachedDTD = cachedDTD;
+    } // setCachedDTD(boolean)
+
+    public final boolean isCachedDTD() {
+        return fCachedDTD;
+    } // isCachedDTD():  boolean
+    
+        
+    public final void reset () {
+        fVSs.clear();
+        fGrammarFound = false;
+        fCachedDTD = false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationState.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationState.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationState.java
new file mode 100644
index 0000000..b089787
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/validation/ValidationState.java
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.validation;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+import org.apache.jena.ext.xerces.util.SymbolTable;
+import org.apache.jena.ext.xerces.xni.NamespaceContext;
+
+/**
+ * Implementation of the ValidationContext interface. Used to establish an
+ * environment for simple type validation.
+ * 
+ * @xerces.internal
+ *
+ * @author Elena Litani, IBM
+ * @version $Id: ValidationState.java 713638 2008-11-13 04:42:18Z mrglavas $
+ */
+@SuppressWarnings("all")
+public class ValidationState implements ValidationContext {
+
+    //
+    // private data
+    //
+    private boolean fExtraChecking              = true;
+    private boolean fFacetChecking              = true;
+    private boolean fNormalize                  = true;
+    private boolean fNamespaces                 = true;
+
+    private EntityState fEntityState            = null;
+    private NamespaceContext fNamespaceContext  = null;
+    private SymbolTable fSymbolTable            = null;
+    private Locale fLocale                      = null;
+
+    //REVISIT: Should replace with a lighter structure.
+    private final HashMap fIdTable    = new HashMap();
+    private final HashMap fIdRefTable = new HashMap();
+    private final static Object fNullValue = new Object();
+
+    //
+    // public methods
+    //
+    public void setExtraChecking(boolean newValue) {
+        fExtraChecking = newValue;
+    }
+
+    public void setFacetChecking(boolean newValue) {
+        fFacetChecking = newValue;
+    }
+
+    public void setNormalizationRequired (boolean newValue) {
+          fNormalize = newValue;
+    }
+
+    public void setUsingNamespaces (boolean newValue) {
+          fNamespaces = newValue;
+    }
+
+    public void setEntityState(EntityState state) {
+        fEntityState = state;
+    }
+
+    public void setNamespaceSupport(NamespaceContext namespace) {
+        fNamespaceContext = namespace;
+    }
+
+    public void setSymbolTable(SymbolTable sTable) {
+        fSymbolTable = sTable;
+    }
+
+    /**
+     * return null if all IDREF values have a corresponding ID value;
+     * otherwise return the first IDREF value without a matching ID value.
+     */
+    public String checkIDRefID () {
+        Iterator iter = fIdRefTable.keySet().iterator();
+        String key;
+        while (iter.hasNext()) {
+            key = (String) iter.next();
+            if (!fIdTable.containsKey(key)) {
+                  return key;
+            }
+        }
+        return null;
+    }
+
+    public void reset () {
+        fExtraChecking = true;
+        fFacetChecking = true;
+        fNamespaces = true;
+        fIdTable.clear();
+        fIdRefTable.clear();
+        fEntityState = null;
+        fNamespaceContext = null;
+        fSymbolTable = null;
+    }
+
+    /**
+     * The same validation state can be used to validate more than one (schema)
+     * validation roots. Entity/Namespace/Symbol are shared, but each validation
+     * root needs its own id/idref tables. So we need this method to reset only
+     * the two tables.
+     */
+    public void resetIDTables() {
+        fIdTable.clear();
+        fIdRefTable.clear();
+    }
+
+    //
+    // implementation of ValidationContext methods
+    //
+
+    // whether to do extra id/idref/entity checking
+    @Override
+    public boolean needExtraChecking() {
+        return fExtraChecking;
+    }
+
+    // whether to validate against facets
+    @Override
+    public boolean needFacetChecking() {
+        return fFacetChecking;
+    }
+
+    @Override
+    public boolean needToNormalize (){
+        return fNormalize;
+    }
+
+    @Override
+    public boolean useNamespaces() {
+        return fNamespaces;
+    }
+
+    // entity
+    @Override
+    public boolean isEntityDeclared (String name) {
+        if (fEntityState !=null) {
+            return fEntityState.isEntityDeclared(getSymbol(name));
+        }
+        return false;
+    }
+    @Override
+    public boolean isEntityUnparsed (String name) {
+        if (fEntityState !=null) {
+            return fEntityState.isEntityUnparsed(getSymbol(name));
+        }
+        return false;
+    }
+
+    // id
+    @Override
+    public boolean isIdDeclared(String name) {
+        return fIdTable.containsKey(name);
+    }
+    @Override
+    public void addId(String name) {
+        fIdTable.put(name, fNullValue);
+    }
+
+    // idref
+    @Override
+    public void addIdRef(String name) {
+        fIdRefTable.put(name, fNullValue);
+    }
+    // get symbols
+
+    @Override
+    public String getSymbol (String symbol) {
+        if (fSymbolTable != null)
+            return fSymbolTable.addSymbol(symbol);
+        // if there is no symbol table, we return java-internalized string,
+        // because symbol table strings are also java-internalzied.
+        // this guarantees that the returned string from this method can be
+        // compared by reference with other symbol table string. -SG
+        return symbol.intern();
+    }
+    // qname, notation
+    @Override
+    public String getURI(String prefix) {
+        if (fNamespaceContext !=null) {
+            return fNamespaceContext.getURI(prefix);
+        }
+        return null;
+    }
+    
+    // Locale
+    
+    public void setLocale(Locale locale) {
+        fLocale = locale;
+    }
+    
+    @Override
+    public Locale getLocale() {
+        return fLocale;
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/BMPattern.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/BMPattern.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/BMPattern.java
new file mode 100644
index 0000000..b8851f8
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/BMPattern.java
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.xpath.regex;
+
+import java.text.CharacterIterator;
+
+/**
+ * Boyer-Moore searcher.
+ * 
+ * @xerces.internal
+ *
+ * @version $Id: BMPattern.java 572108 2007-09-02 18:48:31Z mrglavas $
+ */
+public class BMPattern {
+    final char[] pattern;
+    final int[] shiftTable;
+    final boolean ignoreCase;
+
+    public BMPattern(String pat, boolean ignoreCase) {
+        this(pat, 256, ignoreCase);
+    }
+
+    public BMPattern(String pat, int tableSize, boolean ignoreCase) {
+        this.pattern = pat.toCharArray();
+        this.shiftTable = new int[tableSize];
+        this.ignoreCase = ignoreCase;
+
+        int length = pattern.length;
+        for (int i = 0;  i < this.shiftTable.length;  i ++)
+            this.shiftTable[i] = length;
+
+        for (int i = 0;  i < length;  i ++) {
+            char ch = this.pattern[i];
+            int diff = length-i-1;
+            int index = ch % this.shiftTable.length;
+            if (diff < this.shiftTable[index])
+                this.shiftTable[index] = diff;
+            if (this.ignoreCase) {
+                ch = Character.toUpperCase(ch);
+                index = ch % this.shiftTable.length;
+                if (diff < this.shiftTable[index])
+                    this.shiftTable[index] = diff;
+                ch = Character.toLowerCase(ch);
+                index = ch % this.shiftTable.length;
+                if (diff < this.shiftTable[index])
+                    this.shiftTable[index] = diff;
+            }
+        }
+    }
+
+    /**
+     *
+     * @return -1 if <var>iterator</var> does not contain this pattern.
+     */
+    public int matches(CharacterIterator iterator, int start, int limit) {
+        if (this.ignoreCase)  return this.matchesIgnoreCase(iterator, start, limit);
+        int plength = this.pattern.length;
+        if (plength == 0)  return start;
+        int index = start+plength;
+        while (index <= limit) {
+            int pindex = plength;
+            int nindex = index+1;
+            char ch;
+            do {
+                if ((ch = iterator.setIndex(--index)) != this.pattern[--pindex])
+                    break;
+                if (pindex == 0)
+                    return index;
+            } while (pindex > 0);
+            index += this.shiftTable[ch % this.shiftTable.length]+1;
+            if (index < nindex)  index = nindex;
+        }
+        return -1;
+    }
+
+    /**
+     *
+     * @return -1 if <var>str</var> does not contain this pattern.
+     */
+    public int matches(String str, int start, int limit) {
+        if (this.ignoreCase)  return this.matchesIgnoreCase(str, start, limit);
+        int plength = this.pattern.length;
+        if (plength == 0)  return start;
+        int index = start+plength;
+        while (index <= limit) {
+            //System.err.println("Starts at "+index);
+            int pindex = plength;
+            int nindex = index+1;
+            char ch;
+            do {
+                if ((ch = str.charAt(--index)) != this.pattern[--pindex])
+                    break;
+                if (pindex == 0)
+                    return index;
+            } while (pindex > 0);
+            index += this.shiftTable[ch % this.shiftTable.length]+1;
+            if (index < nindex)  index = nindex;
+        }
+        return -1;
+    }
+    /**
+     *
+     * @return -1 if <var>chars</char> does not contain this pattern.
+     */
+    public int matches(char[] chars, int start, int limit) {
+        if (this.ignoreCase)  return this.matchesIgnoreCase(chars, start, limit);
+        int plength = this.pattern.length;
+        if (plength == 0)  return start;
+        int index = start+plength;
+        while (index <= limit) {
+            //System.err.println("Starts at "+index);
+            int pindex = plength;
+            int nindex = index+1;
+            char ch;
+            do {
+                if ((ch = chars[--index]) != this.pattern[--pindex])
+                    break;
+                if (pindex == 0)
+                    return index;
+            } while (pindex > 0);
+            index += this.shiftTable[ch % this.shiftTable.length]+1;
+            if (index < nindex)  index = nindex;
+        }
+        return -1;
+    }
+
+    int matchesIgnoreCase(CharacterIterator iterator, int start, int limit) {
+        int plength = this.pattern.length;
+        if (plength == 0)  return start;
+        int index = start+plength;
+        while (index <= limit) {
+            int pindex = plength;
+            int nindex = index+1;
+            char ch;
+            do {
+                char ch1 = ch = iterator.setIndex(--index);
+                char ch2 = this.pattern[--pindex];
+                if (ch1 != ch2) {
+                    ch1 = Character.toUpperCase(ch1);
+                    ch2 = Character.toUpperCase(ch2);
+                    if (ch1 != ch2 && Character.toLowerCase(ch1) != Character.toLowerCase(ch2))
+                        break;
+                }
+                if (pindex == 0)
+                    return index;
+            } while (pindex > 0);
+            index += this.shiftTable[ch % this.shiftTable.length]+1;
+            if (index < nindex)  index = nindex;
+        }
+        return -1;
+    }
+    
+    int matchesIgnoreCase(String text, int start, int limit) {
+        int plength = this.pattern.length;
+        if (plength == 0)  return start;
+        int index = start+plength;
+        while (index <= limit) {
+            int pindex = plength;
+            int nindex = index+1;
+            char ch;
+            do {
+                char ch1 = ch = text.charAt(--index);
+                char ch2 = this.pattern[--pindex];
+                if (ch1 != ch2) {
+                    ch1 = Character.toUpperCase(ch1);
+                    ch2 = Character.toUpperCase(ch2);
+                    if (ch1 != ch2 && Character.toLowerCase(ch1) != Character.toLowerCase(ch2))
+                        break;
+                }
+                if (pindex == 0)
+                    return index;
+            } while (pindex > 0);
+            index += this.shiftTable[ch % this.shiftTable.length]+1;
+            if (index < nindex)  index = nindex;
+        }
+        return -1;
+    }
+    int matchesIgnoreCase(char[] chars, int start, int limit) {
+        int plength = this.pattern.length;
+        if (plength == 0)  return start;
+        int index = start+plength;
+        while (index <= limit) {
+            int pindex = plength;
+            int nindex = index+1;
+            char ch;
+            do {
+                char ch1 = ch = chars[--index];
+                char ch2 = this.pattern[--pindex];
+                if (ch1 != ch2) {
+                    ch1 = Character.toUpperCase(ch1);
+                    ch2 = Character.toUpperCase(ch2);
+                    if (ch1 != ch2 && Character.toLowerCase(ch1) != Character.toLowerCase(ch2))
+                        break;
+                }
+                if (pindex == 0)
+                    return index;
+            } while (pindex > 0);
+            index += this.shiftTable[ch % this.shiftTable.length]+1;
+            if (index < nindex)  index = nindex;
+        }
+        return -1;
+    }
+
+    /*
+    public static void main(String[] argv) {
+        try {
+            int[] shiftTable = new int[256];
+            initializeBoyerMoore(argv[0], shiftTable, true);
+            int o = -1;
+            CharacterIterator ite = new java.text.StringCharacterIterator(argv[1]);
+            long start = System.currentTimeMillis();
+            //for (int i = 0;  i < 10000;  i ++)
+                o = searchIgnoreCasesWithBoyerMoore(ite, 0, argv[0], shiftTable);
+            start = System.currentTimeMillis()-start;
+            System.out.println("Result: "+o+", Elapsed: "+start);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }*/
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/CaseInsensitiveMap.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/CaseInsensitiveMap.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/CaseInsensitiveMap.java
new file mode 100644
index 0000000..2f62626
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/CaseInsensitiveMap.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.xpath.regex;
+
+/**
+ * @xerces.internal
+ * 
+ * @version $Id: CaseInsensitiveMap.java 834653 2009-11-10 20:32:39Z mrglavas $
+ */
+final class CaseInsensitiveMap {
+
+    private static int CHUNK_SHIFT = 10;           /* 2^10 = 1k */
+    private static int CHUNK_SIZE = (1<<CHUNK_SHIFT);
+    private static int CHUNK_MASK = (CHUNK_SIZE-1);
+    private static int INITIAL_CHUNK_COUNT = 64;   /* up to 0xFFFF */
+
+    private static int[][][] caseInsensitiveMap;
+    
+    private static int LOWER_CASE_MATCH = 1;
+    private static int UPPER_CASE_MATCH = 2;
+    
+    static {
+        buildCaseInsensitiveMap();
+    }
+
+    /**
+     *  Return a list of code point characters (not including the input value)
+     *  that can be substituted in a case insensitive match
+     */
+    static public int[] get(int codePoint) {
+        return (codePoint < 0x10000) ? getMapping(codePoint) : null;
+    }
+
+    private static int[] getMapping(int codePoint) {
+        int chunk = codePoint >>> CHUNK_SHIFT;
+        int offset = codePoint & CHUNK_MASK;
+        
+        return caseInsensitiveMap[chunk][offset];
+    }
+    
+    private static void buildCaseInsensitiveMap() {
+        caseInsensitiveMap = new int[INITIAL_CHUNK_COUNT][CHUNK_SIZE][];
+        int lc, uc;
+        for (int i=0; i<0x10000; i++) {
+            lc = Character.toLowerCase((char) i);
+            uc = Character.toUpperCase((char) i);
+
+            // lower/upper case value is not the same as code point
+            if (lc != uc || lc != i) {
+                int[] map = new int[2];
+                int index = 0;
+
+                if (lc != i) {
+                    map[index++] = lc;
+                    map[index++] = LOWER_CASE_MATCH;
+                    int[] lcMap = getMapping(lc);
+                    if (lcMap != null) {
+                        map = updateMap(i, map, lc, lcMap, LOWER_CASE_MATCH);
+                    }
+                }
+                
+                if (uc != i) {
+                    if (index == map.length) {
+                        map = expandMap(map, 2);
+                    }
+                    map[index++] = uc;
+                    map[index++] = UPPER_CASE_MATCH;
+                    int[] ucMap = getMapping(uc);
+                    if (ucMap != null) {
+                        map = updateMap(i, map, uc, ucMap, UPPER_CASE_MATCH);
+                    }
+                }
+                
+                set(i, map);
+            }
+        }
+    }
+    
+    private static int[] expandMap(int[] srcMap, int expandBy) {
+        final int oldLen = srcMap.length;
+        int[] newMap = new int[oldLen + expandBy];
+        
+        System.arraycopy(srcMap, 0, newMap, 0, oldLen);
+        return newMap;
+    }
+    
+    private static void set(int codePoint, int[] map) {
+        int chunk = codePoint >>> CHUNK_SHIFT;
+        int offset = codePoint & CHUNK_MASK;
+        
+        caseInsensitiveMap[chunk][offset] = map;
+    }
+
+    private static int[] updateMap(int codePoint, int[] codePointMap,
+            int ciCodePoint, int[] ciCodePointMap, int matchType) {
+        for (int i=0; i<ciCodePointMap.length; i+=2) {
+            int c = ciCodePointMap[i];
+            int[] cMap = getMapping(c);
+            if (cMap != null) {
+                if (contains(cMap, ciCodePoint, matchType)) {
+                    if (!contains(cMap, codePoint)) {
+                        cMap = expandAndAdd(cMap, codePoint, matchType);
+                        set(c, cMap);
+                    }
+                    if (!contains(codePointMap, c)) {
+                        codePointMap = expandAndAdd(codePointMap, c,matchType);
+                    }
+                }
+            }
+        }
+        
+        if (!contains(ciCodePointMap, codePoint)) {
+            ciCodePointMap = expandAndAdd(ciCodePointMap, codePoint, matchType);
+            set(ciCodePoint, ciCodePointMap);
+        }
+
+        return codePointMap;
+    }
+    
+    private static boolean contains(int[] map, int codePoint) {
+        for (int i=0; i<map.length; i += 2) {
+            if (map[i] == codePoint) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static boolean contains(int[] map, int codePoint, int matchType) {
+        for (int i=0; i<map.length; i += 2) {
+            if (map[i] == codePoint && map[i+1] == matchType) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    private static int[] expandAndAdd(int[] srcMap, int codePoint, int matchType) {
+        final int oldLen = srcMap.length;
+        int[] newMap = new int[oldLen + 2];
+        
+        System.arraycopy(srcMap, 0, newMap, 0, oldLen);
+        newMap[oldLen] = codePoint;
+        newMap[oldLen+1] = matchType;
+        return newMap;
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/Match.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/Match.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/Match.java
new file mode 100644
index 0000000..c6bc1f8
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/Match.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.xpath.regex;
+
+import java.text.CharacterIterator;
+
+/**
+ * An instance of this class has ranges captured in matching.
+ * 
+ * @xerces.internal
+ *
+ * @see RegularExpression#matches(char[], int, int, Match)
+ * @see RegularExpression#matches(char[], Match)
+ * @see RegularExpression#matches(java.text.CharacterIterator, Match)
+ * @see RegularExpression#matches(java.lang.String, int, int, Match)
+ * @see RegularExpression#matches(java.lang.String, Match)
+ * @author TAMURA Kent &lt;kent@trl.ibm.co.jp&gt;
+ * @version $Id: Match.java 446721 2006-09-15 20:35:34Z mrglavas $
+ */
+public class Match implements Cloneable {
+    int[] beginpos = null;
+    int[] endpos = null;
+    int nofgroups = 0;
+
+    CharacterIterator ciSource = null;
+    String strSource = null;
+    char[] charSource = null;
+
+    /**
+     * Creates an instance.
+     */
+    public Match() {
+    }
+
+    /**
+     *
+     */
+    @Override
+    public synchronized Object clone() {
+        Match ma = new Match();
+        if (this.nofgroups > 0) {
+            ma.setNumberOfGroups(this.nofgroups);
+            if (this.ciSource != null)  ma.setSource(this.ciSource);
+            if (this.strSource != null)  ma.setSource(this.strSource);
+            for (int i = 0;  i < this.nofgroups;  i ++) {
+                ma.setBeginning(i, this.getBeginning(i));
+                ma.setEnd(i, this.getEnd(i));
+            }
+        }
+        return ma;
+    }
+
+    /**
+     *
+     */
+    protected void setNumberOfGroups(int n) {
+        int oldn = this.nofgroups;
+        this.nofgroups = n;
+        if (oldn <= 0
+            || oldn < n || n*2 < oldn) {
+            this.beginpos = new int[n];
+            this.endpos = new int[n];
+        }
+        for (int i = 0;  i < n;  i ++) {
+            this.beginpos[i] = -1;
+            this.endpos[i] = -1;
+        }
+    }
+
+    /**
+     *
+     */
+    protected void setSource(CharacterIterator ci) {
+        this.ciSource = ci;
+        this.strSource = null;
+        this.charSource = null;
+    }
+    /**
+     *
+     */
+    protected void setSource(String str) {
+        this.ciSource = null;
+        this.strSource = str;
+        this.charSource = null;
+    }
+    /**
+     *
+     */
+    protected void setSource(char[] chars) {
+        this.ciSource = null;
+        this.strSource = null;
+        this.charSource = chars;
+    }
+
+    /**
+     *
+     */
+    protected void setBeginning(int index, int v) {
+        this.beginpos[index] = v;
+    }
+
+    /**
+     *
+     */
+    protected void setEnd(int index, int v) {
+        this.endpos[index] = v;
+    }
+
+    /**
+     * Return the number of regular expression groups.
+     * This method returns 1 when the regular expression has no capturing-parenthesis.
+     */
+    public int getNumberOfGroups() {
+        if (this.nofgroups <= 0)
+            throw new IllegalStateException("A result is not set.");
+        return this.nofgroups;
+    }
+
+    /**
+     * Return a start position in the target text matched to specified regular expression group.
+     *
+     * @param index Less than <code>getNumberOfGroups()</code>.
+     */
+    public int getBeginning(int index) {
+        if (this.beginpos == null)
+            throw new IllegalStateException("A result is not set.");
+        if (index < 0 || this.nofgroups <= index)
+            throw new IllegalArgumentException("The parameter must be less than "
+                                               +this.nofgroups+": "+index);
+        return this.beginpos[index];
+    }
+
+    /**
+     * Return an end position in the target text matched to specified regular expression group.
+     *
+     * @param index Less than <code>getNumberOfGroups()</code>.
+     */
+    public int getEnd(int index) {
+        if (this.endpos == null)
+            throw new IllegalStateException("A result is not set.");
+        if (index < 0 || this.nofgroups <= index)
+            throw new IllegalArgumentException("The parameter must be less than "
+                                               +this.nofgroups+": "+index);
+        return this.endpos[index];
+    }
+
+    /**
+     * Return an substring of the target text matched to specified regular expression group.
+     *
+     * @param index Less than <code>getNumberOfGroups()</code>.
+     */
+    public String getCapturedText(int index) {
+        if (this.beginpos == null)
+            throw new IllegalStateException("match() has never been called.");
+        if (index < 0 || this.nofgroups <= index)
+            throw new IllegalArgumentException("The parameter must be less than "
+                                               +this.nofgroups+": "+index);
+        String ret;
+        int begin = this.beginpos[index], end = this.endpos[index];
+        if (begin < 0 || end < 0)  return null;
+        if (this.ciSource != null) {
+            ret = REUtil.substring(this.ciSource, begin, end);
+        } else if (this.strSource != null) {
+            ret = this.strSource.substring(begin, end);
+        } else {
+            ret = new String(this.charSource, begin, end-begin);
+        }
+        return ret;
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/Op.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/Op.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/Op.java
new file mode 100644
index 0000000..7f5f71b
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/Op.java
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.xpath.regex;
+
+import java.util.Vector;
+
+/**
+ * @xerces.internal
+ * 
+ * @version $Id: Op.java 572108 2007-09-02 18:48:31Z mrglavas $
+ */
+@SuppressWarnings("all")
+class Op {
+    static final int DOT = 0;
+    static final int CHAR = 1;                  // Single character
+    static final int RANGE = 3;                 // [a-zA-Z]
+    static final int NRANGE = 4;                // [^a-zA-Z]
+    static final int ANCHOR = 5;                // ^ $ ...
+    static final int STRING = 6;                // literal String 
+    static final int CLOSURE = 7;               // X*
+    static final int NONGREEDYCLOSURE = 8;      // X*?
+    static final int QUESTION = 9;              // X?
+    static final int NONGREEDYQUESTION = 10;    // X??
+    static final int UNION = 11;                // X|Y
+    static final int CAPTURE = 15;              // ( and )
+    static final int BACKREFERENCE = 16;        // \1 \2 ...
+    static final int LOOKAHEAD = 20;            // (?=...)
+    static final int NEGATIVELOOKAHEAD = 21;    // (?!...)
+    static final int LOOKBEHIND = 22;           // (?<=...)
+    static final int NEGATIVELOOKBEHIND = 23;   // (?<!...)
+    static final int INDEPENDENT = 24;          // (?>...)
+    static final int MODIFIER = 25;             // (?ims-ims:...)
+    static final int CONDITION = 26;            // (?(..)yes|no)
+
+    static int nofinstances = 0;
+    static final boolean COUNT = false;
+
+    static Op createDot() {
+        if (Op.COUNT)  Op.nofinstances ++;
+        return new Op(Op.DOT);
+    }
+    static CharOp createChar(int data) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        return new CharOp(Op.CHAR, data);
+    }
+    static CharOp createAnchor(int data) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        return new CharOp(Op.ANCHOR, data);
+    }
+    static CharOp createCapture(int number, Op next) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        CharOp op = new CharOp(Op.CAPTURE, number);
+        op.next = next;
+        return op;
+    }
+    static UnionOp createUnion(int size) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        //System.err.println("Creates UnionOp");
+        return new UnionOp(Op.UNION, size);
+    }
+    static ChildOp createClosure(int id) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        return new ModifierOp(Op.CLOSURE, id, -1);
+    }
+    static ChildOp createNonGreedyClosure() {
+        if (Op.COUNT)  Op.nofinstances ++;
+        return new ChildOp(Op.NONGREEDYCLOSURE);
+    }
+    static ChildOp createQuestion(boolean nongreedy) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        return new ChildOp(nongreedy ? Op.NONGREEDYQUESTION : Op.QUESTION);
+    }
+    static RangeOp createRange(Token tok) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        return new RangeOp(Op.RANGE, tok);
+    }
+    static ChildOp createLook(int type, Op next, Op branch) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        ChildOp op = new ChildOp(type);
+        op.setChild(branch);
+        op.next = next;
+        return op;
+    }
+    static CharOp createBackReference(int refno) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        return new CharOp(Op.BACKREFERENCE, refno);
+    }
+    static StringOp createString(String literal) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        return new StringOp(Op.STRING, literal);
+    }
+    static ChildOp createIndependent(Op next, Op branch) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        ChildOp op = new ChildOp(Op.INDEPENDENT);
+        op.setChild(branch);
+        op.next = next;
+        return op;
+    }
+    static ModifierOp createModifier(Op next, Op branch, int add, int mask) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        ModifierOp op = new ModifierOp(Op.MODIFIER, add, mask);
+        op.setChild(branch);
+        op.next = next;
+        return op;
+    }
+    static ConditionOp createCondition(Op next, int ref, Op conditionflow, Op yesflow, Op noflow) {
+        if (Op.COUNT)  Op.nofinstances ++;
+        ConditionOp op = new ConditionOp(Op.CONDITION, ref, conditionflow, yesflow, noflow);
+        op.next = next;
+        return op;
+    }
+
+    final int type;
+    Op next = null;
+
+    protected Op(int type) {
+        this.type = type;
+    }
+
+    int size() {                                // for UNION
+        return 0;
+    }
+    Op elementAt(int index) {                   // for UNIoN
+        throw new RuntimeException("Internal Error: type="+this.type);
+    }
+    Op getChild() {                             // for CLOSURE, QUESTION
+        throw new RuntimeException("Internal Error: type="+this.type);
+    }
+                                                // ModifierOp
+    int getData() {                             // CharOp  for CHAR, BACKREFERENCE, CAPTURE, ANCHOR, 
+        throw new RuntimeException("Internal Error: type="+this.type);
+    }
+    int getData2() {                            // ModifierOp
+        throw new RuntimeException("Internal Error: type="+this.type);
+    }
+    RangeToken getToken() {                     // RANGE, NRANGE
+        throw new RuntimeException("Internal Error: type="+this.type);
+    }
+    String getString() {                        // STRING
+        throw new RuntimeException("Internal Error: type="+this.type);
+    }
+
+    // ================================================================
+    static class CharOp extends Op {
+        final int charData;
+        CharOp(int type, int data) {
+            super(type);
+            this.charData = data;
+        }
+        @Override
+        int getData() {
+            return this.charData;
+        }
+    }
+
+    // ================================================================
+    static class UnionOp extends Op {
+        final Vector branches;
+        UnionOp(int type, int size) {
+            super(type);
+            this.branches = new Vector(size);
+        }
+        void addElement(Op op) {
+            this.branches.addElement(op);
+        }
+        @Override
+        int size() {
+            return this.branches.size();
+        }
+        @Override
+        Op elementAt(int index) {
+            return (Op)this.branches.elementAt(index);
+        }
+    }
+
+    // ================================================================
+    static class ChildOp extends Op {
+        Op child;
+        ChildOp(int type) {
+            super(type);
+        }
+        void setChild(Op child) {
+            this.child = child;
+        }
+        @Override
+        Op getChild() {
+            return this.child;
+        }
+    }
+    // ================================================================
+    static class ModifierOp extends ChildOp {
+        final int v1;
+        final int v2;
+        ModifierOp(int type, int v1, int v2) {
+            super(type);
+            this.v1 = v1;
+            this.v2 = v2;
+        }
+        @Override
+        int getData() {
+            return this.v1;
+        }
+        @Override
+        int getData2() {
+            return this.v2;
+        }
+    }
+    // ================================================================
+    static class RangeOp extends Op {
+        final Token tok;
+        RangeOp(int type, Token tok) {
+            super(type);
+            this.tok = tok;
+        }
+        @Override
+        RangeToken getToken() {
+            return (RangeToken)this.tok;
+        }
+    }
+    // ================================================================
+    static class StringOp extends Op {
+        final String string;
+        StringOp(int type, String literal) {
+            super(type);
+            this.string = literal;
+        }
+        @Override
+        String getString() {
+            return this.string;
+        }
+    }
+    // ================================================================
+    static class ConditionOp extends Op {
+        final int refNumber;
+        final Op condition;
+        final Op yes;
+        final Op no;
+        ConditionOp(int type, int refno, Op conditionflow, Op yesflow, Op noflow) {
+            super(type);
+            this.refNumber = refno;
+            this.condition = conditionflow;
+            this.yes = yesflow;
+            this.no = noflow;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/ParseException.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/ParseException.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/ParseException.java
new file mode 100644
index 0000000..9b405c0
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/xpath/regex/ParseException.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ext.xerces.impl.xpath.regex;
+
+/**
+ * @xerces.internal
+ *
+ * @author TAMURA Kent &lt;kent@trl.ibm.co.jp&gt;
+ * @version $Id: ParseException.java 572108 2007-09-02 18:48:31Z mrglavas $
+ */
+public class ParseException extends RuntimeException {
+    
+    /** Serialization version. */
+    static final long serialVersionUID = -7012400318097691370L;
+    
+    final int location;
+
+    /*
+    public ParseException(String mes) {
+        this(mes, -1);
+    }
+    */
+    /**
+     *
+     */
+    public ParseException(String mes, int location) {
+        super(mes);
+        this.location = location;
+    }
+
+    /**
+     *
+     * @return -1 if location information is not available.
+     */
+    public int getLocation() {
+        return this.location;
+    }
+}


Mime
View raw message