Imported GNU Classpath 0.90
Imported GNU Classpath 0.90 * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore. * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant. * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5. * java/lang/Math.java: New override file. * java/lang/Character.java: Merged from Classpath. (start, end): Now 'int's. (canonicalName): New field. (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants. (UnicodeBlock): Added argument. (of): New overload. (forName): New method. Updated unicode blocks. (sets): Updated. * sources.am: Regenerated. * Makefile.in: Likewise. From-SVN: r111942
This commit is contained in:
parent
27079765d0
commit
8aa540d2f7
1367 changed files with 188789 additions and 22762 deletions
|
@ -0,0 +1,61 @@
|
|||
/* Annotation.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
/**
|
||||
* A schema component annotation.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class Annotation
|
||||
{
|
||||
|
||||
public final String documentation;
|
||||
|
||||
public Annotation(String documentation)
|
||||
{
|
||||
this.documentation = documentation;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return documentation;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/* AnySimpleType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Set;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
final class AnySimpleType
|
||||
extends SimpleType
|
||||
{
|
||||
|
||||
AnySimpleType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "anySimpleType"),
|
||||
ANY, /* variety */
|
||||
(Set) null, /* facets */
|
||||
0, /* fundametalFacets */
|
||||
(SimpleType) Type.ANY_TYPE, /* baseType */
|
||||
null);
|
||||
}
|
||||
|
||||
}
|
||||
|
58
libjava/classpath/gnu/xml/validation/datatype/AnyType.java
Normal file
58
libjava/classpath/gnu/xml/validation/datatype/AnyType.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
/* AnyType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
final class AnyType
|
||||
extends SimpleType
|
||||
{
|
||||
|
||||
AnyType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "anyType"),
|
||||
ANY, /* variety */
|
||||
null, /* facets */
|
||||
0, /* fundamentalFacets */
|
||||
null, /* baseType */
|
||||
null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/* AnyURIType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema anyURI type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class AnyURIType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
AnyURIType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "anyURI"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
try
|
||||
{
|
||||
new URI(value);
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
DatatypeException e2 = new DatatypeException(e.getIndex(),
|
||||
e.getReason());
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/* AtomicSimpleType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Set;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* An XML Schema atomic simple type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class AtomicSimpleType
|
||||
extends SimpleType
|
||||
{
|
||||
|
||||
public AtomicSimpleType(QName name,
|
||||
Set facets,
|
||||
int fundamentalFacets,
|
||||
SimpleType baseType,
|
||||
Annotation annotation)
|
||||
{
|
||||
super(name, ATOMIC, facets, fundamentalFacets, baseType, annotation);
|
||||
}
|
||||
|
||||
// Only for use by built-in types
|
||||
AtomicSimpleType(QName name, SimpleType baseType)
|
||||
{
|
||||
super(name, ATOMIC, null, 0, baseType, null);
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
if (baseType != null)
|
||||
baseType.checkValid(value, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/* Base64BinaryType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema base64Binary type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class Base64BinaryType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final String B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
|
||||
"abcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
static final String B16 = "AEIMQUYcgkosw048";
|
||||
static final String B04 = "AQgw";
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
Base64BinaryType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "base64Binary"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
// TODO value = collapseWhitespace(value);
|
||||
int len = value.length();
|
||||
try
|
||||
{
|
||||
for (int i = len - 1; i >= 0; )
|
||||
{
|
||||
char c4 = value.charAt(i--);
|
||||
if (c4 == ' ')
|
||||
c4 = value.charAt(i--);
|
||||
char c3 = value.charAt(i--);
|
||||
if (c3 == ' ')
|
||||
c3 = value.charAt(i--);
|
||||
char c2 = value.charAt(i--);
|
||||
if (c2 == ' ')
|
||||
c2 = value.charAt(i--);
|
||||
char c1 = value.charAt(i--);
|
||||
if (c1 == ' ')
|
||||
c1 = value.charAt(i--);
|
||||
|
||||
if (c4 == '=')
|
||||
{
|
||||
if (c3 == '=')
|
||||
{
|
||||
if (B04.indexOf(c2) != -1 &&
|
||||
B64.indexOf(c1) != -1)
|
||||
continue;
|
||||
}
|
||||
else if (B16.indexOf(c3) != -1)
|
||||
{
|
||||
if (B64.indexOf(c2) != -1 &&
|
||||
B64.indexOf(c1) != -1)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (B64.indexOf(c4) != -1)
|
||||
continue;
|
||||
throw new DatatypeException(i, "illegal BASE64");
|
||||
}
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
throw new DatatypeException("illegal BASE64");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/* BooleanType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema boolean type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class BooleanType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
static final Set VALUE_SPACE =
|
||||
new TreeSet(Arrays.asList(new String[] {"true", "false", "1", "0"}));
|
||||
|
||||
BooleanType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "boolean"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
if (!VALUE_SPACE.contains(value))
|
||||
throw new DatatypeException("invalid boolean value");
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
return ("1".equals(literal) || "true".equals(literal)) ? Boolean.TRUE :
|
||||
Boolean.FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
133
libjava/classpath/gnu/xml/validation/datatype/ByteType.java
Normal file
133
libjava/classpath/gnu/xml/validation/datatype/ByteType.java
Normal file
|
@ -0,0 +1,133 @@
|
|||
/* ByteType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema byte type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class ByteType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
static final String MAX_VALUE = "127";
|
||||
static final String MIN_VALUE = "128";
|
||||
static final int LENGTH = MAX_VALUE.length();
|
||||
|
||||
ByteType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "byte"),
|
||||
TypeLibrary.SHORT);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValue(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid byte value");
|
||||
int i = 0, off = 0;
|
||||
boolean compare = false;
|
||||
String compareTo = MAX_VALUE;
|
||||
char c = value.charAt(0);
|
||||
if (c == '+')
|
||||
i++;
|
||||
else if (c == '-')
|
||||
{
|
||||
compareTo = MIN_VALUE;
|
||||
i++;
|
||||
}
|
||||
if (len - i > LENGTH)
|
||||
throw new DatatypeException(0, "invalid byte value");
|
||||
else if (len - i == LENGTH)
|
||||
compare = true;
|
||||
for (; i < len; i++)
|
||||
{
|
||||
c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
{
|
||||
if (compare)
|
||||
{
|
||||
char d = compareTo.charAt(off);
|
||||
if (Character.digit(c, 10) > Character.digit(d, 10))
|
||||
throw new DatatypeException(i, "invalid byte value");
|
||||
}
|
||||
off++;
|
||||
continue;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid byte value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new Byte(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
335
libjava/classpath/gnu/xml/validation/datatype/DateTimeType.java
Normal file
335
libjava/classpath/gnu/xml/validation/datatype/DateTimeType.java
Normal file
|
@ -0,0 +1,335 @@
|
|||
/* DateTimeType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema dateTime type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class DateTimeType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
DateTimeType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "dateTime"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValue(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
int state = 0;
|
||||
int start = 0;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == '-' && i == 0)
|
||||
{
|
||||
start++;
|
||||
continue;
|
||||
}
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
switch (state)
|
||||
{
|
||||
case 0: // year
|
||||
if (c == '-')
|
||||
{
|
||||
String year = value.substring(start, i);
|
||||
if ("0000".equals(year) || year.length() < 4)
|
||||
throw new DatatypeException(i, "invalid dateTime value");
|
||||
state = 1;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 1: // month
|
||||
if (c == '-')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid dateTime value");
|
||||
state = 2;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 2: // day
|
||||
if (c == 'T')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid dateTime value");
|
||||
state = 3;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 3: // hour
|
||||
if (c == ':')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid dateTime value");
|
||||
state = 4;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 4: // minute
|
||||
if (c == ':')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid dateTime value");
|
||||
state = 5;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 5: // second
|
||||
if (c == '.')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid dateTime value");
|
||||
state = 6;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
else if (c == ' ')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid dateTime value");
|
||||
state = 7;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 6: // second fraction
|
||||
if (c == ' ')
|
||||
{
|
||||
state = 7;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 7: // timezone 1
|
||||
if (start == i)
|
||||
{
|
||||
if (c == '+' || c == '-')
|
||||
continue;
|
||||
else if (c == 'Z')
|
||||
{
|
||||
state = 9;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (c == ':')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid dateTime value");
|
||||
state = 8;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid dateTime value");
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 5: // second
|
||||
if (len - start != 2)
|
||||
throw new DatatypeException(len, "invalid dateTime value");
|
||||
break;
|
||||
case 6: // second fraction
|
||||
break;
|
||||
case 8: // timezone 2
|
||||
if (len - start != 2)
|
||||
throw new DatatypeException(len, "invalid dateTime value");
|
||||
break;
|
||||
case 9: // post Z
|
||||
break;
|
||||
default:
|
||||
throw new DatatypeException(len, "invalid dateTime value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String value, ValidationContext context) {
|
||||
int len = value.length();
|
||||
int state = 0;
|
||||
int start = 0;
|
||||
Calendar cal = new GregorianCalendar();
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == '-' && i == 0)
|
||||
{
|
||||
start++;
|
||||
continue;
|
||||
}
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
switch (state)
|
||||
{
|
||||
case 0: // year
|
||||
if (c == '-')
|
||||
{
|
||||
cal.set(Calendar.YEAR,
|
||||
Integer.parseInt(value.substring(0, i)));
|
||||
state = 1;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 1: // month
|
||||
if (c == '-')
|
||||
{
|
||||
cal.set(Calendar.MONTH,
|
||||
Integer.parseInt(value.substring(start, i)));
|
||||
state = 2;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 2: // day
|
||||
if (c == 'T')
|
||||
{
|
||||
cal.set(Calendar.DATE,
|
||||
Integer.parseInt(value.substring(start, i)));
|
||||
state = 3;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 3: // hour
|
||||
if (c == ':')
|
||||
{
|
||||
cal.set(Calendar.HOUR,
|
||||
Integer.parseInt(value.substring(start, i)));
|
||||
state = 4;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 4: // minute
|
||||
if (c == ':')
|
||||
{
|
||||
cal.set(Calendar.MINUTE,
|
||||
Integer.parseInt(value.substring(start, i)));
|
||||
state = 5;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 5: // second
|
||||
if (c == ' ')
|
||||
{
|
||||
float second = Float.parseFloat(value.substring(start, i));
|
||||
// TODO adjust non-integer values
|
||||
cal.set(Calendar.SECOND, (int) second);
|
||||
state = 7;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// end of input
|
||||
if (len - start > 0 && state == 7)
|
||||
{
|
||||
// Timezone
|
||||
String timezone = value.substring(len - start);
|
||||
int i = timezone.indexOf(':');
|
||||
if (i == -1)
|
||||
{
|
||||
if ("Z".equals(timezone))
|
||||
timezone = "UTC";
|
||||
TimeZone tz = TimeZone.getTimeZone(timezone);
|
||||
if (tz == null)
|
||||
return null;
|
||||
cal.set(Calendar.ZONE_OFFSET, tz.getRawOffset());
|
||||
}
|
||||
else
|
||||
{
|
||||
String tzh = timezone.substring(0, i);
|
||||
String tzm = timezone.substring(i + 1);
|
||||
int offset = Integer.parseInt(tzh) * 360000;
|
||||
if (offset < 0)
|
||||
offset -= Integer.parseInt(tzm) * 60000;
|
||||
else
|
||||
offset += Integer.parseInt(tzm) * 60000;
|
||||
cal.set(Calendar.ZONE_OFFSET, offset);
|
||||
}
|
||||
}
|
||||
return cal.getTime();
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
222
libjava/classpath/gnu/xml/validation/datatype/DateType.java
Normal file
222
libjava/classpath/gnu/xml/validation/datatype/DateType.java
Normal file
|
@ -0,0 +1,222 @@
|
|||
/* DateType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema date type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class DateType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
DateType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "date"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
int state = 0;
|
||||
int start = 0;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == '-' && i == 0)
|
||||
{
|
||||
start++;
|
||||
continue;
|
||||
}
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
switch (state)
|
||||
{
|
||||
case 0: // year
|
||||
if (c == '-')
|
||||
{
|
||||
String year = value.substring(start, i);
|
||||
if ("0000".equals(year) || year.length() < 4)
|
||||
throw new DatatypeException(i, "invalid date value");
|
||||
state = 1;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 1: // month
|
||||
if (c == '-')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid date value");
|
||||
state = 2;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid date value");
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 2: // day
|
||||
if (len - start != 2)
|
||||
throw new DatatypeException("invalid date value");
|
||||
break;
|
||||
default:
|
||||
throw new DatatypeException("invalid date value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String value, ValidationContext context) {
|
||||
int len = value.length();
|
||||
int state = 0;
|
||||
int start = 0;
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.set(Calendar.HOUR, 0);
|
||||
cal.set(Calendar.MINUTE, 0);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == '-' && i == 0)
|
||||
{
|
||||
start++;
|
||||
continue;
|
||||
}
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
switch (state)
|
||||
{
|
||||
case 0: // year
|
||||
if (c == '-')
|
||||
{
|
||||
cal.set(Calendar.YEAR,
|
||||
Integer.parseInt(value.substring(0, i)));
|
||||
state = 1;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 1: // month
|
||||
if (c == '-')
|
||||
{
|
||||
cal.set(Calendar.MONTH,
|
||||
Integer.parseInt(value.substring(start, i)));
|
||||
state = 2;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 2: // day
|
||||
if (c == 'T')
|
||||
{
|
||||
cal.set(Calendar.DATE,
|
||||
Integer.parseInt(value.substring(start, i)));
|
||||
state = 7;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// end of input
|
||||
if (len - start > 0 && state == 7)
|
||||
{
|
||||
// Timezone
|
||||
String timezone = value.substring(len - start);
|
||||
int i = timezone.indexOf(':');
|
||||
if (i == -1)
|
||||
{
|
||||
if ("Z".equals(timezone))
|
||||
timezone = "UTC";
|
||||
TimeZone tz = TimeZone.getTimeZone(timezone);
|
||||
if (tz == null)
|
||||
return null;
|
||||
cal.set(Calendar.ZONE_OFFSET, tz.getRawOffset());
|
||||
}
|
||||
else
|
||||
{
|
||||
String tzh = timezone.substring(0, i);
|
||||
String tzm = timezone.substring(i + 1);
|
||||
int offset = Integer.parseInt(tzh) * 360000;
|
||||
if (offset < 0)
|
||||
offset -= Integer.parseInt(tzm) * 60000;
|
||||
else
|
||||
offset += Integer.parseInt(tzm) * 60000;
|
||||
cal.set(Calendar.ZONE_OFFSET, offset);
|
||||
}
|
||||
}
|
||||
return cal.getTime();
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
121
libjava/classpath/gnu/xml/validation/datatype/DecimalType.java
Normal file
121
libjava/classpath/gnu/xml/validation/datatype/DecimalType.java
Normal file
|
@ -0,0 +1,121 @@
|
|||
/* DecimalType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema decimal type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class DecimalType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
DecimalType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "decimal"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException("invalid decimal value");
|
||||
boolean seenDot = false;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
else if (c == '.')
|
||||
{
|
||||
if (seenDot)
|
||||
throw new DatatypeException(i, "invalid decimal value");
|
||||
seenDot = true;
|
||||
continue;
|
||||
}
|
||||
else if (c == '+' && i == 0)
|
||||
continue;
|
||||
else if (c == '-' && i == 0)
|
||||
continue;
|
||||
else
|
||||
throw new DatatypeException(i, "invalid decimal value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new BigDecimal(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
112
libjava/classpath/gnu/xml/validation/datatype/DoubleType.java
Normal file
112
libjava/classpath/gnu/xml/validation/datatype/DoubleType.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
/* DoubleType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema double type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class DoubleType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
static final Set SPECIAL =
|
||||
new TreeSet(Arrays.asList(new String[] {"INF", "-INF", "NaN"}));
|
||||
|
||||
DoubleType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "double"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
if (SPECIAL.contains(value))
|
||||
return;
|
||||
try
|
||||
{
|
||||
Double.parseDouble(value);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
DatatypeException e2 = new DatatypeException("invalid double value");
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new Double(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
239
libjava/classpath/gnu/xml/validation/datatype/DurationType.java
Normal file
239
libjava/classpath/gnu/xml/validation/datatype/DurationType.java
Normal file
|
@ -0,0 +1,239 @@
|
|||
/* DurationType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema duration type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class DurationType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static class Duration
|
||||
implements Comparable
|
||||
{
|
||||
int years;
|
||||
int months;
|
||||
int days;
|
||||
int minutes;
|
||||
float seconds;
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
int hc = years;
|
||||
hc = hc * 31 + months;
|
||||
hc = hc * 31 + days;
|
||||
hc = hc * 31 + minutes;
|
||||
hc = hc * 31 + new Float(seconds).hashCode();
|
||||
return hc;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
if (other instanceof Duration)
|
||||
{
|
||||
Duration duration = (Duration) other;
|
||||
return duration.years ==years &&
|
||||
duration.months == months &&
|
||||
duration.days == days &&
|
||||
duration.minutes == minutes &&
|
||||
duration.seconds == seconds;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int compareTo(Object other)
|
||||
{
|
||||
if (other instanceof Duration)
|
||||
{
|
||||
Duration duration = (Duration) other;
|
||||
if (duration.years != years)
|
||||
return years - duration.years;
|
||||
if (duration.months != months)
|
||||
return months - duration.months;
|
||||
if (duration.days != days)
|
||||
return days - duration.days;
|
||||
if (duration.minutes != minutes)
|
||||
return minutes = duration.minutes;
|
||||
if (duration.seconds == seconds)
|
||||
return 0;
|
||||
return (seconds < duration.seconds) ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
DurationType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "duration"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
char expect = 'P';
|
||||
boolean seenT = false;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == '-' && expect == 'P')
|
||||
continue;
|
||||
if (c == expect)
|
||||
{
|
||||
if (c == 'P')
|
||||
expect = 'Y';
|
||||
else if (c == 'Y')
|
||||
expect = 'M';
|
||||
else if (c == 'M' && !seenT)
|
||||
expect = 'D';
|
||||
else if (c == 'D')
|
||||
expect = 'T';
|
||||
else if (c == 'T')
|
||||
{
|
||||
expect = 'H';
|
||||
seenT = true;
|
||||
}
|
||||
else if (c == 'H')
|
||||
expect = 'M';
|
||||
else if (c == 'M' && seenT)
|
||||
expect = 'S';
|
||||
else if (c == 'S')
|
||||
{
|
||||
if (i + 1 != len)
|
||||
throw new DatatypeException(i, "illegal duration value");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (c >= 0x30 && c <= 0x39 && expect != 'P' && expect != 'T')
|
||||
continue;
|
||||
throw new DatatypeException(i, "illegal duration value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String value, ValidationContext context) {
|
||||
boolean negative = false;
|
||||
int days = 0, months = 0, years = 0;
|
||||
int minutes = 0;
|
||||
float seconds = 0.0f;
|
||||
int len = value.length();
|
||||
char expect = 'P';
|
||||
boolean seenT = false;
|
||||
int start = 0;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == '-' && expect == 'P')
|
||||
{
|
||||
negative = true;
|
||||
continue;
|
||||
}
|
||||
if (c == expect)
|
||||
{
|
||||
if (c == 'P')
|
||||
expect = 'Y';
|
||||
else if (c == 'Y')
|
||||
{
|
||||
expect = 'M';
|
||||
years = Integer.parseInt(value.substring(start, i));
|
||||
}
|
||||
else if (c == 'M' && !seenT)
|
||||
expect = 'D';
|
||||
else if (c == 'D')
|
||||
expect = 'T';
|
||||
else if (c == 'T')
|
||||
{
|
||||
expect = 'H';
|
||||
seenT = true;
|
||||
}
|
||||
else if (c == 'H')
|
||||
expect = 'M';
|
||||
else if (c == 'M' && seenT)
|
||||
expect = 'S';
|
||||
else if (c == 'S')
|
||||
{
|
||||
if (i + 1 != len)
|
||||
return null;
|
||||
}
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
if (c >= 0x30 && c <= 0x39 && expect != 'P' && expect != 'T')
|
||||
continue;
|
||||
return null;
|
||||
}
|
||||
if (negative)
|
||||
{
|
||||
days = days * -1;
|
||||
minutes = minutes * -1;
|
||||
seconds = seconds * -1.0f;
|
||||
}
|
||||
Duration duration = new Duration();
|
||||
duration.days = days;
|
||||
duration.minutes = minutes;
|
||||
duration.seconds = seconds;
|
||||
return duration;
|
||||
}
|
||||
|
||||
}
|
||||
|
107
libjava/classpath/gnu/xml/validation/datatype/EntitiesType.java
Normal file
107
libjava/classpath/gnu/xml/validation/datatype/EntitiesType.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
/* EntitiesType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema ENTITIES type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class EntitiesType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
EntitiesType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "ENTITIES"),
|
||||
TypeLibrary.ENTITY);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
StringBuffer buf = new StringBuffer();
|
||||
int len = value.length();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == ' ')
|
||||
{
|
||||
String token = buf.toString();
|
||||
if (token.length() > 0)
|
||||
{
|
||||
if (!context.isUnparsedEntity(token))
|
||||
throw new DatatypeException(i, "invalid ENTITIES value");
|
||||
}
|
||||
buf.setLength(0);
|
||||
}
|
||||
else
|
||||
buf.append(c);
|
||||
}
|
||||
String token = buf.toString();
|
||||
if (token.length() == 0 || !context.isUnparsedEntity(token))
|
||||
throw new DatatypeException("invalid ENTITIES value");
|
||||
}
|
||||
|
||||
public boolean isContextDependent()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/* EntityType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema ENTITY type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class EntityType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
EntityType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "ENTITY"),
|
||||
TypeLibrary.NCNAME);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
if (value.length() == 0 || !context.isUnparsedEntity(value))
|
||||
throw new DatatypeException("invalid ENTITY value");
|
||||
}
|
||||
|
||||
public boolean isContextDependent()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/* EnumerationFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
/**
|
||||
* The <code>enumeration</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class EnumerationFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public final String value;
|
||||
|
||||
public EnumerationFacet(String value, Annotation annotation)
|
||||
{
|
||||
super(ENUMERATION, annotation);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof EnumerationFacet &&
|
||||
((EnumerationFacet) other).value.equals(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
78
libjava/classpath/gnu/xml/validation/datatype/Facet.java
Normal file
78
libjava/classpath/gnu/xml/validation/datatype/Facet.java
Normal file
|
@ -0,0 +1,78 @@
|
|||
/* Facet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
/**
|
||||
* An XML Schema constraining facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public abstract class Facet
|
||||
{
|
||||
|
||||
public static final int LENGTH = 1;
|
||||
public static final int MIN_LENGTH = 2;
|
||||
public static final int MAX_LENGTH = 3;
|
||||
public static final int PATTERN = 4;
|
||||
public static final int ENUMERATION = 5;
|
||||
public static final int WHITESPACE = 6;
|
||||
public static final int MAX_INCLUSIVE = 7;
|
||||
public static final int MAX_EXCLUSIVE = 8;
|
||||
public static final int MIN_EXCLUSIVE = 9;
|
||||
public static final int MIN_INCLUSIVE = 10;
|
||||
public static final int TOTAL_DIGITS = 11;
|
||||
public static final int FRACTION_DIGITS = 12;
|
||||
|
||||
/**
|
||||
* The type of this facet.
|
||||
*/
|
||||
public final int type;
|
||||
|
||||
/**
|
||||
* Optional annotation.
|
||||
*/
|
||||
public Annotation annotation;
|
||||
|
||||
protected Facet(int type, Annotation annotation)
|
||||
{
|
||||
this.type = type;
|
||||
this.annotation = annotation;
|
||||
}
|
||||
|
||||
}
|
||||
|
112
libjava/classpath/gnu/xml/validation/datatype/FloatType.java
Normal file
112
libjava/classpath/gnu/xml/validation/datatype/FloatType.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
/* FloatType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema float type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class FloatType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
static final Set SPECIAL =
|
||||
new TreeSet(Arrays.asList(new String[] {"INF", "-INF", "NaN"}));
|
||||
|
||||
FloatType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "float"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
if (SPECIAL.contains(value))
|
||||
return;
|
||||
try
|
||||
{
|
||||
Float.parseFloat(value);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
DatatypeException e2 = new DatatypeException("invalid float value");
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new Float(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/* FractionDigitsFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
/**
|
||||
* The <code>fractionDigits</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class FractionDigitsFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public final int value;
|
||||
|
||||
public final boolean fixed;
|
||||
|
||||
public FractionDigitsFacet(int value, boolean fixed, Annotation annotation)
|
||||
{
|
||||
super(FRACTION_DIGITS, annotation);
|
||||
this.value = value;
|
||||
this.fixed = fixed;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof FractionDigitsFacet &&
|
||||
((FractionDigitsFacet) other).value == value);
|
||||
}
|
||||
|
||||
}
|
||||
|
175
libjava/classpath/gnu/xml/validation/datatype/GDayType.java
Normal file
175
libjava/classpath/gnu/xml/validation/datatype/GDayType.java
Normal file
|
@ -0,0 +1,175 @@
|
|||
/* GDayType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema gDay type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class GDayType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static class GDay
|
||||
implements Comparable
|
||||
{
|
||||
|
||||
int day;
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return day;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
if (other instanceof GDay)
|
||||
return ((GDay) other).day == day;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int compareTo(Object other)
|
||||
{
|
||||
if (other instanceof GDay)
|
||||
{
|
||||
GDay gd = (GDay) other;
|
||||
if (gd.day == day)
|
||||
return 0;
|
||||
return (day < gd.day) ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
GDayType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gDay"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
int state = 0;
|
||||
int start = 0;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
switch (state)
|
||||
{
|
||||
case 0: // year
|
||||
if (c == '-')
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
continue;
|
||||
case 1:
|
||||
state = 1;
|
||||
start = i + 1;
|
||||
continue;
|
||||
default:
|
||||
throw new DatatypeException(i, "invalid GDay value");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1: // month
|
||||
if (c == '-')
|
||||
{
|
||||
if (i - start != 0)
|
||||
throw new DatatypeException(i, "invalid GDay value");
|
||||
state = 2;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid GDay value");
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 2: // day
|
||||
if (len - start != 2)
|
||||
throw new DatatypeException("invalid GDay value");
|
||||
break;
|
||||
default:
|
||||
throw new DatatypeException("invalid GDay value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
GDay ret = new GDay();
|
||||
ret.day = Integer.parseInt(literal.substring(3));
|
||||
return ret;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
184
libjava/classpath/gnu/xml/validation/datatype/GMonthDayType.java
Normal file
184
libjava/classpath/gnu/xml/validation/datatype/GMonthDayType.java
Normal file
|
@ -0,0 +1,184 @@
|
|||
/* GMonthDayType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema gMonthDay type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class GMonthDayType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static class GMonthDay
|
||||
implements Comparable
|
||||
{
|
||||
|
||||
int month;
|
||||
int day;
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return month * 31 + day;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
if (other instanceof GMonthDay)
|
||||
{
|
||||
GMonthDay gmd = (GMonthDay) other;
|
||||
return gmd.month == month && gmd.day == day;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int compareTo(Object other)
|
||||
{
|
||||
if (other instanceof GMonthDay)
|
||||
{
|
||||
GMonthDay gmd = (GMonthDay) other;
|
||||
if (gmd.month == month)
|
||||
{
|
||||
if (gmd.day == day)
|
||||
return 0;
|
||||
return (day < gmd.day) ? -1 : 1;
|
||||
}
|
||||
return (month < gmd.month) ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
GMonthDayType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gMonthDay"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
int state = 0;
|
||||
int start = 0;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
switch (state)
|
||||
{
|
||||
case 0: // year
|
||||
if (c == '-')
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
continue;
|
||||
case 1:
|
||||
state = 1;
|
||||
start = i + 1;
|
||||
continue;
|
||||
default:
|
||||
throw new DatatypeException(i, "illegal GMonthDay type");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1: // month
|
||||
if (c == '-')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "illegal GMonthDay type");
|
||||
state = 2;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw new DatatypeException(i, "illegal GMonthDay type");
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 2: // day
|
||||
if (len - start != 2)
|
||||
throw new DatatypeException("illegal GMonthDay type");
|
||||
break;
|
||||
default:
|
||||
throw new DatatypeException("illegal GMonthDay type");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
GMonthDay ret = new GMonthDay();
|
||||
ret.month = Integer.parseInt(literal.substring(2, 5));
|
||||
ret.day = Integer.parseInt(literal.substring(6));
|
||||
return ret;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
164
libjava/classpath/gnu/xml/validation/datatype/GMonthType.java
Normal file
164
libjava/classpath/gnu/xml/validation/datatype/GMonthType.java
Normal file
|
@ -0,0 +1,164 @@
|
|||
/* GMonthType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema gMonth type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class GMonthType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static class GMonth
|
||||
implements Comparable
|
||||
{
|
||||
|
||||
int month;
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return month;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
if (other instanceof GMonth)
|
||||
return ((GMonth) other).month == month;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int compareTo(Object other)
|
||||
{
|
||||
if (other instanceof GMonth)
|
||||
{
|
||||
GMonth gm = (GMonth) other;
|
||||
if (gm.month == month)
|
||||
return 0;
|
||||
return (month < gm.month) ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
GMonthType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gMonth"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
int len = value.length();
|
||||
int state = 0;
|
||||
int start = 0;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
switch (state)
|
||||
{
|
||||
case 0: // year
|
||||
if (c == '-')
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
continue;
|
||||
case 1:
|
||||
state = 1;
|
||||
start = i + 1;
|
||||
continue;
|
||||
default:
|
||||
throw new DatatypeException(i, "illegal GMonth value");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw new DatatypeException(i, "illegal GMonth value");
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 1: // month
|
||||
if (len - start != 2)
|
||||
throw new DatatypeException("illegal GMonth value");
|
||||
break;
|
||||
default:
|
||||
throw new DatatypeException("illegal GMonth value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
GMonth ret = new GMonth();
|
||||
ret.month = Integer.parseInt(literal.substring(2));
|
||||
return ret;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
/* GYearMonthType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema gYearMonth type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class GYearMonthType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static class GYearMonth
|
||||
implements Comparable
|
||||
{
|
||||
|
||||
int year;
|
||||
int month;
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return year * 31 + month;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
if (other instanceof GYearMonth)
|
||||
{
|
||||
GYearMonth gmy = (GYearMonth) other;
|
||||
return gmy.year == year && gmy.month == month;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int compareTo(Object other)
|
||||
{
|
||||
if (other instanceof GYearMonth)
|
||||
{
|
||||
GYearMonth gmy = (GYearMonth) other;
|
||||
if (gmy.year == year)
|
||||
{
|
||||
if (gmy.month == month)
|
||||
return 0;
|
||||
return (month < gmy.month) ? -1 : 1;
|
||||
}
|
||||
return (year < gmy.year) ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
GYearMonthType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gYearMonth"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
int state = 0;
|
||||
int start = 0;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == '-' && i == 0)
|
||||
{
|
||||
start++;
|
||||
continue;
|
||||
}
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
switch (state)
|
||||
{
|
||||
case 0: // year
|
||||
if (c == '-')
|
||||
{
|
||||
String year = value.substring(start, i);
|
||||
if (year.length() < 4 || Integer.parseInt(year) == 0)
|
||||
throw new DatatypeException(i, "illegal GYear value");
|
||||
state = 1;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw new DatatypeException(i, "illegal GYear value");
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 1: // month
|
||||
if (len - start != 2)
|
||||
throw new DatatypeException("illegal GYear value");
|
||||
break;
|
||||
default:
|
||||
throw new DatatypeException("illegal GYear value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
int offset = 5;
|
||||
if (literal.charAt(0) == '-')
|
||||
offset++;
|
||||
GYearMonth ret = new GYearMonth();
|
||||
ret.year = Integer.parseInt(literal.substring(0, offset));
|
||||
ret.month = Integer.parseInt(literal.substring(offset + 1));
|
||||
return ret;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
152
libjava/classpath/gnu/xml/validation/datatype/GYearType.java
Normal file
152
libjava/classpath/gnu/xml/validation/datatype/GYearType.java
Normal file
|
@ -0,0 +1,152 @@
|
|||
/* GYearType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema gYear type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class GYearType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static class GYear
|
||||
implements Comparable
|
||||
{
|
||||
|
||||
int year;
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return year;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
if (other instanceof GYear)
|
||||
return ((GYear) other).year == year;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int compareTo(Object other)
|
||||
{
|
||||
if (other instanceof GYear)
|
||||
{
|
||||
GYear gy = (GYear) other;
|
||||
if (gy.year == year)
|
||||
return 0;
|
||||
return (year < gy.year) ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
GYearType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gYear"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
int state = 0;
|
||||
int start = 0;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == '-' && i == 0)
|
||||
{
|
||||
start++;
|
||||
continue;
|
||||
}
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
throw new DatatypeException(i, "invalid GYear value");
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 0: // year
|
||||
String year = value.substring(start, len);
|
||||
if (year.length() < 4 || Integer.parseInt(year) == 0)
|
||||
throw new DatatypeException("invalid GYear value");
|
||||
break;
|
||||
default:
|
||||
throw new DatatypeException("invalid GYear value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
GYear ret = new GYear();
|
||||
ret.year = Integer.parseInt(literal);
|
||||
return ret;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/* HexBinaryType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema hexBinary type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class HexBinaryType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final String HEX = "0123456789ABCDEF";
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
HexBinaryType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "hexBinary"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (HEX.indexOf(c) == -1)
|
||||
throw new DatatypeException(i, "invalid hexBinary value");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
87
libjava/classpath/gnu/xml/validation/datatype/IDRefType.java
Normal file
87
libjava/classpath/gnu/xml/validation/datatype/IDRefType.java
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* IDRefType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema IDREF type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class IDRefType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
IDRefType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "IDREF"),
|
||||
TypeLibrary.NCNAME);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
// TODO
|
||||
}
|
||||
|
||||
public int getIdType()
|
||||
{
|
||||
return ID_TYPE_IDREF;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/* IDRefsType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema IDREFS type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class IDRefsType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
IDRefsType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "IDREFS"),
|
||||
TypeLibrary.IDREF);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
// TODO
|
||||
}
|
||||
|
||||
public int getIdType()
|
||||
{
|
||||
return ID_TYPE_IDREFS;
|
||||
}
|
||||
|
||||
}
|
||||
|
87
libjava/classpath/gnu/xml/validation/datatype/IDType.java
Normal file
87
libjava/classpath/gnu/xml/validation/datatype/IDType.java
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* IDType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema ID type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class IDType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
IDType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "ID"),
|
||||
TypeLibrary.NCNAME);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
// TODO
|
||||
}
|
||||
|
||||
public int getIdType()
|
||||
{
|
||||
return ID_TYPE_ID;
|
||||
}
|
||||
|
||||
}
|
||||
|
133
libjava/classpath/gnu/xml/validation/datatype/IntType.java
Normal file
133
libjava/classpath/gnu/xml/validation/datatype/IntType.java
Normal file
|
@ -0,0 +1,133 @@
|
|||
/* IntType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema int type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class IntType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
static final String MAX_VALUE = "2147483647";
|
||||
static final String MIN_VALUE = "2147483648";
|
||||
static final int LENGTH = MAX_VALUE.length();
|
||||
|
||||
IntType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "int"),
|
||||
TypeLibrary.LONG);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid int value");
|
||||
int i = 0, off = 0;
|
||||
boolean compare = false;
|
||||
String compareTo = MAX_VALUE;
|
||||
char c = value.charAt(0);
|
||||
if (c == '+')
|
||||
i++;
|
||||
else if (c == '-')
|
||||
{
|
||||
compareTo = MIN_VALUE;
|
||||
i++;
|
||||
}
|
||||
if (len - i > LENGTH)
|
||||
throw new DatatypeException("invalid int value");
|
||||
else if (len - i == LENGTH)
|
||||
compare = true;
|
||||
for (; i < len; i++)
|
||||
{
|
||||
c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
{
|
||||
if (compare)
|
||||
{
|
||||
char d = compareTo.charAt(off);
|
||||
if (Character.digit(c, 10) > Character.digit(d, 10))
|
||||
throw new DatatypeException(i, "invalid int value");
|
||||
}
|
||||
off++;
|
||||
continue;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid int value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new Integer(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
110
libjava/classpath/gnu/xml/validation/datatype/IntegerType.java
Normal file
110
libjava/classpath/gnu/xml/validation/datatype/IntegerType.java
Normal file
|
@ -0,0 +1,110 @@
|
|||
/* IntegerType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema integer type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class IntegerType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
IntegerType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "integer"),
|
||||
TypeLibrary.DECIMAL);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid integer value");
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
else if (c == '+' && i == 0)
|
||||
continue;
|
||||
else if (c == '-' && i == 0)
|
||||
continue;
|
||||
throw new DatatypeException(i, "invalid integer value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new BigInteger(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/* LanguageType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema language type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class LanguageType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
static final Pattern PATTERN =
|
||||
Pattern.compile("[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*");
|
||||
|
||||
LanguageType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "language"),
|
||||
TypeLibrary.TOKEN);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
if (!PATTERN.matcher(value).matches())
|
||||
throw new DatatypeException("invalid language value");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/* LengthFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
/**
|
||||
* The <code>length</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class LengthFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public final int value;
|
||||
|
||||
public final boolean fixed;
|
||||
|
||||
public LengthFacet(int value, boolean fixed, Annotation annotation)
|
||||
{
|
||||
super(LENGTH, annotation);
|
||||
this.value = value;
|
||||
this.fixed = fixed;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof LengthFacet &&
|
||||
((LengthFacet) other).value == value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/* ListSimpleType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* An XML Schema list simple type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class ListSimpleType
|
||||
extends SimpleType
|
||||
{
|
||||
|
||||
/**
|
||||
* The type of the items in this list (atomic or union).
|
||||
*/
|
||||
public final SimpleType itemType;
|
||||
|
||||
public ListSimpleType(QName name, Set facets,
|
||||
int fundamentalFacets, SimpleType baseType,
|
||||
Annotation annotation, SimpleType itemType)
|
||||
{
|
||||
super(name, LIST, facets, fundamentalFacets, baseType, annotation);
|
||||
this.itemType = itemType;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
StringTokenizer st = new StringTokenizer(value, " ");
|
||||
if (!st.hasMoreTokens())
|
||||
throw new DatatypeException("invalid list value");
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
String token = st.nextToken();
|
||||
itemType.checkValid(token, context);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
133
libjava/classpath/gnu/xml/validation/datatype/LongType.java
Normal file
133
libjava/classpath/gnu/xml/validation/datatype/LongType.java
Normal file
|
@ -0,0 +1,133 @@
|
|||
/* LongType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema long type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class LongType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
static final String MAX_VALUE = "9223372036854775807";
|
||||
static final String MIN_VALUE = "9223372036854775808";
|
||||
static final int LENGTH = MAX_VALUE.length();
|
||||
|
||||
LongType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "long"),
|
||||
TypeLibrary.INTEGER);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid long value");
|
||||
int i = 0, off = 0;
|
||||
boolean compare = false;
|
||||
String compareTo = MAX_VALUE;
|
||||
char c = value.charAt(0);
|
||||
if (c == '+')
|
||||
i++;
|
||||
else if (c == '-')
|
||||
{
|
||||
compareTo = MIN_VALUE;
|
||||
i++;
|
||||
}
|
||||
if (len - i > LENGTH)
|
||||
throw new DatatypeException(i, "invalid long value");
|
||||
else if (len - i == LENGTH)
|
||||
compare = true;
|
||||
for (; i < len; i++)
|
||||
{
|
||||
c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
{
|
||||
if (compare)
|
||||
{
|
||||
char d = compareTo.charAt(off);
|
||||
if (Character.digit(c, 10) > Character.digit(d, 10))
|
||||
throw new DatatypeException(i, "invalid long value");
|
||||
}
|
||||
off++;
|
||||
continue;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid long value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new Long(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/* MaxExclusiveFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* The <code>maxExclusive</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class MaxExclusiveFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public final Object value; // date or number
|
||||
|
||||
public final boolean fixed;
|
||||
|
||||
public MaxExclusiveFacet(Object value, boolean fixed, Annotation annotation)
|
||||
{
|
||||
super(MAX_EXCLUSIVE, annotation);
|
||||
this.value = value;
|
||||
this.fixed = fixed;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof MaxExclusiveFacet &&
|
||||
((MaxExclusiveFacet) other).value.equals(value));
|
||||
}
|
||||
|
||||
boolean matches(Object test)
|
||||
{
|
||||
if (value instanceof Date)
|
||||
{
|
||||
Date dvalue = (Date) value;
|
||||
if (!(test instanceof Date))
|
||||
return false;
|
||||
return ((Date) test).before(dvalue);
|
||||
}
|
||||
else if (value instanceof BigInteger)
|
||||
{
|
||||
BigInteger ivalue = (BigInteger) value;
|
||||
if (!(test instanceof BigInteger))
|
||||
return false;
|
||||
return ((BigInteger) test).compareTo(ivalue) < 0;
|
||||
}
|
||||
else if (value instanceof BigDecimal)
|
||||
{
|
||||
BigDecimal dvalue = (BigDecimal) value;
|
||||
if (!(test instanceof BigDecimal))
|
||||
return false;
|
||||
return ((BigDecimal) test).compareTo(dvalue) < 0;
|
||||
}
|
||||
else if (value instanceof Comparable)
|
||||
{
|
||||
if (!(test.getClass().equals(value.getClass())))
|
||||
return false;
|
||||
return ((Comparable) test).compareTo(value) < 0;
|
||||
}
|
||||
Number nvalue = (Number) value;
|
||||
if (!(test instanceof Number))
|
||||
return false;
|
||||
return ((Number) test).doubleValue() < nvalue.doubleValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
/* MaxInclusiveFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* The <code>maxInclusive</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class MaxInclusiveFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public final Object value;
|
||||
|
||||
public final boolean fixed;
|
||||
|
||||
public MaxInclusiveFacet(Object value, boolean fixed, Annotation annotation)
|
||||
{
|
||||
super(MAX_INCLUSIVE, annotation);
|
||||
this.value = value;
|
||||
this.fixed = fixed;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof MaxInclusiveFacet &&
|
||||
((MaxInclusiveFacet) other).value.equals(value));
|
||||
}
|
||||
|
||||
boolean matches(Object test)
|
||||
{
|
||||
if (value instanceof Date)
|
||||
{
|
||||
Date dvalue = (Date) value;
|
||||
if (!(test instanceof Date))
|
||||
return false;
|
||||
Date dtest = (Date) test;
|
||||
return dtest.equals(dvalue) || dtest.before(dvalue);
|
||||
}
|
||||
else if (value instanceof BigInteger)
|
||||
{
|
||||
BigInteger ivalue = (BigInteger) value;
|
||||
if (!(test instanceof BigInteger))
|
||||
return false;
|
||||
return ((BigInteger) test).compareTo(ivalue) <= 0;
|
||||
}
|
||||
else if (value instanceof BigDecimal)
|
||||
{
|
||||
BigDecimal dvalue = (BigDecimal) value;
|
||||
if (!(test instanceof BigDecimal))
|
||||
return false;
|
||||
return ((BigDecimal) test).compareTo(dvalue) <= 0;
|
||||
}
|
||||
else if (value instanceof Comparable)
|
||||
{
|
||||
if (!(test.getClass().equals(value.getClass())))
|
||||
return false;
|
||||
return ((Comparable) test).compareTo(value) <= 0;
|
||||
}
|
||||
Number nvalue = (Number) value;
|
||||
if (!(test instanceof Number))
|
||||
return false;
|
||||
return ((Number) test).doubleValue() <= nvalue.doubleValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/* MaxLengthFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
/**
|
||||
* The <code>maxLength</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class MaxLengthFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public final int value;
|
||||
|
||||
public final boolean fixed;
|
||||
|
||||
public MaxLengthFacet(int value, boolean fixed, Annotation annotation)
|
||||
{
|
||||
super(MAX_LENGTH, annotation);
|
||||
this.value = value;
|
||||
this.fixed = fixed;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof MaxLengthFacet &&
|
||||
((MaxLengthFacet) other).value == value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/* MinExclusiveFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* The <code>minExclusive</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class MinExclusiveFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public final Object value;
|
||||
|
||||
public final boolean fixed;
|
||||
|
||||
public MinExclusiveFacet(Object value, boolean fixed, Annotation annotation)
|
||||
{
|
||||
super(MIN_EXCLUSIVE, annotation);
|
||||
this.value = value;
|
||||
this.fixed = fixed;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof MinExclusiveFacet &&
|
||||
((MinExclusiveFacet) other).value.equals(value));
|
||||
}
|
||||
|
||||
boolean matches(Object test)
|
||||
{
|
||||
if (value instanceof Date)
|
||||
{
|
||||
Date dvalue = (Date) value;
|
||||
if (!(test instanceof Date))
|
||||
return false;
|
||||
return ((Date) test).after(dvalue);
|
||||
}
|
||||
else if (value instanceof BigInteger)
|
||||
{
|
||||
BigInteger ivalue = (BigInteger) value;
|
||||
if (!(test instanceof BigInteger))
|
||||
return false;
|
||||
return ((BigInteger) test).compareTo(ivalue) > 0;
|
||||
}
|
||||
else if (value instanceof BigDecimal)
|
||||
{
|
||||
BigDecimal dvalue = (BigDecimal) value;
|
||||
if (!(test instanceof BigDecimal))
|
||||
return false;
|
||||
return ((BigDecimal) test).compareTo(dvalue) > 0;
|
||||
}
|
||||
else if (value instanceof Comparable)
|
||||
{
|
||||
if (!(test.getClass().equals(value.getClass())))
|
||||
return false;
|
||||
return ((Comparable) test).compareTo(value) > 0;
|
||||
}
|
||||
Number nvalue = (Number) value;
|
||||
if (!(test instanceof Number))
|
||||
return false;
|
||||
return ((Number) test).doubleValue() > nvalue.doubleValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
/* MinInclusiveFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* The <code>minInclusive</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class MinInclusiveFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public final Object value;
|
||||
|
||||
public final boolean fixed;
|
||||
|
||||
public MinInclusiveFacet(Object value, boolean fixed, Annotation annotation)
|
||||
{
|
||||
super(MIN_INCLUSIVE, annotation);
|
||||
this.value = value;
|
||||
this.fixed = fixed;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof MinInclusiveFacet &&
|
||||
((MinInclusiveFacet) other).value.equals(value));
|
||||
}
|
||||
|
||||
boolean matches(Object test)
|
||||
{
|
||||
if (value instanceof Date)
|
||||
{
|
||||
Date dvalue = (Date) value;
|
||||
if (!(test instanceof Date))
|
||||
return false;
|
||||
Date dtest = (Date) test;
|
||||
return dtest.equals(dvalue) || dtest.after(dvalue);
|
||||
}
|
||||
else if (value instanceof BigInteger)
|
||||
{
|
||||
BigInteger ivalue = (BigInteger) value;
|
||||
if (!(test instanceof BigInteger))
|
||||
return false;
|
||||
return ((BigInteger) test).compareTo(ivalue) >= 0;
|
||||
}
|
||||
else if (value instanceof BigDecimal)
|
||||
{
|
||||
BigDecimal dvalue = (BigDecimal) value;
|
||||
if (!(test instanceof BigDecimal))
|
||||
return false;
|
||||
return ((BigDecimal) test).compareTo(dvalue) >= 0;
|
||||
}
|
||||
else if (value instanceof Comparable)
|
||||
{
|
||||
if (!(test.getClass().equals(value.getClass())))
|
||||
return false;
|
||||
return ((Comparable) test).compareTo(value) >= 0;
|
||||
}
|
||||
Number nvalue = (Number) value;
|
||||
if (!(test instanceof Number))
|
||||
return false;
|
||||
return ((Number) test).doubleValue() >= nvalue.doubleValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/* MinLengthFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
/**
|
||||
* The <code>minLength</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class MinLengthFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public final int value;
|
||||
|
||||
public final boolean fixed;
|
||||
|
||||
public MinLengthFacet(int value, boolean fixed, Annotation annotation)
|
||||
{
|
||||
super(MIN_LENGTH, annotation);
|
||||
this.value = value;
|
||||
this.fixed = fixed;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof MinLengthFacet &&
|
||||
((MinLengthFacet) other).value == value);
|
||||
}
|
||||
|
||||
}
|
||||
|
111
libjava/classpath/gnu/xml/validation/datatype/NCNameType.java
Normal file
111
libjava/classpath/gnu/xml/validation/datatype/NCNameType.java
Normal file
|
@ -0,0 +1,111 @@
|
|||
/* NCNameType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
import gnu.xml.stream.UnicodeReader;
|
||||
import gnu.xml.stream.XMLParser;
|
||||
|
||||
/**
|
||||
* The XML Schema NCName type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class NCNameType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
NCNameType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "NCName"),
|
||||
TypeLibrary.NAME);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
try
|
||||
{
|
||||
int[] cp = UnicodeReader.toCodePointArray(value);
|
||||
if (cp.length == 0)
|
||||
throw new DatatypeException("invalid NCName value");
|
||||
// XXX XML 1.1 documents?
|
||||
if (cp[0] == ':' || !XMLParser.isNameStartCharacter(cp[0], false))
|
||||
throw new DatatypeException(0, "invalid NCName value");
|
||||
boolean seenColon = false;
|
||||
for (int i = 1; i < cp.length; i++)
|
||||
{
|
||||
if (cp[i] == ':')
|
||||
{
|
||||
if (seenColon || (i + 1 == cp.length))
|
||||
throw new DatatypeException(i, "invalid NCName value");
|
||||
seenColon = true;
|
||||
}
|
||||
else if (!XMLParser.isNameCharacter(cp[i], false))
|
||||
throw new DatatypeException(i, "invalid NCName value");
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
DatatypeException e2 = new DatatypeException("invalid NCName value");
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
102
libjava/classpath/gnu/xml/validation/datatype/NMTokenType.java
Normal file
102
libjava/classpath/gnu/xml/validation/datatype/NMTokenType.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
/* NMTokenType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
import gnu.xml.stream.UnicodeReader;
|
||||
import gnu.xml.stream.XMLParser;
|
||||
|
||||
/**
|
||||
* The XML Schema NMTOKEN type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class NMTokenType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
NMTokenType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "NMTOKEN"),
|
||||
TypeLibrary.TOKEN);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
try
|
||||
{
|
||||
int[] cp = UnicodeReader.toCodePointArray(value);
|
||||
if (cp.length == 0)
|
||||
throw new DatatypeException("invalid NMTOKEN value");
|
||||
for (int i = 0; i < cp.length; i++)
|
||||
{
|
||||
// XXX XML 1.1 documents?
|
||||
if (!XMLParser.isNameCharacter(cp[i], false))
|
||||
throw new DatatypeException(i, "invalid NMTOKEN value");
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
DatatypeException e2 = new DatatypeException("invalid NMTOKEN value");
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
124
libjava/classpath/gnu/xml/validation/datatype/NMTokensType.java
Normal file
124
libjava/classpath/gnu/xml/validation/datatype/NMTokensType.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
/* NMTokensType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
import gnu.xml.stream.UnicodeReader;
|
||||
import gnu.xml.stream.XMLParser;
|
||||
|
||||
/**
|
||||
* The XML Schema NMTOKENS type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class NMTokensType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
NMTokensType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "NMTOKENS"),
|
||||
TypeLibrary.NMTOKEN);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == ' ')
|
||||
{
|
||||
String token = buf.toString();
|
||||
if (token.length() > 0)
|
||||
checkNmtoken(token, i);
|
||||
buf.setLength(0);
|
||||
}
|
||||
else
|
||||
buf.append(c);
|
||||
}
|
||||
checkNmtoken(buf.toString(), len);
|
||||
}
|
||||
|
||||
private void checkNmtoken(String text, int i)
|
||||
throws DatatypeException
|
||||
{
|
||||
try
|
||||
{
|
||||
int[] cp = UnicodeReader.toCodePointArray(text);
|
||||
if (cp.length == 0)
|
||||
throw new DatatypeException("invalid NMTOKEN value");
|
||||
for (int j = 0; j < cp.length; j++)
|
||||
{
|
||||
// XXX XML 1.1 documents?
|
||||
if (!XMLParser.isNameCharacter(cp[j], false))
|
||||
throw new DatatypeException(i, "invalid NMTOKEN value");
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
DatatypeException e2 = new DatatypeException("invalid NMTOKEN value");
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
104
libjava/classpath/gnu/xml/validation/datatype/NameType.java
Normal file
104
libjava/classpath/gnu/xml/validation/datatype/NameType.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
/* NameType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
import gnu.xml.stream.UnicodeReader;
|
||||
import gnu.xml.stream.XMLParser;
|
||||
|
||||
/**
|
||||
* The XML Schema Name type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class NameType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
NameType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "Name"),
|
||||
TypeLibrary.TOKEN);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
try
|
||||
{
|
||||
int[] cp = UnicodeReader.toCodePointArray(value);
|
||||
if (cp.length == 0)
|
||||
throw new DatatypeException("invalid Name value");
|
||||
// XXX XML 1.1 documents?
|
||||
if (!XMLParser.isNameStartCharacter(cp[0], false))
|
||||
throw new DatatypeException(0, "invalid Name value");
|
||||
for (int i = 1; i < cp.length; i++)
|
||||
{
|
||||
if (!XMLParser.isNameCharacter(cp[i], false))
|
||||
throw new DatatypeException(i, "invalid Name value");
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
DatatypeException e2 = new DatatypeException("invalid Name value");
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/* NegativeIntegerType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema negativeInteger type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class NegativeIntegerType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
NegativeIntegerType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "negativeInteger"),
|
||||
TypeLibrary.NON_POSITIVE_INTEGER);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValue(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid negative integer value");
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == '-')
|
||||
{
|
||||
if (i == 0)
|
||||
continue;
|
||||
}
|
||||
else if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
throw new DatatypeException(i, "invalid negative integer value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new BigInteger(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/* NonNegativeIntegerType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema nonNegativeInteger type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class NonNegativeIntegerType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
NonNegativeIntegerType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "nonNegativeInteger"),
|
||||
TypeLibrary.INTEGER);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid non-negative integer value");
|
||||
boolean negative = false;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == 0x30)
|
||||
continue;
|
||||
else if (c >= 0x31 && c <= 0x39)
|
||||
{
|
||||
if (negative)
|
||||
throw new DatatypeException(i,
|
||||
"invalid non-negative integer value");
|
||||
continue;
|
||||
}
|
||||
else if (c == '+' && i == 0)
|
||||
continue;
|
||||
else if (c == '-' && i == 0)
|
||||
{
|
||||
negative = true;
|
||||
continue;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid non-negative integer value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new BigInteger(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/* NonPositiveIntegerType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema nonPositiveInteger type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class NonPositiveIntegerType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
NonPositiveIntegerType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "nonPositiveInteger"),
|
||||
TypeLibrary.INTEGER);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid non-positive integer value");
|
||||
boolean positive = true;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == 0x30)
|
||||
continue;
|
||||
else if (c >= 0x31 && c <= 0x39)
|
||||
{
|
||||
if (positive)
|
||||
throw new DatatypeException(i,
|
||||
"invalid non-positive integer value");
|
||||
continue;
|
||||
}
|
||||
else if (c == '+' && i == 0)
|
||||
continue;
|
||||
else if (c == '-' && i == 0)
|
||||
{
|
||||
positive = false;
|
||||
continue;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid non-positive integer value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new BigInteger(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/* NormalizedStringType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema normalizedString type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class NormalizedStringType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
NormalizedStringType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "normalizedString"),
|
||||
TypeLibrary.STRING);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == 0x0a || c == 0x0d || c == 0x09)
|
||||
throw new DatatypeException(i, "invalid normalized-string value");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/* NotationType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema NOTATION type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class NotationType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
NotationType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "NOTATION"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
if (!context.isNotation(value))
|
||||
throw new DatatypeException("invalid NOTATION value");
|
||||
}
|
||||
|
||||
public boolean isContextDependent()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/* PatternFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* The <code>pattern</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class PatternFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public final Pattern value;
|
||||
|
||||
public PatternFacet(Pattern value, Annotation annotation)
|
||||
{
|
||||
super(PATTERN, annotation);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof PatternFacet &&
|
||||
((PatternFacet) other).value.equals(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/* PositiveIntegerType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema positiveInteger type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class PositiveIntegerType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
PositiveIntegerType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "positiveInteger"),
|
||||
TypeLibrary.NON_NEGATIVE_INTEGER);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid positive integer value");
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == '+')
|
||||
{
|
||||
if (i == 0)
|
||||
continue;
|
||||
}
|
||||
else if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
throw new DatatypeException(i, "invalid positive integer value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new BigInteger(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
122
libjava/classpath/gnu/xml/validation/datatype/QNameType.java
Normal file
122
libjava/classpath/gnu/xml/validation/datatype/QNameType.java
Normal file
|
@ -0,0 +1,122 @@
|
|||
/* QNameType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
import gnu.xml.stream.UnicodeReader;
|
||||
import gnu.xml.stream.XMLParser;
|
||||
|
||||
/**
|
||||
* The XML Schema QName type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class QNameType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
QNameType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "QName"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int ci = -1;
|
||||
try
|
||||
{
|
||||
int[] cp = UnicodeReader.toCodePointArray(value);
|
||||
if (cp.length == 0)
|
||||
throw new DatatypeException("invalid NCName value");
|
||||
// XXX XML 1.1 documents?
|
||||
if (cp[0] == ':' || !XMLParser.isNameStartCharacter(cp[0], false))
|
||||
throw new DatatypeException(0, "invalid NCName value");
|
||||
for (int i = 1; i < cp.length; i++)
|
||||
{
|
||||
if (cp[i] == ':')
|
||||
{
|
||||
if (ci != -1 || (i + 1 == cp.length))
|
||||
throw new DatatypeException(i, "invalid NCName value");
|
||||
ci = i;
|
||||
}
|
||||
else if (!XMLParser.isNameCharacter(cp[i], false))
|
||||
throw new DatatypeException(i, "invalid NCName value");
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
DatatypeException e2 = new DatatypeException("invalid NCName value");
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
if (ci != -1)
|
||||
{
|
||||
String prefix = value.substring(0, ci);
|
||||
if (context.resolveNamespacePrefix(prefix) == null)
|
||||
throw new DatatypeException("invalid namespace prefix");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isContextDependent()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
133
libjava/classpath/gnu/xml/validation/datatype/ShortType.java
Normal file
133
libjava/classpath/gnu/xml/validation/datatype/ShortType.java
Normal file
|
@ -0,0 +1,133 @@
|
|||
/* ShortType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema short type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class ShortType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
static final String MAX_VALUE = "32767";
|
||||
static final String MIN_VALUE = "32768";
|
||||
static final int LENGTH = MAX_VALUE.length();
|
||||
|
||||
ShortType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "short"),
|
||||
TypeLibrary.INT);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid short value");
|
||||
int i = 0, off = 0;
|
||||
boolean compare = false;
|
||||
String compareTo = MAX_VALUE;
|
||||
char c = value.charAt(0);
|
||||
if (c == '+')
|
||||
i++;
|
||||
else if (c == '-')
|
||||
{
|
||||
compareTo = MIN_VALUE;
|
||||
i++;
|
||||
}
|
||||
if (len - i > LENGTH)
|
||||
throw new DatatypeException(i, "invalid short value");
|
||||
else if (len - i == LENGTH)
|
||||
compare = true;
|
||||
for (; i < len; i++)
|
||||
{
|
||||
c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
{
|
||||
if (compare)
|
||||
{
|
||||
char d = compareTo.charAt(off);
|
||||
if (Character.digit(c, 10) > Character.digit(d, 10))
|
||||
throw new DatatypeException(i, "invalid short value");
|
||||
}
|
||||
off++;
|
||||
continue;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid short value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new Short(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
257
libjava/classpath/gnu/xml/validation/datatype/SimpleType.java
Normal file
257
libjava/classpath/gnu/xml/validation/datatype/SimpleType.java
Normal file
|
@ -0,0 +1,257 @@
|
|||
/* SimpleType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.Datatype;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.DatatypeStreamingValidator;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* An XML Schema simple type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class SimpleType
|
||||
extends Type
|
||||
implements Datatype
|
||||
{
|
||||
|
||||
/**
|
||||
* The variety of the <code>anySimpleType</code> datatype.
|
||||
*/
|
||||
public static final int ANY = 0;
|
||||
|
||||
/**
|
||||
* The atomic variety.
|
||||
*/
|
||||
public static final int ATOMIC = 1;
|
||||
|
||||
/**
|
||||
* The list variety.
|
||||
*/
|
||||
public static final int LIST = 2;
|
||||
|
||||
/**
|
||||
* The union variety.
|
||||
*/
|
||||
public static final int UNION = 3;
|
||||
|
||||
public static final int ID_TYPE_NULL = 0;
|
||||
public static final int ID_TYPE_ID = 1;
|
||||
public static final int ID_TYPE_IDREF = 2;
|
||||
public static final int ID_TYPE_IDREFS = 3;
|
||||
|
||||
/**
|
||||
* The variety of this simple type.
|
||||
*/
|
||||
public final int variety;
|
||||
|
||||
/**
|
||||
* The facets of this simple type.
|
||||
*/
|
||||
public Set facets;
|
||||
|
||||
/**
|
||||
* The fundamental facets of this simple type.
|
||||
*/
|
||||
public int fundamentalFacets;
|
||||
|
||||
/**
|
||||
* If this datatype has been derived by restriction, then the component
|
||||
* from which it was derived.
|
||||
*/
|
||||
public final SimpleType baseType;
|
||||
|
||||
/**
|
||||
* Optional annotation.
|
||||
*/
|
||||
public final Annotation annotation;
|
||||
|
||||
public SimpleType(QName name, int variety, Set facets,
|
||||
int fundamentalFacets, SimpleType baseType,
|
||||
Annotation annotation)
|
||||
{
|
||||
super(name);
|
||||
this.variety = variety;
|
||||
this.facets = facets;
|
||||
this.fundamentalFacets = fundamentalFacets;
|
||||
this.baseType = baseType;
|
||||
this.annotation = annotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this type permits the specified value.
|
||||
*/
|
||||
public boolean isValid(String value, ValidationContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
checkValid(value, context);
|
||||
return true;
|
||||
}
|
||||
catch (DatatypeException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
if (facets != null && !facets.isEmpty())
|
||||
{
|
||||
Object parsedValue = createValue(value, context);
|
||||
for (Iterator i = facets.iterator(); i.hasNext(); )
|
||||
{
|
||||
Facet facet = (Facet) i.next();
|
||||
switch (facet.type)
|
||||
{
|
||||
case Facet.LENGTH:
|
||||
LengthFacet lf = (LengthFacet) facet;
|
||||
if (value.length() != lf.value)
|
||||
throw new DatatypeException("invalid length");
|
||||
break;
|
||||
case Facet.MIN_LENGTH:
|
||||
MinLengthFacet nlf = (MinLengthFacet) facet;
|
||||
if (value.length() < nlf.value)
|
||||
throw new DatatypeException("invalid minimum length");
|
||||
break;
|
||||
case Facet.MAX_LENGTH:
|
||||
MaxLengthFacet xlf = (MaxLengthFacet) facet;
|
||||
if (value.length() > xlf.value)
|
||||
throw new DatatypeException("invalid maximum length");
|
||||
break;
|
||||
case Facet.PATTERN:
|
||||
PatternFacet pf = (PatternFacet) facet;
|
||||
Matcher matcher = pf.value.matcher(value);
|
||||
if (!matcher.find())
|
||||
throw new DatatypeException("invalid match for pattern");
|
||||
break;
|
||||
case Facet.ENUMERATION:
|
||||
// TODO
|
||||
break;
|
||||
case Facet.WHITESPACE:
|
||||
// TODO
|
||||
break;
|
||||
case Facet.MAX_INCLUSIVE:
|
||||
MaxInclusiveFacet xif = (MaxInclusiveFacet) facet;
|
||||
if (!xif.matches(parsedValue))
|
||||
throw new DatatypeException("beyond upper bound");
|
||||
break;
|
||||
case Facet.MAX_EXCLUSIVE:
|
||||
MaxExclusiveFacet xef = (MaxExclusiveFacet) facet;
|
||||
if (!xef.matches(parsedValue))
|
||||
throw new DatatypeException("beyond upper bound");
|
||||
break;
|
||||
case Facet.MIN_EXCLUSIVE:
|
||||
MinExclusiveFacet nef = (MinExclusiveFacet) facet;
|
||||
if (!nef.matches(parsedValue))
|
||||
throw new DatatypeException("beyond lower bound");
|
||||
break;
|
||||
case Facet.MIN_INCLUSIVE:
|
||||
MinInclusiveFacet nif = (MinInclusiveFacet) facet;
|
||||
if (!nif.matches(parsedValue))
|
||||
throw new DatatypeException("beyond lower bound");
|
||||
break;
|
||||
case Facet.TOTAL_DIGITS:
|
||||
TotalDigitsFacet tdf = (TotalDigitsFacet) facet;
|
||||
if (countDigits(value, true) > tdf.value)
|
||||
throw new DatatypeException("too many digits");
|
||||
break;
|
||||
case Facet.FRACTION_DIGITS:
|
||||
FractionDigitsFacet fdf = (FractionDigitsFacet) facet;
|
||||
if (countDigits(value, false) > fdf.value)
|
||||
throw new DatatypeException("too many fraction digits");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int countDigits(String value, boolean any)
|
||||
{
|
||||
int count = 0;
|
||||
int len = value.length();
|
||||
boolean seenDecimal = false;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == 0x2e)
|
||||
seenDecimal = true;
|
||||
else if (c >= 0x30 && c <= 0x39 && (any || seenDecimal))
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
// TODO createStreamingValidator
|
||||
public DatatypeStreamingValidator createStreamingValidator(ValidationContext context)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
return literal;
|
||||
}
|
||||
|
||||
public boolean sameValue(Object value1, Object value2) {
|
||||
return value1.equals(value2);
|
||||
}
|
||||
|
||||
public int valueHashCode(Object value) {
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
public int getIdType()
|
||||
{
|
||||
return ID_TYPE_NULL;
|
||||
}
|
||||
|
||||
public boolean isContextDependent()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/* StringType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema string type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class StringType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
StringType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "string"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
}
|
||||
|
303
libjava/classpath/gnu/xml/validation/datatype/TimeType.java
Normal file
303
libjava/classpath/gnu/xml/validation/datatype/TimeType.java
Normal file
|
@ -0,0 +1,303 @@
|
|||
/* TimeType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.TimeZone;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema time type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class TimeType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static class Time
|
||||
implements Comparable
|
||||
{
|
||||
int minutes;
|
||||
float seconds;
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return minutes * 31 + new Float(seconds).hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
if (other instanceof Time)
|
||||
{
|
||||
Time time = (Time) other;
|
||||
return time.minutes == minutes && time.seconds == seconds;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int compareTo(Object other)
|
||||
{
|
||||
if (other instanceof Time)
|
||||
{
|
||||
Time time = (Time) other;
|
||||
if (time.minutes != minutes)
|
||||
return minutes - time.minutes;
|
||||
if (time.seconds == seconds)
|
||||
return 0;
|
||||
return (seconds < time.seconds) ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
TimeType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "time"),
|
||||
TypeLibrary.ANY_SIMPLE_TYPE);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
int state = 3;
|
||||
int start = 0;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == '-' && state == 0)
|
||||
{
|
||||
start++;
|
||||
continue;
|
||||
}
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
switch (state)
|
||||
{
|
||||
case 3: // hour
|
||||
if (c == ':')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid time value");
|
||||
state = 4;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 4: // minute
|
||||
if (c == ':')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid time value");
|
||||
state = 5;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 5: // second
|
||||
if (c == '.')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid time value");
|
||||
state = 6;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
else if (c == ' ')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid time value");
|
||||
state = 7;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 6: // second fraction
|
||||
if (c == ' ')
|
||||
{
|
||||
state = 7;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 7: // timezone 1
|
||||
if (start == i)
|
||||
{
|
||||
if (c == '+' || c == '-')
|
||||
continue;
|
||||
else if (c == 'Z')
|
||||
{
|
||||
state = 9;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (c == ':')
|
||||
{
|
||||
if (i - start != 2)
|
||||
throw new DatatypeException(i, "invalid time value");
|
||||
state = 8;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid time value");
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 5: // second
|
||||
if (len - start != 2)
|
||||
throw new DatatypeException(len, "invalid time value");
|
||||
break;
|
||||
case 6: // second fraction
|
||||
break;
|
||||
case 8: // timezone 2
|
||||
if (len - start != 2)
|
||||
throw new DatatypeException(len, "invalid time value");
|
||||
break;
|
||||
case 9: // post Z
|
||||
break;
|
||||
default:
|
||||
throw new DatatypeException(len, "invalid time value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String value, ValidationContext context) {
|
||||
int len = value.length();
|
||||
int state = 3;
|
||||
int start = 0;
|
||||
Time time = new Time();
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
continue;
|
||||
switch (state)
|
||||
{
|
||||
case 3: // hour
|
||||
if (c == ':')
|
||||
{
|
||||
time.minutes =
|
||||
Integer.parseInt(value.substring(start, i)) * 60;
|
||||
state = 4;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 4: // minute
|
||||
if (c == ':')
|
||||
{
|
||||
time.minutes +=
|
||||
Integer.parseInt(value.substring(start, i));
|
||||
state = 5;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 5: // second
|
||||
if (c == ' ')
|
||||
{
|
||||
time.seconds =
|
||||
Float.parseFloat(value.substring(start, i));
|
||||
state = 7;
|
||||
start = i + 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// end of input
|
||||
if (len - start > 0 && state == 7)
|
||||
{
|
||||
// Timezone
|
||||
String timezone = value.substring(len - start);
|
||||
int i = timezone.indexOf(':');
|
||||
if (i == -1)
|
||||
{
|
||||
if ("Z".equals(timezone))
|
||||
timezone = "UTC";
|
||||
TimeZone tz = TimeZone.getTimeZone(timezone);
|
||||
if (tz == null)
|
||||
return null;
|
||||
time.minutes += tz.getRawOffset();
|
||||
}
|
||||
else
|
||||
{
|
||||
String tzh = timezone.substring(0, i);
|
||||
String tzm = timezone.substring(i + 1);
|
||||
int offset = Integer.parseInt(tzh) * 60;
|
||||
if (offset < 0)
|
||||
offset -= Integer.parseInt(tzm);
|
||||
else
|
||||
offset += Integer.parseInt(tzm);
|
||||
time.minutes += offset;
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
96
libjava/classpath/gnu/xml/validation/datatype/TokenType.java
Normal file
96
libjava/classpath/gnu/xml/validation/datatype/TokenType.java
Normal file
|
@ -0,0 +1,96 @@
|
|||
/* TokenType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema token type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class TokenType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.LENGTH,
|
||||
Facet.MIN_LENGTH,
|
||||
Facet.MAX_LENGTH,
|
||||
Facet.PATTERN,
|
||||
Facet.ENUMERATION,
|
||||
Facet.WHITESPACE
|
||||
};
|
||||
|
||||
TokenType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "token"),
|
||||
TypeLibrary.NORMALIZED_STRING);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid token value");
|
||||
if (value.charAt(0) == ' ' || value.charAt(len - 1) == ' ')
|
||||
throw new DatatypeException(0, "invalid token value");
|
||||
char last = '\u0000';
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c == 0x0a || c == 0x0d || c == 0x09)
|
||||
throw new DatatypeException(i, "invalid token value");
|
||||
if (c == ' ' && last == ' ')
|
||||
throw new DatatypeException(i, "invalid token value");
|
||||
last = c;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/* TotalDigitsFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
/**
|
||||
* The <code>totalDigits</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class TotalDigitsFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public final int value;
|
||||
|
||||
public final boolean fixed;
|
||||
|
||||
public TotalDigitsFacet(int value, boolean fixed, Annotation annotation)
|
||||
{
|
||||
super(TOTAL_DIGITS, annotation);
|
||||
this.value = value;
|
||||
this.fixed = fixed;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof TotalDigitsFacet &&
|
||||
((TotalDigitsFacet) other).value == value);
|
||||
}
|
||||
|
||||
}
|
||||
|
65
libjava/classpath/gnu/xml/validation/datatype/Type.java
Normal file
65
libjava/classpath/gnu/xml/validation/datatype/Type.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* Type.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.xml.namespace.QName;
|
||||
/**
|
||||
* Abstract base class for XML Schema datatypes.
|
||||
* @see http://www.w3.org/TR/xmlschema-2/
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public abstract class Type
|
||||
{
|
||||
|
||||
public static final Type ANY_TYPE = new AnyType();
|
||||
|
||||
/**
|
||||
* The name of this type.
|
||||
*/
|
||||
public final QName name;
|
||||
|
||||
public Type(QName name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
279
libjava/classpath/gnu/xml/validation/datatype/TypeBuilder.java
Normal file
279
libjava/classpath/gnu/xml/validation/datatype/TypeBuilder.java
Normal file
|
@ -0,0 +1,279 @@
|
|||
/* TypeBuilder.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.Datatype;
|
||||
import org.relaxng.datatype.DatatypeBuilder;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* Datatype builder.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class TypeBuilder
|
||||
implements DatatypeBuilder
|
||||
{
|
||||
|
||||
final SimpleType type;
|
||||
|
||||
TypeBuilder(SimpleType type)
|
||||
{
|
||||
this.type = type;
|
||||
// TODO fundamental facets
|
||||
type.facets = new LinkedHashSet();
|
||||
}
|
||||
|
||||
public void addParameter(String name, String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
// TODO fundamental facets
|
||||
if ("length".equals(name))
|
||||
type.facets.add(parseLengthFacet(value));
|
||||
else if ("minLength".equals(name))
|
||||
type.facets.add(parseMinLengthFacet(value));
|
||||
else if ("maxLength".equals(name))
|
||||
type.facets.add(parseMaxLengthFacet(value));
|
||||
else if ("pattern".equals(name))
|
||||
type.facets.add(parsePatternFacet(value));
|
||||
else if ("enumeration".equals(name))
|
||||
type.facets.add(parseEnumerationFacet(value));
|
||||
else if ("whiteSpace".equals(name))
|
||||
type.facets.add(parseWhiteSpaceFacet(value));
|
||||
else if ("maxInclusive".equals(name))
|
||||
type.facets.add(parseMaxInclusiveFacet(value, context));
|
||||
else if ("maxExclusive".equals(name))
|
||||
type.facets.add(parseMaxExclusiveFacet(value, context));
|
||||
else if ("minExclusive".equals(name))
|
||||
type.facets.add(parseMinExclusiveFacet(value, context));
|
||||
else if ("minInclusive".equals(name))
|
||||
type.facets.add(parseMinInclusiveFacet(value, context));
|
||||
else if ("totalDigits".equals(name))
|
||||
type.facets.add(parseTotalDigitsFacet(value));
|
||||
else if ("fractionDigits".equals(name))
|
||||
type.facets.add(parseFractionDigitsFacet(value));
|
||||
}
|
||||
|
||||
LengthFacet parseLengthFacet(String value)
|
||||
throws DatatypeException
|
||||
{
|
||||
int si = value.indexOf(' ');
|
||||
boolean fixed = false;
|
||||
if (si != -1)
|
||||
{
|
||||
if (!"FIXED".equalsIgnoreCase(value.substring(si + 1)))
|
||||
throw new DatatypeException("second argument must be FIXED if present");
|
||||
fixed = true;
|
||||
value = value.substring(0, si);
|
||||
}
|
||||
return new LengthFacet(Integer.parseInt(value), fixed, null);
|
||||
}
|
||||
|
||||
MinLengthFacet parseMinLengthFacet(String value)
|
||||
throws DatatypeException
|
||||
{
|
||||
int si = value.indexOf(' ');
|
||||
boolean fixed = false;
|
||||
if (si != -1)
|
||||
{
|
||||
if (!"FIXED".equalsIgnoreCase(value.substring(si + 1)))
|
||||
throw new DatatypeException("second argument must be FIXED if present");
|
||||
fixed = true;
|
||||
value = value.substring(0, si);
|
||||
}
|
||||
return new MinLengthFacet(Integer.parseInt(value), fixed, null);
|
||||
}
|
||||
|
||||
MaxLengthFacet parseMaxLengthFacet(String value)
|
||||
throws DatatypeException
|
||||
{
|
||||
int si = value.indexOf(' ');
|
||||
boolean fixed = false;
|
||||
if (si != -1)
|
||||
{
|
||||
if (!"FIXED".equalsIgnoreCase(value.substring(si + 1)))
|
||||
throw new DatatypeException("second argument must be FIXED if present");
|
||||
fixed = true;
|
||||
value = value.substring(0, si);
|
||||
}
|
||||
return new MaxLengthFacet(Integer.parseInt(value), fixed, null);
|
||||
}
|
||||
|
||||
PatternFacet parsePatternFacet(String value)
|
||||
throws DatatypeException
|
||||
{
|
||||
return new PatternFacet(Pattern.compile(value), null);
|
||||
}
|
||||
|
||||
EnumerationFacet parseEnumerationFacet(String value)
|
||||
throws DatatypeException
|
||||
{
|
||||
return new EnumerationFacet(value, null);
|
||||
}
|
||||
|
||||
WhiteSpaceFacet parseWhiteSpaceFacet(String value)
|
||||
throws DatatypeException
|
||||
{
|
||||
int si = value.indexOf(' ');
|
||||
boolean fixed = false;
|
||||
if (si != -1)
|
||||
{
|
||||
if (!"FIXED".equalsIgnoreCase(value.substring(si + 1)))
|
||||
throw new DatatypeException("second argument must be FIXED if present");
|
||||
fixed = true;
|
||||
value = value.substring(0, si);
|
||||
}
|
||||
if ("preserve".equals(value))
|
||||
return new WhiteSpaceFacet(WhiteSpaceFacet.PRESERVE, fixed, null);
|
||||
if ("replace".equals(value))
|
||||
return new WhiteSpaceFacet(WhiteSpaceFacet.REPLACE, fixed, null);
|
||||
if ("collapse".equals(value))
|
||||
return new WhiteSpaceFacet(WhiteSpaceFacet.COLLAPSE, fixed, null);
|
||||
throw new DatatypeException("argument must be preserve, replace, or collapse");
|
||||
}
|
||||
|
||||
MaxInclusiveFacet parseMaxInclusiveFacet(String value,
|
||||
ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
int si = value.indexOf(' ');
|
||||
boolean fixed = false;
|
||||
if (si != -1)
|
||||
{
|
||||
if (!"FIXED".equalsIgnoreCase(value.substring(si + 1)))
|
||||
throw new DatatypeException("second argument must be FIXED if present");
|
||||
fixed = true;
|
||||
value = value.substring(0, si);
|
||||
}
|
||||
return new MaxInclusiveFacet(type.createValue(value, context), fixed, null);
|
||||
}
|
||||
|
||||
MaxExclusiveFacet parseMaxExclusiveFacet(String value,
|
||||
ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
int si = value.indexOf(' ');
|
||||
boolean fixed = false;
|
||||
if (si != -1)
|
||||
{
|
||||
if (!"FIXED".equalsIgnoreCase(value.substring(si + 1)))
|
||||
throw new DatatypeException("second argument must be FIXED if present");
|
||||
fixed = true;
|
||||
value = value.substring(0, si);
|
||||
}
|
||||
return new MaxExclusiveFacet(type.createValue(value, context), fixed, null);
|
||||
}
|
||||
|
||||
MinExclusiveFacet parseMinExclusiveFacet(String value,
|
||||
ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
int si = value.indexOf(' ');
|
||||
boolean fixed = false;
|
||||
if (si != -1)
|
||||
{
|
||||
if (!"FIXED".equalsIgnoreCase(value.substring(si + 1)))
|
||||
throw new DatatypeException("second argument must be FIXED if present");
|
||||
fixed = true;
|
||||
value = value.substring(0, si);
|
||||
}
|
||||
return new MinExclusiveFacet(type.createValue(value, context), fixed, null);
|
||||
}
|
||||
|
||||
MinInclusiveFacet parseMinInclusiveFacet(String value,
|
||||
ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
int si = value.indexOf(' ');
|
||||
boolean fixed = false;
|
||||
if (si != -1)
|
||||
{
|
||||
if (!"FIXED".equalsIgnoreCase(value.substring(si + 1)))
|
||||
throw new DatatypeException("second argument must be FIXED if present");
|
||||
fixed = true;
|
||||
value = value.substring(0, si);
|
||||
}
|
||||
return new MinInclusiveFacet(type.createValue(value, context), fixed, null);
|
||||
}
|
||||
|
||||
TotalDigitsFacet parseTotalDigitsFacet(String value)
|
||||
throws DatatypeException
|
||||
{
|
||||
int si = value.indexOf(' ');
|
||||
boolean fixed = false;
|
||||
if (si != -1)
|
||||
{
|
||||
if (!"FIXED".equalsIgnoreCase(value.substring(si + 1)))
|
||||
throw new DatatypeException("second argument must be FIXED if present");
|
||||
fixed = true;
|
||||
value = value.substring(0, si);
|
||||
}
|
||||
int val = Integer.parseInt(value);
|
||||
if (val < 0)
|
||||
throw new DatatypeException("value must be a positiveInteger");
|
||||
return new TotalDigitsFacet(val, fixed, null);
|
||||
}
|
||||
|
||||
FractionDigitsFacet parseFractionDigitsFacet(String value)
|
||||
throws DatatypeException
|
||||
{
|
||||
int si = value.indexOf(' ');
|
||||
boolean fixed = false;
|
||||
if (si != -1)
|
||||
{
|
||||
if (!"FIXED".equalsIgnoreCase(value.substring(si + 1)))
|
||||
throw new DatatypeException("second argument must be FIXED if present");
|
||||
fixed = true;
|
||||
value = value.substring(0, si);
|
||||
}
|
||||
int val = Integer.parseInt(value);
|
||||
if (val < 0)
|
||||
throw new DatatypeException("value must be a positiveInteger");
|
||||
return new FractionDigitsFacet(val, fixed, null);
|
||||
}
|
||||
|
||||
public Datatype createDatatype()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
173
libjava/classpath/gnu/xml/validation/datatype/TypeLibrary.java
Normal file
173
libjava/classpath/gnu/xml/validation/datatype/TypeLibrary.java
Normal file
|
@ -0,0 +1,173 @@
|
|||
/* TypeLibrary.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.relaxng.datatype.Datatype;
|
||||
import org.relaxng.datatype.DatatypeBuilder;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.DatatypeLibrary;
|
||||
|
||||
/**
|
||||
* Datatype library for XML Schema datatypes.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class TypeLibrary
|
||||
implements DatatypeLibrary
|
||||
{
|
||||
|
||||
public static final SimpleType ANY_SIMPLE_TYPE = new AnySimpleType();
|
||||
|
||||
public static final SimpleType STRING = new StringType();
|
||||
public static final SimpleType BOOLEAN = new BooleanType();
|
||||
public static final SimpleType DECIMAL = new DecimalType();
|
||||
public static final SimpleType FLOAT = new FloatType();
|
||||
public static final SimpleType DOUBLE = new DoubleType();
|
||||
public static final SimpleType DURATION = new DurationType();
|
||||
public static final SimpleType DATE_TIME = new DateTimeType();
|
||||
public static final SimpleType TIME = new TimeType();
|
||||
public static final SimpleType DATE = new DateType();
|
||||
public static final SimpleType G_YEAR_MONTH = new GYearMonthType();
|
||||
public static final SimpleType G_YEAR = new GYearType();
|
||||
public static final SimpleType G_MONTH_DAY = new GMonthDayType();
|
||||
public static final SimpleType G_DAY = new GDayType();
|
||||
public static final SimpleType G_MONTH = new GMonthType();
|
||||
public static final SimpleType HEX_BINARY = new HexBinaryType();
|
||||
public static final SimpleType BASE64_BINARY = new Base64BinaryType();
|
||||
public static final SimpleType ANY_URI = new AnyURIType();
|
||||
public static final SimpleType QNAME = new QNameType();
|
||||
public static final SimpleType NOTATION = new NotationType();
|
||||
|
||||
public static final SimpleType NORMALIZED_STRING = new NormalizedStringType();
|
||||
public static final SimpleType TOKEN = new TokenType();
|
||||
public static final SimpleType LANGUAGE = new LanguageType();
|
||||
public static final SimpleType NMTOKEN = new NMTokenType();
|
||||
public static final SimpleType NMTOKENS = new NMTokensType();
|
||||
public static final SimpleType NAME = new NameType();
|
||||
public static final SimpleType NCNAME = new NCNameType();
|
||||
public static final SimpleType ID = new IDType();
|
||||
public static final SimpleType IDREF = new IDRefType();
|
||||
public static final SimpleType IDREFS = new IDRefsType();
|
||||
public static final SimpleType ENTITY = new EntityType();
|
||||
public static final SimpleType ENTITIES = new EntitiesType();
|
||||
public static final SimpleType INTEGER = new IntegerType();
|
||||
public static final SimpleType NON_POSITIVE_INTEGER = new NonPositiveIntegerType();
|
||||
public static final SimpleType NEGATIVE_INTEGER = new NegativeIntegerType();
|
||||
public static final SimpleType LONG = new LongType();
|
||||
public static final SimpleType INT = new IntType();
|
||||
public static final SimpleType SHORT = new ShortType();
|
||||
public static final SimpleType BYTE = new ByteType();
|
||||
public static final SimpleType NON_NEGATIVE_INTEGER = new NonNegativeIntegerType();
|
||||
public static final SimpleType UNSIGNED_LONG = new UnsignedLongType();
|
||||
public static final SimpleType UNSIGNED_INT = new UnsignedIntType();
|
||||
public static final SimpleType UNSIGNED_SHORT = new UnsignedShortType();
|
||||
public static final SimpleType UNSIGNED_BYTE = new UnsignedByteType();
|
||||
public static final SimpleType POSITIVE_INTEGER = new PositiveIntegerType();
|
||||
|
||||
private static Map byName;
|
||||
static
|
||||
{
|
||||
byName = new HashMap();
|
||||
byName.put("anySimpleType", ANY_SIMPLE_TYPE);
|
||||
byName.put("string", STRING);
|
||||
byName.put("boolean", BOOLEAN);
|
||||
byName.put("decimal", DECIMAL);
|
||||
byName.put("float", FLOAT);
|
||||
byName.put("double", DOUBLE);
|
||||
byName.put("duration", DURATION);
|
||||
byName.put("dateTime", DATE_TIME);
|
||||
byName.put("time", TIME);
|
||||
byName.put("date", DATE);
|
||||
byName.put("gYearMonth", G_YEAR_MONTH);
|
||||
byName.put("gYear", G_YEAR);
|
||||
byName.put("gMonthDay", G_MONTH_DAY);
|
||||
byName.put("gDay", G_DAY);
|
||||
byName.put("gMonth",G_MONTH);
|
||||
byName.put("hexBinary", HEX_BINARY);
|
||||
byName.put("base64Binary", BASE64_BINARY);
|
||||
byName.put("anyURI", ANY_URI);
|
||||
byName.put("QName", QNAME);
|
||||
byName.put("NOTATION", NOTATION);
|
||||
byName.put("normalizedString", NORMALIZED_STRING);
|
||||
byName.put("token", TOKEN);
|
||||
byName.put("language", LANGUAGE);
|
||||
byName.put("NMTOKEN", NMTOKEN);
|
||||
byName.put("NMTOKENS", NMTOKENS);
|
||||
byName.put("Name", NAME);
|
||||
byName.put("NCName", NCNAME);
|
||||
byName.put("ID", ID);
|
||||
byName.put("IDREF", IDREF);
|
||||
byName.put("IDREFS", IDREFS);
|
||||
byName.put("ENTITY", ENTITY);
|
||||
byName.put("ENTITIES", ENTITIES);
|
||||
byName.put("integer", INTEGER);
|
||||
byName.put("nonPositiveInteger", NON_POSITIVE_INTEGER);
|
||||
byName.put("negativeInteger", NEGATIVE_INTEGER);
|
||||
byName.put("long", LONG);
|
||||
byName.put("int", INT);
|
||||
byName.put("short", SHORT);
|
||||
byName.put("byte", BYTE);
|
||||
byName.put("nonNegativeInteger", NON_NEGATIVE_INTEGER);
|
||||
byName.put("unsignedLong", UNSIGNED_LONG);
|
||||
byName.put("unsignedInt", UNSIGNED_INT);
|
||||
byName.put("unsignedShort", UNSIGNED_SHORT);
|
||||
byName.put("unsignedByte", UNSIGNED_BYTE);
|
||||
byName.put("positiveInteger", POSITIVE_INTEGER);
|
||||
}
|
||||
|
||||
public DatatypeBuilder createDatatypeBuilder(String baseTypeLocalName)
|
||||
throws DatatypeException
|
||||
{
|
||||
SimpleType type = (SimpleType) byName.get(baseTypeLocalName);
|
||||
if (type == null)
|
||||
throw new DatatypeException("Unknown type name: " + baseTypeLocalName);
|
||||
return new TypeBuilder(type);
|
||||
}
|
||||
|
||||
public Datatype createDatatype(String typeLocalName)
|
||||
throws DatatypeException
|
||||
{
|
||||
SimpleType type = (SimpleType) byName.get(typeLocalName);
|
||||
if (type == null)
|
||||
throw new DatatypeException("Unknown type name: " + typeLocalName);
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* TypeLibraryFactory.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import org.relaxng.datatype.DatatypeLibrary;
|
||||
import org.relaxng.datatype.DatatypeLibraryFactory;
|
||||
|
||||
/**
|
||||
* Datatype library factory for XML Schema datatypes.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class TypeLibraryFactory
|
||||
implements DatatypeLibraryFactory
|
||||
{
|
||||
|
||||
public DatatypeLibrary createDatatypeLibrary(String namespaceURI)
|
||||
{
|
||||
if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(namespaceURI))
|
||||
return new TypeLibrary();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/* UnionSimpleType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* An XML Schema union simple type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class UnionSimpleType
|
||||
extends SimpleType
|
||||
{
|
||||
|
||||
/**
|
||||
* The member types in this union.
|
||||
*/
|
||||
public final List memberTypes;
|
||||
|
||||
public UnionSimpleType(QName name, Set facets,
|
||||
int fundamentalFacets, SimpleType baseType,
|
||||
Annotation annotation, List memberTypes)
|
||||
{
|
||||
super(name, UNION, facets, fundamentalFacets, baseType, annotation);
|
||||
this.memberTypes = memberTypes;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
for (Iterator i = memberTypes.iterator(); i.hasNext(); )
|
||||
{
|
||||
SimpleType type = (SimpleType) i.next();
|
||||
if (type.isValid(value, context))
|
||||
return;
|
||||
}
|
||||
throw new DatatypeException("invalid union type value");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/* UnsignedByteType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema unsignedByte type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class UnsignedByteType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
static final String MAX_VALUE = "255";
|
||||
static final int LENGTH = MAX_VALUE.length();
|
||||
|
||||
UnsignedByteType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "unsignedByte"),
|
||||
TypeLibrary.UNSIGNED_SHORT);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid unsigned byte value");
|
||||
boolean compare = false;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (len - i > LENGTH)
|
||||
throw new DatatypeException(i, "invalid unsigned byte value");
|
||||
else if (len - i == LENGTH)
|
||||
compare = true;
|
||||
char c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
{
|
||||
if (compare)
|
||||
{
|
||||
char d = MAX_VALUE.charAt(i);
|
||||
if (Character.digit(c, 10) > Character.digit(d, 10))
|
||||
throw new DatatypeException(i, "invalid unsigned byte value");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid unsigned byte value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new Byte(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/* UnsignedIntType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema unsignedInt type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class UnsignedIntType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
static final String MAX_VALUE = "4294967295";
|
||||
static final int LENGTH = MAX_VALUE.length();
|
||||
|
||||
UnsignedIntType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "unsignedInt"),
|
||||
TypeLibrary.UNSIGNED_LONG);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid unsigned int value");
|
||||
boolean compare = false;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (len - i > LENGTH)
|
||||
throw new DatatypeException(i, "invalid unsigned int value");
|
||||
else if (len - i == LENGTH)
|
||||
compare = true;
|
||||
char c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
{
|
||||
if (compare)
|
||||
{
|
||||
char d = MAX_VALUE.charAt(i);
|
||||
if (Character.digit(c, 10) > Character.digit(d, 10))
|
||||
throw new DatatypeException(i, "invalid unsigned int value");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid unsigned int value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new Integer(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/* UnsignedLongType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema unsignedLong type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class UnsignedLongType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
static final String MAX_VALUE = "18446744073709551615";
|
||||
static final int LENGTH = MAX_VALUE.length();
|
||||
|
||||
UnsignedLongType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "unsignedLong"),
|
||||
TypeLibrary.NON_NEGATIVE_INTEGER);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid unsigned long value");
|
||||
boolean compare = false;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (len - i > LENGTH)
|
||||
throw new DatatypeException(i, "invalid unsigned long value");
|
||||
else if (len - i == LENGTH)
|
||||
compare = true;
|
||||
char c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
{
|
||||
if (compare)
|
||||
{
|
||||
char d = MAX_VALUE.charAt(i);
|
||||
if (Character.digit(c, 10) > Character.digit(d, 10))
|
||||
throw new DatatypeException(i, "invalid unsigned long value");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid unsigned long value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new Long(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
/* UnsignedShortType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.relaxng.datatype.DatatypeException;
|
||||
import org.relaxng.datatype.ValidationContext;
|
||||
|
||||
/**
|
||||
* The XML Schema unsignedShort type.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class UnsignedShortType
|
||||
extends AtomicSimpleType
|
||||
{
|
||||
|
||||
static final int[] CONSTRAINING_FACETS = {
|
||||
Facet.TOTAL_DIGITS,
|
||||
Facet.FRACTION_DIGITS,
|
||||
Facet.PATTERN,
|
||||
Facet.WHITESPACE,
|
||||
Facet.ENUMERATION,
|
||||
Facet.MAX_INCLUSIVE,
|
||||
Facet.MAX_EXCLUSIVE,
|
||||
Facet.MIN_INCLUSIVE,
|
||||
Facet.MIN_EXCLUSIVE
|
||||
};
|
||||
|
||||
static final String MAX_VALUE = "65535";
|
||||
static final int LENGTH = MAX_VALUE.length();
|
||||
|
||||
UnsignedShortType()
|
||||
{
|
||||
super(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "unsignedShort"),
|
||||
TypeLibrary.UNSIGNED_INT);
|
||||
}
|
||||
|
||||
public int[] getConstrainingFacets()
|
||||
{
|
||||
return CONSTRAINING_FACETS;
|
||||
}
|
||||
|
||||
public void checkValid(String value, ValidationContext context)
|
||||
throws DatatypeException
|
||||
{
|
||||
super.checkValid(value, context);
|
||||
int len = value.length();
|
||||
if (len == 0)
|
||||
throw new DatatypeException(0, "invalid unsigned short value");
|
||||
boolean compare = false;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (len - i > LENGTH)
|
||||
throw new DatatypeException(i, "invalid unsigned short value");
|
||||
else if (len - i == LENGTH)
|
||||
compare = true;
|
||||
char c = value.charAt(i);
|
||||
if (c >= 0x30 && c <= 0x39)
|
||||
{
|
||||
if (compare)
|
||||
{
|
||||
char d = MAX_VALUE.charAt(i);
|
||||
if (Character.digit(c, 10) > Character.digit(d, 10))
|
||||
throw new DatatypeException(i,
|
||||
"invalid unsigned short value");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
throw new DatatypeException(i, "invalid unsigned short value");
|
||||
}
|
||||
}
|
||||
|
||||
public Object createValue(String literal, ValidationContext context) {
|
||||
try
|
||||
{
|
||||
return new Short(literal);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/* WhiteSpaceFacet.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.datatype;
|
||||
|
||||
/**
|
||||
* The <code>whiteSpace</code> facet.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public final class WhiteSpaceFacet
|
||||
extends Facet
|
||||
{
|
||||
|
||||
public static final int PRESERVE = 0;
|
||||
public static final int REPLACE = 1;
|
||||
public static final int COLLAPSE = 2;
|
||||
|
||||
public final int value;
|
||||
public final boolean fixed;
|
||||
|
||||
public WhiteSpaceFacet(int value, boolean fixed, Annotation annotation)
|
||||
{
|
||||
super(WHITESPACE, annotation);
|
||||
this.value = value;
|
||||
this.fixed = fixed;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return (other instanceof WhiteSpaceFacet &&
|
||||
((WhiteSpaceFacet) other).value == value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/* AnyNameNameClass.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG anyName element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class AnyNameNameClass
|
||||
extends NameClass
|
||||
{
|
||||
|
||||
NameClass exceptNameClass;
|
||||
|
||||
boolean matchesName(String uri, String localName)
|
||||
{
|
||||
return (exceptNameClass == null) ? true :
|
||||
!exceptNameClass.matchesName(uri, localName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/* AttributePattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG attribute element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class AttributePattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
NameClass nameClass;
|
||||
Pattern pattern;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/* ChoiceNameClass.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG choice element (in the context of a name class).
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class ChoiceNameClass
|
||||
extends NameClass
|
||||
{
|
||||
|
||||
NameClass name1;
|
||||
NameClass name2;
|
||||
|
||||
boolean matchesName(String uri, String localName)
|
||||
{
|
||||
return name1.matchesName(uri, localName) ||
|
||||
name2.matchesName(uri, localName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/* ChoicePattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG choice element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class ChoicePattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
Pattern pattern1;
|
||||
Pattern pattern2;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/* DataPattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.relaxng.datatype.Datatype;
|
||||
import org.relaxng.datatype.DatatypeLibrary;
|
||||
|
||||
/**
|
||||
* A RELAX NG data element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class DataPattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
Datatype type;
|
||||
DatatypeLibrary datatypeLibrary;
|
||||
List params = new LinkedList();
|
||||
Pattern exceptPattern;
|
||||
|
||||
}
|
||||
|
52
libjava/classpath/gnu/xml/validation/relaxng/Define.java
Normal file
52
libjava/classpath/gnu/xml/validation/relaxng/Define.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* Define.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG define.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class Define
|
||||
{
|
||||
|
||||
String name;
|
||||
ElementPattern element;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/* ElementPattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class ElementPattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
NameClass nameClass;
|
||||
Pattern pattern;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/* EmptyPattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG empty element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class EmptyPattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
static final EmptyPattern INSTANCE = new EmptyPattern();
|
||||
|
||||
}
|
||||
|
1651
libjava/classpath/gnu/xml/validation/relaxng/FullSyntaxBuilder.java
Normal file
1651
libjava/classpath/gnu/xml/validation/relaxng/FullSyntaxBuilder.java
Normal file
File diff suppressed because it is too large
Load diff
70
libjava/classpath/gnu/xml/validation/relaxng/Grammar.java
Normal file
70
libjava/classpath/gnu/xml/validation/relaxng/Grammar.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* Grammar.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.xml.validation.Schema;
|
||||
import javax.xml.validation.Validator;
|
||||
import javax.xml.validation.ValidatorHandler;
|
||||
|
||||
/**
|
||||
* A RELAX NG grammar.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class Grammar
|
||||
extends Schema
|
||||
{
|
||||
|
||||
Pattern start;
|
||||
List defines = new LinkedList();
|
||||
|
||||
public Validator newValidator()
|
||||
{
|
||||
return new GrammarValidator(this);
|
||||
}
|
||||
|
||||
public ValidatorHandler newValidatorHandler()
|
||||
{
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/* GrammarException.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Exception parsing a grammar.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class GrammarException
|
||||
extends IOException
|
||||
{
|
||||
|
||||
GrammarException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/* GrammarValidator.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.validation.Validator;
|
||||
import org.w3c.dom.ls.LSResourceResolver;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* RELAX NG validator.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class GrammarValidator
|
||||
extends Validator
|
||||
{
|
||||
|
||||
final Grammar grammar;
|
||||
ErrorHandler errorHandler;
|
||||
LSResourceResolver resourceResolver;
|
||||
|
||||
GrammarValidator(Grammar grammar)
|
||||
{
|
||||
this.grammar = grammar;
|
||||
}
|
||||
|
||||
public ErrorHandler getErrorHandler()
|
||||
{
|
||||
return errorHandler;
|
||||
}
|
||||
|
||||
public void setErrorHandler(ErrorHandler errorHandler)
|
||||
{
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
public LSResourceResolver getResourceResolver()
|
||||
{
|
||||
return resourceResolver;
|
||||
}
|
||||
|
||||
public void setResourceResolver(LSResourceResolver resourceResolver)
|
||||
{
|
||||
this.resourceResolver = resourceResolver;
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
public void validate(Source source, Result result)
|
||||
throws SAXException, IOException
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/* GroupPattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG group element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class GroupPattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
Pattern pattern1;
|
||||
Pattern pattern2;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/* InterleavePattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG interleave element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class InterleavePattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
Pattern pattern1;
|
||||
Pattern pattern2;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/* ListPattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG list element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class ListPattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
Pattern pattern;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/* NSNameNameClass.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG nsName element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class NSNameNameClass
|
||||
extends NameClass
|
||||
{
|
||||
|
||||
String ns;
|
||||
NameClass exceptNameClass;
|
||||
|
||||
boolean matchesName(String uri, String localName)
|
||||
{
|
||||
if (!ns.equals(uri))
|
||||
return false;
|
||||
return (exceptNameClass == null) ? true :
|
||||
!exceptNameClass.matchesName(uri, localName);
|
||||
}
|
||||
|
||||
}
|
||||
|
50
libjava/classpath/gnu/xml/validation/relaxng/NameClass.java
Normal file
50
libjava/classpath/gnu/xml/validation/relaxng/NameClass.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* NameClass.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG name class.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
abstract class NameClass
|
||||
{
|
||||
|
||||
abstract boolean matchesName(String uri, String localName);
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* NameNameClass.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG name element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class NameNameClass
|
||||
extends NameClass
|
||||
{
|
||||
|
||||
String ns;
|
||||
String name;
|
||||
|
||||
boolean matchesName(String uri, String localName)
|
||||
{
|
||||
if (!ns.equals(uri))
|
||||
return false;
|
||||
return name.equals(localName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/* NotAllowedPattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG notAllowed element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class NotAllowedPattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
static final NotAllowedPattern INSTANCE = new NotAllowedPattern();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/* OneOrMorePattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG oneOrMore element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class OneOrMorePattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
Pattern pattern;
|
||||
|
||||
}
|
||||
|
52
libjava/classpath/gnu/xml/validation/relaxng/Param.java
Normal file
52
libjava/classpath/gnu/xml/validation/relaxng/Param.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* Param.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG param element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class Param
|
||||
{
|
||||
|
||||
String name;
|
||||
String value;
|
||||
|
||||
}
|
||||
|
48
libjava/classpath/gnu/xml/validation/relaxng/Pattern.java
Normal file
48
libjava/classpath/gnu/xml/validation/relaxng/Pattern.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* Pattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG pattern.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
abstract class Pattern
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
/* RelaxNGSchemaFactory.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import javax.xml.validation.Schema;
|
||||
import javax.xml.validation.SchemaFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.ls.LSResourceResolver;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Schema factory for RELAX NG grammars.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class RELAXNGSchemaFactory
|
||||
extends SchemaFactory
|
||||
{
|
||||
|
||||
LSResourceResolver resourceResolver;
|
||||
|
||||
public LSResourceResolver getResourceResolver()
|
||||
{
|
||||
return resourceResolver;
|
||||
}
|
||||
|
||||
public void setResourceResolver(LSResourceResolver resourceResolver)
|
||||
{
|
||||
this.resourceResolver = resourceResolver;
|
||||
}
|
||||
|
||||
public boolean isSchemaLanguageSupported(String schemaLanguage)
|
||||
{
|
||||
return XMLConstants.RELAXNG_NS_URI.equals(schemaLanguage);
|
||||
}
|
||||
|
||||
public Schema newSchema()
|
||||
throws SAXException
|
||||
{
|
||||
// TODO
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Schema newSchema(Source[] schemata)
|
||||
throws SAXException
|
||||
{
|
||||
if (schemata == null || schemata.length != 1)
|
||||
throw new IllegalArgumentException("must specify one source");
|
||||
// TODO multiple schemata
|
||||
// TODO compact syntax
|
||||
try
|
||||
{
|
||||
Document doc = getDocument(schemata[0]);
|
||||
FullSyntaxBuilder builder = new FullSyntaxBuilder();
|
||||
return builder.parse(doc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
SAXException e2 = new SAXException(e.getMessage());
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
|
||||
private static Document getDocument(Source source)
|
||||
throws SAXException, IOException
|
||||
{
|
||||
if (source instanceof DOMSource)
|
||||
{
|
||||
Node node = ((DOMSource) source).getNode();
|
||||
if (node != null && node instanceof Document)
|
||||
return (Document) node;
|
||||
}
|
||||
String url = source.getSystemId();
|
||||
try
|
||||
{
|
||||
InputSource input = new InputSource(url);
|
||||
if (source instanceof StreamSource)
|
||||
{
|
||||
StreamSource streamSource = (StreamSource) source;
|
||||
input.setByteStream(streamSource.getInputStream());
|
||||
input.setCharacterStream(streamSource.getReader());
|
||||
}
|
||||
if (input.getByteStream() == null &&
|
||||
input.getCharacterStream() == null &&
|
||||
url != null)
|
||||
input.setByteStream(new URL(url).openStream());
|
||||
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
|
||||
f.setNamespaceAware(true);
|
||||
f.setCoalescing(true);
|
||||
f.setExpandEntityReferences(true);
|
||||
f.setIgnoringComments(true);
|
||||
f.setIgnoringElementContentWhitespace(true);
|
||||
DocumentBuilder b = f.newDocumentBuilder();
|
||||
return b.parse(input);
|
||||
}
|
||||
catch (ParserConfigurationException e)
|
||||
{
|
||||
SAXException e2 = new SAXException(e.getMessage());
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
52
libjava/classpath/gnu/xml/validation/relaxng/RefPattern.java
Normal file
52
libjava/classpath/gnu/xml/validation/relaxng/RefPattern.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* RefPattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG ref element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class RefPattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
String name;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/* TextPattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
/**
|
||||
* A RELAX NG text element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class TextPattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
static final TextPattern INSTANCE = new TextPattern();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/* ValuePattern.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.relaxng;
|
||||
|
||||
import org.relaxng.datatype.Datatype;
|
||||
import org.relaxng.datatype.DatatypeLibrary;
|
||||
|
||||
/**
|
||||
* A RELAX NG value element.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class ValuePattern
|
||||
extends Pattern
|
||||
{
|
||||
|
||||
DatatypeLibrary datatypeLibrary;
|
||||
Datatype type;
|
||||
String ns;
|
||||
String value;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/* AnyAttribute.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.xmlschema;
|
||||
|
||||
import gnu.xml.validation.datatype.Annotation;
|
||||
|
||||
/**
|
||||
* An attribute wildcard.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
final class AnyAttribute
|
||||
{
|
||||
|
||||
static final int STRICT = 0;
|
||||
static final int LAX = 1;
|
||||
static final int SKIP = 2;
|
||||
|
||||
final String namespace;
|
||||
|
||||
final int processContents;
|
||||
|
||||
Annotation annotation;
|
||||
|
||||
AnyAttribute(String namespace, int processContents)
|
||||
{
|
||||
this.namespace = namespace;
|
||||
this.processContents = processContents;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
/* AttributeDeclaration.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.xmlschema;
|
||||
|
||||
import gnu.xml.validation.datatype.Annotation;
|
||||
import gnu.xml.validation.datatype.SimpleType;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* An XML Schema attribute declaration schema component.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class AttributeDeclaration
|
||||
{
|
||||
|
||||
static final int NONE = 0;
|
||||
static final int DEFAULT = 1;
|
||||
static final int FIXED = 2;
|
||||
|
||||
/**
|
||||
* The scope of this attribute declaration (global or local).
|
||||
*/
|
||||
final boolean scope;
|
||||
|
||||
/**
|
||||
* The constraint type.
|
||||
* One of NONE, DEFAULT, FIXED.
|
||||
*/
|
||||
final int type;
|
||||
|
||||
/**
|
||||
* The value constraint.
|
||||
*/
|
||||
final String value;
|
||||
|
||||
/**
|
||||
* The name of the attribute to which this declaration refers.
|
||||
*/
|
||||
final QName name;
|
||||
|
||||
/**
|
||||
* The type definition corresponding to this attribute.
|
||||
*/
|
||||
final SimpleType datatype;
|
||||
|
||||
/**
|
||||
* The annotation associated with this attribute declaration, if any.
|
||||
*/
|
||||
final Annotation annotation;
|
||||
|
||||
AttributeDeclaration(boolean scope, int type, String value, QName name,
|
||||
SimpleType datatype, Annotation annotation)
|
||||
{
|
||||
this.scope = scope;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
this.datatype = datatype;
|
||||
this.annotation = annotation;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/* AttributeUse.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.xmlschema;
|
||||
|
||||
/**
|
||||
* An XML Schema attribute use schema component.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class AttributeUse
|
||||
{
|
||||
|
||||
/**
|
||||
* Whether the attribute is required.
|
||||
*/
|
||||
final boolean required;
|
||||
|
||||
/**
|
||||
* The constraint type.
|
||||
* One of NONE, DEFAULT, FIXED.
|
||||
*/
|
||||
final int type;
|
||||
|
||||
/**
|
||||
* The value constraint.
|
||||
*/
|
||||
final String value;
|
||||
|
||||
/**
|
||||
* The name of the attribute to which this declaration refers.
|
||||
*/
|
||||
final AttributeDeclaration declaration;
|
||||
|
||||
AttributeUse(boolean required, int type, String value,
|
||||
AttributeDeclaration declaration)
|
||||
{
|
||||
this.required = required;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
this.declaration = declaration;
|
||||
}
|
||||
|
||||
}
|
||||
|
102
libjava/classpath/gnu/xml/validation/xmlschema/ComplexType.java
Normal file
102
libjava/classpath/gnu/xml/validation/xmlschema/ComplexType.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
/* ComplexType.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.xmlschema;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import javax.xml.namespace.QName;
|
||||
import gnu.xml.validation.datatype.Type;
|
||||
|
||||
/**
|
||||
* A complex type definition.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class ComplexType
|
||||
extends Type
|
||||
{
|
||||
|
||||
/**
|
||||
* Either a simple type definition or a complex type definition.
|
||||
*/
|
||||
QName baseType;
|
||||
|
||||
/**
|
||||
* Either EXTENSION or RESTRICTION.
|
||||
*/
|
||||
int derivationMethod;
|
||||
|
||||
/**
|
||||
* A subset of {EXTENSION, RESTRICTION}.
|
||||
*/
|
||||
final int finality;
|
||||
|
||||
final boolean isAbstract;
|
||||
|
||||
Set attributeUses;
|
||||
|
||||
AnyAttribute attributeWildcard;
|
||||
|
||||
/**
|
||||
* One of EMPTY, SIMPLE, MIXED, or ELEMENT_ONLY.
|
||||
*/
|
||||
int contentType;
|
||||
|
||||
/**
|
||||
* A simple type definition or a Particle.
|
||||
*/
|
||||
Object contentModel;
|
||||
|
||||
final int prohibitedSubstitutions;
|
||||
|
||||
Set annotations;
|
||||
|
||||
ComplexType(QName name,
|
||||
boolean isAbstract,
|
||||
int prohibitedSubstitutions,
|
||||
int finality)
|
||||
{
|
||||
super(name);
|
||||
this.isAbstract = isAbstract;
|
||||
this.prohibitedSubstitutions = prohibitedSubstitutions;
|
||||
this.finality = finality;
|
||||
attributeUses = new LinkedHashSet();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
/* ElementDeclaration.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.xmlschema;
|
||||
|
||||
import gnu.xml.validation.datatype.Annotation;
|
||||
import gnu.xml.validation.datatype.Type;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* An XML Schema element declaration schema component.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class ElementDeclaration
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the element to which this declaration refers.
|
||||
*/
|
||||
final QName name;
|
||||
|
||||
/**
|
||||
* The type definition corresponding to this element.
|
||||
*/
|
||||
Type datatype;
|
||||
|
||||
/**
|
||||
* The scope of this schema component.
|
||||
* One of GLOBAL, LOCAL, or ABSENT.
|
||||
*/
|
||||
final int scope;
|
||||
|
||||
/**
|
||||
* If scope is LOCAL, the parent element definition.
|
||||
*/
|
||||
final ElementDeclaration parent;
|
||||
|
||||
/**
|
||||
* The constraint type.
|
||||
* One of NONE, DEFAULT, FIXED.
|
||||
*/
|
||||
final int type;
|
||||
|
||||
/**
|
||||
* The value constraint.
|
||||
*/
|
||||
final String value;
|
||||
|
||||
final boolean nillable;
|
||||
|
||||
// TODO identity-constraint definitions
|
||||
|
||||
final QName substitutionGroup;
|
||||
|
||||
final int substitutionGroupExclusions;
|
||||
|
||||
final int disallowedSubstitutions;
|
||||
|
||||
final boolean isAbstract;
|
||||
|
||||
/**
|
||||
* The annotation associated with this attribute declaration, if any.
|
||||
*/
|
||||
Annotation annotation;
|
||||
|
||||
ElementDeclaration(QName name,
|
||||
Type datatype,
|
||||
int scope, ElementDeclaration parent,
|
||||
int type, String value,
|
||||
boolean nillable,
|
||||
QName substitutionGroup,
|
||||
int substitutionGroupExclusions,
|
||||
int disallowedSubstitutions,
|
||||
boolean isAbstract)
|
||||
{
|
||||
this.name = name;
|
||||
this.datatype = datatype;
|
||||
this.scope = scope;
|
||||
this.parent = parent;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
this.nillable = nillable;
|
||||
this.substitutionGroup = substitutionGroup;
|
||||
this.substitutionGroupExclusions = substitutionGroupExclusions;
|
||||
this.disallowedSubstitutions = disallowedSubstitutions;
|
||||
this.isAbstract = isAbstract;
|
||||
}
|
||||
|
||||
}
|
||||
|
61
libjava/classpath/gnu/xml/validation/xmlschema/Particle.java
Normal file
61
libjava/classpath/gnu/xml/validation/xmlschema/Particle.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* Particle.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.validation.xmlschema;
|
||||
|
||||
/**
|
||||
* Container for element content.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class Particle
|
||||
{
|
||||
|
||||
final Integer minOccurs;
|
||||
final Integer maxOccurs;
|
||||
|
||||
final Object term;
|
||||
|
||||
Particle(Integer minOccurs, Integer maxOccurs, Object term)
|
||||
{
|
||||
this.minOccurs = minOccurs;
|
||||
this.maxOccurs = maxOccurs;
|
||||
this.term = term;
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue