[Mulgara-svn] r877 - trunk/src/jar/query/java/org/mulgara/query/rdf

pag at mulgara.org pag at mulgara.org
Thu May 1 17:38:18 UTC 2008


Author: pag
Date: 2008-05-01 10:38:17 -0700 (Thu, 01 May 2008)
New Revision: 877

Added:
   trunk/src/jar/query/java/org/mulgara/query/rdf/XSDAbbrev.java
Log:
Copy of XSD which refers to the XSD namespace tag directly. This is a hack to deal with all that data out there that forgot to declare the XSD namespace before using xsd: everywhere.

Added: trunk/src/jar/query/java/org/mulgara/query/rdf/XSDAbbrev.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/rdf/XSDAbbrev.java	                        (rev 0)
+++ trunk/src/jar/query/java/org/mulgara/query/rdf/XSDAbbrev.java	2008-05-01 17:38:17 UTC (rev 877)
@@ -0,0 +1,176 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.query.rdf;
+
+// Java 2 standard packages
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * This is a hack to take into account bad data that sometimes arrives with
+ * references to the XSD namespace, but no declaration of it..
+ *
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/">XML Schema Part 2: Datatypes</a>
+ * @created 2008-04-29
+ * @author Paul Gearon
+ * @copyright &copy; 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class XSDAbbrev {
+
+  /**
+   * XML namespace prefix for XML Schema datatypes:
+   * <code>http://www.w3.org/2001/XMLSchema#</code>.
+   *
+   * Note that this does not represent a declared namespace, because if it
+   * did then this class would not be needed.
+   */
+  public final static String NAMESPACE = "xsd:";
+
+  /** URI for the XML Schema <code>xsd:string</code> datatype. */
+  public final static URI STRING_URI = URI.create(NAMESPACE + "string");
+
+  ///////////////////////
+  // Start of Numeric types
+  ///////////////////////
+
+  /** URI for the XML Schema <code>xsd:float</code> datatype; */
+  public final static URI FLOAT_URI = URI.create(NAMESPACE + "float");
+
+  /** URI for the XML Schema <code>xsd:double</code> datatype; */
+  public final static URI DOUBLE_URI = URI.create(NAMESPACE + "double");
+
+  /** URI for the XML Schema <code>xsd:decimal</code> datatype. */
+  public final static URI DECIMAL_URI = URI.create(NAMESPACE + "decimal");
+
+  /** URI for the XML Schema <code>integer</code> datatype. Subtype of {@link #DECIMAL_URI}. */
+  public final static URI INTEGER_URI = URI.create(NAMESPACE + "integer");
+
+  /** URI for the XML Schema <code>nonPositiveInteger</code> datatype. Subtype of {@link #INTEGER_URI}. */
+  public final static URI NON_POSITIVE_INTEGER_URI = URI.create(NAMESPACE + "nonPositiveInteger");
+
+  /** URI for the XML Schema <code>negativeInteger</code> datatype. Subtype of {@link #NON_POSITIVE_INTEGER_URI}. */
+  public final static URI NEGATIVE_INTEGER_URI = URI.create(NAMESPACE + "negativeInteger");
+
+  /** URI for the XML Schema <code>long</code> datatype. Subtype of {@link #INTEGER_URI}. */
+  public final static URI LONG_URI = URI.create(NAMESPACE + "long");
+
+  /** URI for the XML Schema <code>int</code> datatype. Subtype of {@link #LONG_URI}. */
+  public final static URI INT_URI = URI.create(NAMESPACE + "int");
+
+  /** URI for the XML Schema <code>short</code> datatype. Subtype of {@link #INT_URI}. */
+  public final static URI SHORT_URI = URI.create(NAMESPACE + "short");
+
+  /** URI for the XML Schema <code>byte</code> datatype. Subtype of {@link #SHORT_URI}. */
+  public final static URI BYTE_URI = URI.create(NAMESPACE + "byte");
+
+  /** URI for the XML Schema <code>nonNegativeInteger</code> datatype. Subtype of {@link #INTEGER_URI}. */
+  public final static URI NON_NEGATIVE_INTEGER_URI = URI.create(NAMESPACE + "nonNegativeInteger");
+
+  /** URI for the XML Schema <code>positiveInteger</code> datatype. Subtype of {@link #NON_NEGATIVE_INTEGER_URI}. */
+  public final static URI POSITIVE_INTEGER_URI = URI.create(NAMESPACE + "positiveInteger");
+
+  /** URI for the XML Schema <code>unsignedLong</code> datatype. Subtype of {@link #NON_NEGATIVE_INTEGER_URI}. */
+  public final static URI UNSIGNED_LONG_URI = URI.create(NAMESPACE + "unsignedLong");
+
+  /** URI for the XML Schema <code>unsignedInt</code> datatype. Subtype of {@link #UNSIGNED_LONG_URI}. */
+  public final static URI UNSIGNED_INT_URI = URI.create(NAMESPACE + "unsignedInt");
+
+  /** URI for the XML Schema <code>unsignedShort</code> datatype. Subtype of {@link #UNSIGNED_INT_URI}. */
+  public final static URI UNSIGNED_SHORT_URI = URI.create(NAMESPACE + "unsignedShort");
+
+  /** URI for the XML Schema <code>unsignedByte</code> datatype. Subtype of {@link #UNSIGNED_SHORT_URI}. */
+  public final static URI UNSIGNED_BYTE_URI = URI.create(NAMESPACE + "unsignedByte");
+
+  /** The set of all numeric types/ */
+  static final private Set<URI> numericTypes = new HashSet<URI>();
+
+  /**
+   * Tests if a URI is for a numeric type.
+   * @param type The URI of the type to test.
+   * @return <code>true</code> iff the type is an XSD numeric type.
+   */
+  public static final boolean isNumericType(URI type) {
+    return numericTypes.contains(type);
+  }
+
+  // Initialize the set of number types
+  static {
+    numericTypes.add(FLOAT_URI);
+    numericTypes.add(DOUBLE_URI);
+    numericTypes.add(DECIMAL_URI);
+    numericTypes.add(INTEGER_URI);
+    numericTypes.add(NON_POSITIVE_INTEGER_URI);
+    numericTypes.add(NEGATIVE_INTEGER_URI);
+    numericTypes.add(LONG_URI);
+    numericTypes.add(INT_URI);
+    numericTypes.add(SHORT_URI);
+    numericTypes.add(BYTE_URI);
+    numericTypes.add(NON_NEGATIVE_INTEGER_URI);
+    numericTypes.add(POSITIVE_INTEGER_URI);
+    numericTypes.add(UNSIGNED_LONG_URI);
+    numericTypes.add(UNSIGNED_INT_URI);
+    numericTypes.add(UNSIGNED_SHORT_URI);
+    numericTypes.add(UNSIGNED_BYTE_URI);
+  }
+  ///////////////////////
+  // End of Numeric types
+  ///////////////////////
+
+  /** URI for the XML Schema <code>xsd:date</code> datatype. */
+  public final static URI DATE_URI = URI.create(NAMESPACE + "date");
+
+  /** URI for the XML Schema <code>xsd:dateTime</code> datatype. */
+  public final static URI DATE_TIME_URI = URI.create(NAMESPACE + "dateTime");
+
+  /** URI for the XML Schema <code>xsd:gYearMonth</code> datatype; */
+  public final static URI GYEARMONTH_URI = URI.create(NAMESPACE + "gYearMonth");
+
+  /** URI for the XML Schema <code>xsd:gYear</code> datatype; */
+  public final static URI GYEAR_URI = URI.create(NAMESPACE + "gYear");
+
+  /** URI for the XML Schema <code>xsd:gMonthDay</code> datatype; */
+  public final static URI GMONTHDAY_URI = URI.create(NAMESPACE + "gMonthDay");
+
+  /** URI for the XML Schema <code>xsd:gDay</code> datatype; */
+  public final static URI GDAY_URI = URI.create(NAMESPACE + "gDay");
+
+  /** URI for the XML Schema <code>xsd:gMonth</code> datatype; */
+  public final static URI GMONTH_URI = URI.create(NAMESPACE + "gMonth");
+
+  /** URI for the XML Schema <code>xsd:boolean</code> datatype; */
+  public final static URI BOOLEAN_URI = URI.create(NAMESPACE + "boolean");
+
+  /** URI for the XML Schema <code>xsd:hexBinary</code> datatype; */
+  public final static URI HEX_BINARY_URI = URI.create(NAMESPACE + "hexBinary");
+
+  /** URI for the XML Schema <code>xsd:base64Binary</code> datatype; */
+  public final static URI BASE64_BINARY_URI = URI.create(NAMESPACE + "base64Binary");
+
+}




More information about the Mulgara-svn mailing list