Author: reto
Date: Sun May 8 19:53:45 2011
New Revision: 1100800
URL: http://svn.apache.org/viewvc?rev=1100800&view=rev
Log:
CLEREZZA-511: improving performance without changing the public api as the
issue suggests
Modified:
incubator/clerezza/trunk/parent/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
Modified:
incubator/clerezza/trunk/parent/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java?rev=1100800&r1=1100799&r2=1100800&view=diff
==============================================================================
---
incubator/clerezza/trunk/parent/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
(original)
+++
incubator/clerezza/trunk/parent/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
Sun May 8 19:53:45 2011
@@ -277,14 +277,24 @@ public class SimpleLiteralFactory extend
}
- @SuppressWarnings("unchecked")
+
@Override
public <T> T createObject(Class<T> type, TypedLiteral literal)
throws NoConvertorException,
InvalidLiteralTypeException {
+ final TypeConverter<T> converter = getConverterFor(type);
+ return converter.createObject(literal);
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> TypeConverter<T> getConverterFor(Class<T> type) throws
NoConvertorException {
+ TypeConverter<T> convertor = (TypeConverter<T>)
typeConverterMap.get(type);
+ if (convertor != null) {
+ return convertor;
+ }
for (Map.Entry<Class<?>, TypeConverter<?>> converterEntry :
typeConverterMap.entrySet()) {
if (type.isAssignableFrom(converterEntry.getKey())) {
- TypeConverter<T> converter = (TypeConverter<T>)
converterEntry.getValue();
- return converter.createObject(literal);
+ return (TypeConverter<T>)
converterEntry.getValue();
}
}
throw new NoConvertorException(type);