aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Pitschke2012-11-12 14:39:08 (EST)
committerSteve Pitschke2012-11-12 14:39:08 (EST)
commit382f363ea0dad4c3e3b7af6891c92796f84a6991 (patch)
treea1b9537e184d3f442812c6f17bf3478d7fd32c41
parentf963b86f94a7eb9cbe50859acbd741ea775eacb1 (diff)
downloadorg.eclipse.lyo.core-382f363ea0dad4c3e3b7af6891c92796f84a6991.zip
org.eclipse.lyo.core-382f363ea0dad4c3e3b7af6891c92796f84a6991.tar.gz
org.eclipse.lyo.core-382f363ea0dad4c3e3b7af6891c92796f84a6991.tar.bz2
Bug 394006: Deal with Complete FilteredResource<> Template Argsrefs/changes/44/8644/1
Need to deal with either a Object[] or List<Object> template argument to FilteredResouce<> class.
-rw-r--r--OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/OslcRdfXmlProvider.java39
-rw-r--r--OSLC4JJson4JProvider/src/org/eclipse/lyo/oslc4j/provider/json4j/OslcRdfJsonProvider.java39
2 files changed, 72 insertions, 6 deletions
diff --git a/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/OslcRdfXmlProvider.java b/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/OslcRdfXmlProvider.java
index b37d976..8fe5de3 100644
--- a/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/OslcRdfXmlProvider.java
+++ b/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/OslcRdfXmlProvider.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
+import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Collection;
@@ -82,13 +83,45 @@ public final class OslcRdfXmlProvider
ParameterizedType parameterizedType = (ParameterizedType)genericType;
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
- if (actualTypeArguments.length != 1 ||
- ! (actualTypeArguments[0] instanceof Class<?>))
+ if (actualTypeArguments.length != 1)
{
return false;
}
- actualType = (Class<?>)actualTypeArguments[0];
+ if (actualTypeArguments[0] instanceof Class<?>)
+ {
+ actualType = (Class<?>)actualTypeArguments[0];
+ }
+ else if (actualTypeArguments[0] instanceof ParameterizedType)
+ {
+ parameterizedType = (ParameterizedType)actualTypeArguments[0];
+ actualTypeArguments = parameterizedType.getActualTypeArguments();
+
+ if (actualTypeArguments.length != 1 ||
+ ! (actualTypeArguments[0] instanceof Class<?>))
+ {
+ return false;
+ }
+
+ actualType = (Class<?>)actualTypeArguments[0];
+ }
+ else if (actualTypeArguments[0] instanceof GenericArrayType)
+ {
+ GenericArrayType genericArrayType =
+ (GenericArrayType)actualTypeArguments[0];
+ Type componentType = genericArrayType.getGenericComponentType();
+
+ if (! (componentType instanceof Class<?>))
+ {
+ return false;
+ }
+
+ actualType = (Class<?>)componentType;
+ }
+ else
+ {
+ return false;
+ }
}
else
{
diff --git a/OSLC4JJson4JProvider/src/org/eclipse/lyo/oslc4j/provider/json4j/OslcRdfJsonProvider.java b/OSLC4JJson4JProvider/src/org/eclipse/lyo/oslc4j/provider/json4j/OslcRdfJsonProvider.java
index d351051..46b6813 100644
--- a/OSLC4JJson4JProvider/src/org/eclipse/lyo/oslc4j/provider/json4j/OslcRdfJsonProvider.java
+++ b/OSLC4JJson4JProvider/src/org/eclipse/lyo/oslc4j/provider/json4j/OslcRdfJsonProvider.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
+import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Collection;
@@ -82,13 +83,45 @@ public final class OslcRdfJsonProvider
ParameterizedType parameterizedType = (ParameterizedType)genericType;
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
- if (actualTypeArguments.length != 1 ||
- ! (actualTypeArguments[0] instanceof Class<?>))
+ if (actualTypeArguments.length != 1)
{
return false;
}
- actualType = (Class<?>)actualTypeArguments[0];
+ if (actualTypeArguments[0] instanceof Class<?>)
+ {
+ actualType = (Class<?>)actualTypeArguments[0];
+ }
+ else if (actualTypeArguments[0] instanceof ParameterizedType)
+ {
+ parameterizedType = (ParameterizedType)actualTypeArguments[0];
+ actualTypeArguments = parameterizedType.getActualTypeArguments();
+
+ if (actualTypeArguments.length != 1 ||
+ ! (actualTypeArguments[0] instanceof Class<?>))
+ {
+ return false;
+ }
+
+ actualType = (Class<?>)actualTypeArguments[0];
+ }
+ else if (actualTypeArguments[0] instanceof GenericArrayType)
+ {
+ GenericArrayType genericArrayType =
+ (GenericArrayType)actualTypeArguments[0];
+ Type componentType = genericArrayType.getGenericComponentType();
+
+ if (! (componentType instanceof Class<?>))
+ {
+ return false;
+ }
+
+ actualType = (Class<?>)componentType;
+ }
+ else
+ {
+ return false;
+ }
}
else
{