clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r983707 - /incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
Date Mon, 09 Aug 2010 16:12:17 GMT
Author: reto
Date: Mon Aug  9 16:12:17 2010
New Revision: 983707

URL: http://svn.apache.org/viewvc?rev=983707&view=rev
Log:
added sipport for BigInteger

Modified:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java?rev=983707&r1=983706&r2=983707&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
Mon Aug  9 16:12:17 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.clerezza.rdf.core.impl;
 
+import java.math.BigInteger;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.util.Collections;
@@ -210,6 +211,24 @@ public class SimpleLiteralFactory extend
 			return new Double(literal.getLexicalForm());
 		}
 	}
+
+	private static class BigIntegerConverter implements TypeConverter<BigInteger> {
+
+
+
+		@Override
+		public TypedLiteral createTypedLiteral(BigInteger value) {
+			return new TypedLiteralImpl(value.toString(), xsdInteger);
+		}
+
+		@Override
+		public BigInteger createObject(TypedLiteral literal) {
+			if (!literal.getDataType().equals(xsdInteger)) {
+				throw new InvalidLiteralTypeException(Double.class, literal.getDataType());
+			}
+			return new BigInteger(literal.getLexicalForm());
+		}
+	}
 	
 	private static class UriRefConverter implements TypeConverter<UriRef> {
 
@@ -229,7 +248,7 @@ public class SimpleLiteralFactory extend
 		}
 	}
 
-	private static Map<Class<?>, TypeConverter<?>> typeConverterMap = new
HashMap<Class<?>, TypeConverter<?>>();
+	final private static Map<Class<?>, TypeConverter<?>> typeConverterMap
= new HashMap<Class<?>, TypeConverter<?>>();
 
 	static {
 		typeConverterMap.put(byteArrayType, new ByteArrayConverter());
@@ -237,6 +256,7 @@ public class SimpleLiteralFactory extend
 		typeConverterMap.put(Boolean.class, new BooleanConverter());
 		typeConverterMap.put(String.class, new StringConverter());
 		typeConverterMap.put(Integer.class, new IntegerConverter());
+		typeConverterMap.put(BigInteger.class, new BigIntegerConverter());
 		typeConverterMap.put(Long.class, new LongConverter());
 		typeConverterMap.put(Double.class, new DoubleConverter());
 		typeConverterMap.put(UriRef.class, new UriRefConverter());



Mime
View raw message