[Mulgara-svn] r879 - trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa
pag at mulgara.org
pag at mulgara.org
Thu May 1 17:42:28 UTC 2008
Author: pag
Date: 2008-05-01 10:42:27 -0700 (Thu, 01 May 2008)
New Revision: 879
Modified:
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDoubleFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPFloatFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPHexBinaryFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPTypedLiteralRegistry.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralFactory.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralImpl.java
trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXSDStringFactory.java
Log:
Added the raw xsd: prefix into the type URIs to handle data that has not been declared with the appropriate namespace
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -59,6 +59,7 @@
*/
public final class SPBase64BinaryFactory implements SPTypedLiteralFactory {
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPBase64BinaryFactory.class);
@@ -74,8 +75,11 @@
* Returns the type URI for the objects created by this factory.
* @return URI
*/
- public Set getTypeURIs() {
- return Collections.singleton(SPBase64BinaryImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPBase64BinaryImpl.TYPE_URI);
+ types.add(XSDAbbrev.BASE64_BINARY_URI);
+ return Collections.unmodifiableSet(types);
}
/**
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBooleanFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -59,6 +59,7 @@
*/
public final class SPBooleanFactory implements SPTypedLiteralFactory {
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPBooleanFactory.class);
@@ -74,8 +75,11 @@
* Returns the type URI for the objects created by this factory.
* @return URI
*/
- public Set getTypeURIs() {
- return Collections.singleton(SPBooleanImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPBooleanImpl.TYPE_URI);
+ types.add(XSDAbbrev.BOOLEAN_URI);
+ return Collections.unmodifiableSet(types);
}
/**
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -35,6 +35,7 @@
import org.apache.log4j.Logger;
// Locally written packages
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -58,6 +59,7 @@
*/
public final class SPDateFactory implements SPTypedLiteralFactory {
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPDateFactory.class);
@@ -69,8 +71,11 @@
/**
* Returns the type URI for the objects created by this factory.
*/
- public Set getTypeURIs() {
- return Collections.singleton(SPDateImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPDateImpl.TYPE_URI);
+ types.add(XSDAbbrev.DATE_URI);
+ return Collections.unmodifiableSet(types);
}
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDateTimeFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -35,6 +35,7 @@
import org.apache.log4j.Logger;
// Locally written packages
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -58,6 +59,7 @@
*/
public final class SPDateTimeFactory implements SPTypedLiteralFactory {
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPDateTimeFactory.class);
@@ -68,8 +70,11 @@
/**
* Returns the type URI for the objects created by this factory.
*/
- public Set getTypeURIs() {
- return Collections.singleton(SPDateTimeImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPDateTimeImpl.TYPE_URI);
+ types.add(XSDAbbrev.DATE_TIME_URI);
+ return Collections.unmodifiableSet(types);
}
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDecimalFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -36,6 +36,7 @@
// Locally written packages
import org.mulgara.query.rdf.XSD;
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -61,6 +62,7 @@
*/
public final class SPDecimalFactory implements SPTypedLiteralFactory {
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPDecimalFactory.class);
private final static URI[] TYPE_URIS = {
@@ -78,13 +80,28 @@
URI.create(XSD.NAMESPACE + "unsignedShort"),
URI.create(XSD.NAMESPACE + "unsignedByte"),
URI.create(XSD.NAMESPACE + "positiveInteger"),
+ // Hacks to pick up on missing namespaces
+ URI.create(XSDAbbrev.NAMESPACE + "decimal"),
+ URI.create(XSDAbbrev.NAMESPACE + "integer"),
+ URI.create(XSDAbbrev.NAMESPACE + "nonPositiveInteger"),
+ URI.create(XSDAbbrev.NAMESPACE + "negativeInteger"),
+ URI.create(XSDAbbrev.NAMESPACE + "long"),
+ URI.create(XSDAbbrev.NAMESPACE + "int"),
+ URI.create(XSDAbbrev.NAMESPACE + "short"),
+ URI.create(XSDAbbrev.NAMESPACE + "byte"),
+ URI.create(XSDAbbrev.NAMESPACE + "nonNegativeInteger"),
+ URI.create(XSDAbbrev.NAMESPACE + "unsignedLong"),
+ URI.create(XSDAbbrev.NAMESPACE + "unsignedInt"),
+ URI.create(XSDAbbrev.NAMESPACE + "unsignedShort"),
+ URI.create(XSDAbbrev.NAMESPACE + "unsignedByte"),
+ URI.create(XSDAbbrev.NAMESPACE + "positiveInteger"),
// Always add new entries at the end of this array.
};
- private final static Map uriToSubtypeIdMap;
+ private final static Map<URI,Integer> uriToSubtypeIdMap;
static {
// Populate the uriToSubtypeIdMap.
- uriToSubtypeIdMap = new HashMap();
+ uriToSubtypeIdMap = new HashMap<URI,Integer>();
for (int i = 0; i < TYPE_URIS.length; ++i) {
uriToSubtypeIdMap.put(TYPE_URIS[i], new Integer(i));
}
@@ -99,7 +116,7 @@
/**
* Returns the type URIs for the objects created by this factory.
*/
- public Set getTypeURIs() {
+ public Set<URI> getTypeURIs() {
return Collections.unmodifiableSet(uriToSubtypeIdMap.keySet());
}
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDoubleFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDoubleFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPDoubleFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -35,6 +35,7 @@
import org.apache.log4j.Logger;
// Locally written packages
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -60,6 +61,7 @@
*/
public final class SPDoubleFactory implements SPTypedLiteralFactory {
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPDoubleFactory.class);
@@ -71,8 +73,11 @@
/**
* Returns the type URI for the objects created by this factory.
*/
- public Set getTypeURIs() {
- return Collections.singleton(SPDoubleImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPDoubleImpl.TYPE_URI);
+ types.add(XSDAbbrev.DOUBLE_URI);
+ return Collections.unmodifiableSet(types);
}
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPFloatFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPFloatFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPFloatFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -35,6 +35,7 @@
import org.apache.log4j.Logger;
// Locally written packages
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -60,6 +61,7 @@
*/
public final class SPFloatFactory implements SPTypedLiteralFactory {
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPFloatFactory.class);
@@ -71,8 +73,11 @@
/**
* Returns the type URI for the objects created by this factory.
*/
- public Set getTypeURIs() {
- return Collections.singleton(SPFloatImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPFloatImpl.TYPE_URI);
+ types.add(XSDAbbrev.FLOAT_URI);
+ return Collections.unmodifiableSet(types);
}
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGDayFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -35,6 +35,7 @@
import org.apache.log4j.Logger;
// Locally written packages
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -61,6 +62,7 @@
public final class SPGDayFactory implements SPTypedLiteralFactory {
/** Logging for the class */
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPGDayFactory.class);
/**
@@ -79,9 +81,11 @@
*
* @return The XSD type URI
*/
- public Set getTypeURIs() {
-
- return Collections.singleton(SPGDayImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPGDayImpl.TYPE_URI);
+ types.add(XSDAbbrev.GDAY_URI);
+ return Collections.unmodifiableSet(types);
}
/**
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthDayFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -35,6 +35,7 @@
import org.apache.log4j.Logger;
// Locally written packages
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -61,6 +62,7 @@
public final class SPGMonthDayFactory implements SPTypedLiteralFactory {
/** Logging for the class */
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPGMonthDayFactory.class);
/**
@@ -79,9 +81,11 @@
*
* @return The XSD type URI
*/
- public Set getTypeURIs() {
-
- return Collections.singleton(SPGMonthDayImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPGMonthDayImpl.TYPE_URI);
+ types.add(XSDAbbrev.GMONTHDAY_URI);
+ return Collections.unmodifiableSet(types);
}
/**
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGMonthFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -35,6 +35,7 @@
import org.apache.log4j.Logger;
// Locally written packages
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -61,6 +62,7 @@
public final class SPGMonthFactory implements SPTypedLiteralFactory {
/** Logging for the class */
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPGMonthFactory.class);
/**
@@ -79,9 +81,11 @@
*
* @return The XSD type URI
*/
- public Set getTypeURIs() {
-
- return Collections.singleton(SPGMonthImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPGMonthImpl.TYPE_URI);
+ types.add(XSDAbbrev.GMONTH_URI);
+ return Collections.unmodifiableSet(types);
}
/**
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -35,6 +35,7 @@
import org.apache.log4j.Logger;
// Locally written packages
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -61,6 +62,7 @@
public final class SPGYearFactory implements SPTypedLiteralFactory {
/** Logging for the class */
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPGYearFactory.class);
/**
@@ -79,9 +81,11 @@
*
* @return The XSD type URI
*/
- public Set getTypeURIs() {
-
- return Collections.singleton(SPGYearImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPGYearImpl.TYPE_URI);
+ types.add(XSDAbbrev.GYEAR_URI);
+ return Collections.unmodifiableSet(types);
}
/**
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPGYearMonthFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -35,6 +35,7 @@
import org.apache.log4j.Logger;
// Locally written packages
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -61,6 +62,7 @@
public final class SPGYearMonthFactory implements SPTypedLiteralFactory {
/** Logging for the class */
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPGYearMonthFactory.class);
/**
@@ -79,9 +81,11 @@
*
* @return The XSD type URI
*/
- public Set getTypeURIs() {
-
- return Collections.singleton(SPGYearMonthImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPGYearMonthImpl.TYPE_URI);
+ types.add(XSDAbbrev.GYEARMONTH_URI);
+ return Collections.unmodifiableSet(types);
}
/**
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPHexBinaryFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPHexBinaryFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPHexBinaryFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -35,7 +35,7 @@
import org.apache.log4j.Logger;
// Locally written packages
-import org.mulgara.query.rdf.*;
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -59,6 +59,7 @@
*/
public final class SPHexBinaryFactory implements SPTypedLiteralFactory {
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPHexBinaryFactory.class);
@@ -74,8 +75,11 @@
* Returns the type URI for the objects created by this factory.
* @return URI
*/
- public Set getTypeURIs() {
- return Collections.singleton(SPHexBinaryImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPHexBinaryImpl.TYPE_URI);
+ types.add(XSDAbbrev.HEX_BINARY_URI);
+ return Collections.unmodifiableSet(types);
}
/**
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPTypedLiteralRegistry.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPTypedLiteralRegistry.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPTypedLiteralRegistry.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -28,7 +28,6 @@
package org.mulgara.store.stringpool.xa;
// Java 2 standard packages
-import java.nio.ByteBuffer;
import java.net.URI;
import java.util.*;
@@ -36,28 +35,17 @@
import org.apache.log4j.Logger;
// Locally written packages
-import org.mulgara.query.rdf.LiteralImpl;
-import org.mulgara.query.rdf.XSD;
import org.mulgara.store.stringpool.*;
/**
- *
+ * Manages mappings of type URIs to the factory that handles that type, and also typeIDs to factories
+ * handling raw data with that ID.
+ *
* @created 2004-09-30
*
* @author David Makepeace
- *
- * @version $Revision: 1.1 $
- *
- * @modified $Date: 2005/03/11 04:15:22 $
- *
- * @maintenanceAuthor $Author: raboczi $
- *
- * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
- *
- * @copyright © 2004 <A href="http://www.PIsoftware.com/">Plugged In
- * Software Pty Ltd</A>
- *
+ * @copyright © 2004 <A href="http://www.PIsoftware.com/">Plugged In Software Pty Ltd</A>
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
public abstract class SPTypedLiteralRegistry {
@@ -86,14 +74,12 @@
private static final int MAX_TYPE_ID = 127;
- private static final SPTypedLiteralFactory[] typeIdToFactory =
- new SPTypedLiteralFactory[MAX_TYPE_ID];
+ private static final SPTypedLiteralFactory[] typeIdToFactory = new SPTypedLiteralFactory[MAX_TYPE_ID];
// Maps URI objects to SPTypedLiteralFactory objects.
- private static final Map typeURIToFactoryMap = new HashMap();
+ private static final Map<URI,SPTypedLiteralFactory> typeURIToFactoryMap = new HashMap<URI,SPTypedLiteralFactory>();
- private static final SPTypedLiteralFactory unknownSPTypedLiteralFactory =
- new UnknownSPTypedLiteralFactory();
+ private static final SPTypedLiteralFactory unknownSPTypedLiteralFactory = new UnknownSPTypedLiteralFactory();
static {
@@ -104,43 +90,31 @@
/**
* Returns the Set of supported type URIs.
*/
- public static Set getTypeURIs() {
+ public static Set<URI> getTypeURIs() {
return Collections.unmodifiableSet(typeURIToFactoryMap.keySet());
}
static SPTypedLiteralFactory getSPTypedLiteralFactory(URI typeURI) {
- if (typeURI == null) {
- throw new IllegalArgumentException("Parameter typeURI is null");
- }
+ if (typeURI == null) throw new IllegalArgumentException("Parameter typeURI is null");
// Look up the SPTypedLiteralFactory instance for this type URI.
- SPTypedLiteralFactory factory =
- (SPTypedLiteralFactory)typeURIToFactoryMap.get(typeURI);
+ SPTypedLiteralFactory factory = (SPTypedLiteralFactory)typeURIToFactoryMap.get(typeURI);
- if (factory == null) {
- factory = unknownSPTypedLiteralFactory;
- }
+ if (factory == null) factory = unknownSPTypedLiteralFactory;
assert factory != null;
return factory;
}
static SPTypedLiteralFactory getSPTypedLiteralFactory(int typeId) {
- if (
- typeId == SPObjectFactory.INVALID_TYPE_ID ||
- typeId < 0 || typeId > MAX_TYPE_ID
- ) {
+ if (typeId == SPObjectFactory.INVALID_TYPE_ID || typeId < 0 || typeId > MAX_TYPE_ID) {
throw new IllegalArgumentException("Invalid typeId: " + typeId);
}
- if (typeId == UnknownSPTypedLiteralImpl.TYPE_ID) {
- return unknownSPTypedLiteralFactory;
- }
+ if (typeId == UnknownSPTypedLiteralImpl.TYPE_ID) return unknownSPTypedLiteralFactory;
SPTypedLiteralFactory factory = typeIdToFactory[typeId];
- if (factory == null) {
- factory = unknownSPTypedLiteralFactory;
- }
+ if (factory == null) factory = unknownSPTypedLiteralFactory;
assert factory != null;
return factory;
}
@@ -148,21 +122,17 @@
static void initTypeURIToFactoryMap() {
// Iterate over the class names and construct each factory instance.
- for (int i = 0; i < DATATYPE_HANDLERS.length; ++i) {
- SPTypedLiteralFactory factory = DATATYPE_HANDLERS[i];
+ for (SPTypedLiteralFactory factory: DATATYPE_HANDLERS) {
assert factory != null;
- Set typeURIs = factory.getTypeURIs();
+ Set<URI> typeURIs = factory.getTypeURIs();
assert typeURIs != null;
assert !typeURIs.isEmpty();
int typeId = factory.getTypeId();
if (typeId < 0 || typeId == SPObjectFactory.INVALID_TYPE_ID) {
- logger.error(
- "Invalid typeId for datatype handler: " +
- factory.getClass().getName() + ". typeId:" + typeId
- );
+ logger.error("Invalid typeId for datatype handler: " + factory.getClass().getName() + ". typeId:" + typeId);
continue;
}
if (typeId >= MAX_TYPE_ID) {
@@ -177,16 +147,12 @@
// Check for duplicate typeIds.
if (typeIdToFactory[typeId] != null) {
- logger.error(
- "Duplicate typeId for datatype handler: " +
- factory.getClass().getName() +
- " (typeId:" + typeId + ", typeURIs:" + typeURIs + ")"
- );
+ logger.error("Duplicate typeId for datatype handler: " + factory.getClass().getName() + " (typeId:" + typeId + ", typeURIs:" + typeURIs + ")");
continue;
}
// Check for duplicate typeURIs.
- Set duplicates = new HashSet(typeURIs);
+ Set<URI> duplicates = new HashSet<URI>(typeURIs);
duplicates.retainAll(typeURIToFactoryMap.keySet());
if (!duplicates.isEmpty()) {
logger.error(
@@ -197,31 +163,12 @@
continue;
}
- // Ensure that the Set returned by getTypeURIs() only contains URI
- // objects.
- URI[] uris;
- try {
- uris = (URI[])typeURIs.toArray(new URI[typeURIs.size()]);
- } catch (ClassCastException ex) {
- logger.error(
- "Non-URI object in Set returned by getTypeURIs() for datatype handler: " +
- factory.getClass().getName() +
- " (typeId:" + typeId + ", typeURIs:" + typeURIs + ")", ex
- );
- continue;
- }
-
// Add the factory to the Maps.
typeIdToFactory[typeId] = factory;
- for (int j = 0; j < uris.length; ++j) {
- typeURIToFactoryMap.put(uris[j], factory);
- }
+ for (URI uri: typeURIs) typeURIToFactoryMap.put(uri, factory);
if (logger.isInfoEnabled()) {
- logger.info(
- "Registered SPTypedLiteralFactory for: " + typeURIs + " (id:" +
- typeId + ")"
- );
+ logger.info("Registered SPTypedLiteralFactory for: " + typeURIs + " (id:" + typeId + ")");
}
}
}
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -57,14 +57,18 @@
*/
public final class SPXMLLiteralFactory implements SPTypedLiteralFactory {
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPXMLLiteralFactory.class);
public int getTypeId() {
return SPXMLLiteralImpl.TYPE_ID;
}
- public Set getTypeURIs() {
- return Collections.singleton(SPXMLLiteralImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPXMLLiteralImpl.TYPE_URI);
+ types.add(SPXMLLiteralImpl.TYPE_URI_ABBREV);
+ return Collections.unmodifiableSet(types);
}
public SPTypedLiteral newSPTypedLiteral(URI typeURI, String lexicalForm) {
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralImpl.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralImpl.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXMLLiteralImpl.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -65,27 +65,22 @@
*
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-public class SPXMLLiteralImpl extends AbstractSPTypedLiteral
- implements SPTypedLiteral {
+public class SPXMLLiteralImpl extends AbstractSPTypedLiteral implements SPTypedLiteral {
- /**
- * Logger
- */
+ /** Logger */
+ @SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(SPXMLLiteralImpl.class);
- /**
- * Type code that identifies this type
- */
+ /** Type code that identifies this type */
static final int TYPE_ID = 15;
- /**
- * the XML Literal URI
- */
+ /** the XML Literal URI */
static final URI TYPE_URI = RDF.XML_LITERAL;
- /**
- * The lexical value of the XML Literal.
- */
+ /** the abbreviated XML Literal URI. This is a hack to handle references to a missing namespace */
+ static final URI TYPE_URI_ABBREV = URI.create("rdf:XMLLiteral");
+
+ /** The lexical value of the XML Literal. */
private String str;
SPXMLLiteralImpl(String str) {
Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXSDStringFactory.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXSDStringFactory.java 2008-05-01 17:40:50 UTC (rev 878)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPXSDStringFactory.java 2008-05-01 17:42:27 UTC (rev 879)
@@ -35,6 +35,7 @@
import org.apache.log4j.Logger;
// Locally written packages
+import org.mulgara.query.rdf.XSDAbbrev;
import org.mulgara.store.stringpool.*;
@@ -60,6 +61,7 @@
*/
public final class SPXSDStringFactory implements SPTypedLiteralFactory {
+ @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(SPXSDStringFactory.class);
@@ -71,8 +73,11 @@
/**
* Returns the type URI for the objects created by this factory.
*/
- public Set getTypeURIs() {
- return Collections.singleton(SPXSDStringImpl.TYPE_URI);
+ public Set<URI> getTypeURIs() {
+ Set<URI> types = new HashSet<URI>();
+ types.add(SPXSDStringImpl.TYPE_URI);
+ types.add(XSDAbbrev.STRING_URI);
+ return Collections.unmodifiableSet(types);
}
More information about the Mulgara-svn
mailing list