-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/main/resources" excluding="**/.svn/**|**/*.java"/>
- <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
- <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
- <classpathentry kind="output" path="target/classes"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/antlr/antlr/3.1.3/antlr-3.1.3.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.1.3/antlr-runtime-3.1.3.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/4.1/junit-4.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/antlr/stringtemplate/3.2/stringtemplate-3.2.jar"/>
- <classpathentry kind="var" path="M2_REPO/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar"/>
+<classpath>\r
+ <classpathentry kind="src" path="src/main/java"/>\r
+ <classpathentry kind="src" path="src/main/resources" excluding="**/.svn/**|**/*.java"/>\r
+ <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>\r
+ <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+ <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>\r
+ <classpathentry kind="var" path="M2_REPO/org/antlr/antlr/3.1.3/antlr-3.1.3.jar"/>\r
+ <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.1.3/antlr-runtime-3.1.3.jar"/>\r
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.1/junit-4.1.jar"/>\r
+ <classpathentry kind="var" path="M2_REPO/org/antlr/stringtemplate/3.2/stringtemplate-3.2.jar"/>\r
+ <classpathentry kind="var" path="M2_REPO/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar"/>\r
</classpath>
\ No newline at end of file
-<projectDescription>
- <name>xerial-core</name>
- <comment>xerial-core is a common utilities for the Xerial project.</comment>
- <projects/>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.hyades.probekit.probekitbuilder</name>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.hyades.probekit.probekitbundler</name>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.hyades.test.tools.core.java.junit.builder</name>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.hyades.probekit.probekitnature</nature>
- </natures>
+<projectDescription>\r
+ <name>xerial-core</name>\r
+ <comment>xerial-core is a common utilities for the Xerial project.</comment>\r
+ <projects/>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.hyades.probekit.probekitbuilder</name>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.hyades.probekit.probekitbundler</name>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.hyades.test.tools.core.java.junit.builder</name>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ <nature>org.eclipse.hyades.probekit.probekitnature</nature>\r
+ </natures>\r
</projectDescription>
\ No newline at end of file
-#Thu Sep 10 14:33:14 JST 2009\r
+#Thu Sep 10 17:47:23 JST 2009\r
eclipse.preferences.version=1\r
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5\r
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
org.eclipse.jdt.core.compiler.source=1.5\r
-org.eclipse.jdt.core.formatter.align_type_members_on_columns=true\r
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false\r
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16\r
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=82\r
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16\r
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16\r
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16\r
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16\r
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16\r
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16\r
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80\r
-org.eclipse.jdt.core.formatter.alignment_for_enum_constants=82\r
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0\r
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16\r
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16\r
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16\r
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16\r
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16\r
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16\r
-org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=82\r
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16\r
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16\r
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16\r
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16\r
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line\r
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line\r
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line\r
-org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line\r
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line\r
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false\r
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false\r
org.eclipse.jdt.core.formatter.comment.format_block_comments=false\r
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=true\r
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false\r
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false\r
-org.eclipse.jdt.core.formatter.lineSplit=120\r
+org.eclipse.jdt.core.formatter.lineSplit=100\r
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false\r
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false\r
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0\r
* @author leo\r
* \r
*/\r
-public class ObjectLens\r
-{\r
- private static Logger _logger = Logger.getLogger(ObjectLens.class);\r
+public class ObjectLens {\r
\r
- private static HashMap<Class< ? >, ObjectLens> cache = new HashMap<Class< ? >, ObjectLens>();\r
+ private static Logger _logger = Logger.getLogger(ObjectLens.class);\r
+\r
+ private static HashMap<Class< ? >, ObjectLens> cache = new HashMap<Class< ? >, ObjectLens>();\r
\r
/**\r
* Get the lens of the target type\r
}\r
}\r
\r
- private Class< ? > targetType;\r
+ private Class< ? > targetType;\r
\r
- private List<ParameterGetter> getterContainer = new ArrayList<ParameterGetter>();\r
- private List<ParameterSetter> setterContainer = new ArrayList<ParameterSetter>();\r
- private List<RelationSetter> relationSetterContainer = new ArrayList<RelationSetter>();\r
- private ParameterSetter valueSetter = null;\r
+ private List<ParameterGetter> getterContainer = new ArrayList<ParameterGetter>();\r
+ private List<ParameterSetter> setterContainer = new ArrayList<ParameterSetter>();\r
+ private List<RelationSetter> relationSetterContainer = new ArrayList<RelationSetter>();\r
+ private ParameterSetter valueSetter = null;\r
\r
- private RelationSetter propertySetter = null;\r
+ private RelationSetter propertySetter = null;\r
\r
public void setProperty(Object target, Object key, Object value) throws XerialException {\r
if (propertySetter == null)\r
}\r
else if (TypeInfo.isMap(fieldType)) {\r
// TODO map putter\r
- Pair<Type, Type> keyValueTypes = ReflectionUtil.getGenericMapElementType(eachField);\r
+ Pair<Type, Type> keyValueTypes = ReflectionUtil\r
+ .getGenericMapElementType(eachField);\r
Pair<String, String> keyValueNames = pickRelationName(eachField.getName());\r
if (keyValueNames == null) {\r
// infer key and value names from type parameters in Map<Key, Value>\r
else if (TypeInfo.isCollection(fieldType)) {\r
Class< ? > elementType = ReflectionUtil.getRawClass(ReflectionUtil\r
.getGenericCollectionElementType(eachField));\r
- setterContainer.add(ParameterSetter.newSetter(elementType, paramName, eachField));\r
+ setterContainer.add(ParameterSetter\r
+ .newSetter(elementType, paramName, eachField));\r
getterContainer.add(ParameterGetter.newFieldGetter(eachField, paramName));\r
}\r
else {\r
if (!paramName.equals("value"))\r
- setterContainer.add(ParameterSetter.newSetter(fieldType, paramName, eachField));\r
+ setterContainer.add(ParameterSetter.newSetter(fieldType, paramName,\r
+ eachField));\r
else\r
valueSetter = ParameterSetter.newSetter(fieldType, paramName, eachField);\r
getterContainer.add(ParameterGetter.newFieldGetter(eachField, paramName));\r
case 1: {\r
String paramName = pickPropertyName(methodName);\r
Class< ? > parentOfTheSetter = eachMethod.getDeclaringClass();\r
- if ((TypeInfo.isCollection(parentOfTheSetter) || TypeInfo.isMap(parentOfTheSetter))\r
+ if ((TypeInfo.isCollection(parentOfTheSetter) || TypeInfo\r
+ .isMap(parentOfTheSetter))\r
&& paramName.equals("all"))\r
break;\r
\r
if (paramName.length() <= 0 && TypeInfo.isCollection(parentOfTheSetter)) {\r
- Class< ? > elementType = BeanUtil.resolveActualTypeOfCollectionElement(targetType, argTypes[0]);\r
- setterContainer.add(ParameterSetter.newSetter(elementType, "entry", eachMethod));\r
+ Class< ? > elementType = BeanUtil.resolveActualTypeOfCollectionElement(\r
+ targetType, argTypes[0]);\r
+ setterContainer.add(ParameterSetter.newSetter(elementType, "entry",\r
+ eachMethod));\r
}\r
else\r
addNewSetter(setterContainer, paramName, eachMethod);\r
\r
// relation adder\r
\r
- Pair<String, String> relName = pickRelationName(pickPropertyName(methodName, false));\r
+ Pair<String, String> relName = pickRelationName(pickPropertyName(methodName,\r
+ false));\r
if (relName == null) {\r
// infer relation node names\r
if (TypeInfo.isMap(eachMethod.getDeclaringClass())) {\r
\r
- Class< ? >[] mapElementType = BeanUtil.resolveActualTypeOfMapElement(targetType, eachMethod\r
- .getParameterTypes());\r
+ Class< ? >[] mapElementType = BeanUtil.resolveActualTypeOfMapElement(\r
+ targetType, eachMethod.getParameterTypes());\r
\r
// map.put(Key, Value)\r
- setterContainer\r
- .add(ParameterSetter.newMapEntrySetter(mapElementType[0], mapElementType[1]));\r
+ setterContainer.add(ParameterSetter.newMapEntrySetter(\r
+ mapElementType[0], mapElementType[1]));\r
\r
// (entry, key)\r
setterContainer.add(ParameterSetter.newKeySetter(mapElementType[0]));\r
continue;\r
}\r
else {\r
- relName = new Pair<String, String>(getCanonicalParameterName(argTypes[0].getSimpleName()),\r
+ relName = new Pair<String, String>(\r
+ getCanonicalParameterName(argTypes[0].getSimpleName()),\r
getCanonicalParameterName(argTypes[1].getSimpleName()));\r
}\r
}\r
\r
- relationSetterContainer.add(RelationSetter.newRelationSetter(relName.getFirst(), relName\r
- .getSecond(), eachMethod));\r
+ relationSetterContainer.add(RelationSetter.newRelationSetter(\r
+ relName.getFirst(), relName.getSecond(), eachMethod));\r
break;\r
}\r
}\r
// infer relation node names\r
if (TypeInfo.isMap(eachMethod.getDeclaringClass())) {\r
\r
- Class< ? >[] mapElementType = BeanUtil.resolveActualTypeOfMapElement(targetType, eachMethod\r
- .getParameterTypes());\r
+ Class< ? >[] mapElementType = BeanUtil.resolveActualTypeOfMapElement(\r
+ targetType, eachMethod.getParameterTypes());\r
\r
// map.put(Key, Value)\r
- setterContainer.add(ParameterSetter.newMapEntrySetter(mapElementType[0], mapElementType[1]));\r
+ setterContainer.add(ParameterSetter.newMapEntrySetter(mapElementType[0],\r
+ mapElementType[1]));\r
\r
// (entry, key)\r
setterContainer.add(ParameterSetter.newKeySetter(mapElementType[0]));\r
continue;\r
}\r
else {\r
- propertySetter = RelationSetter.newRelationSetter("key", "value", eachMethod);\r
+ propertySetter = RelationSetter.newRelationSetter("key", "value",\r
+ eachMethod);\r
continue;\r
}\r
}\r
\r
- relationSetterContainer.add(RelationSetter.newRelationSetter(relName.getFirst(), relName.getSecond(),\r
- eachMethod));\r
+ relationSetterContainer.add(RelationSetter.newRelationSetter(relName.getFirst(),\r
+ relName.getSecond(), eachMethod));\r
\r
continue;\r
}\r
}\r
}\r
\r
- private static void addNewSetter(List<ParameterSetter> setterContainer, String paramPart, Method m) {\r
+ private static void addNewSetter(List<ParameterSetter> setterContainer, String paramPart,\r
+ Method m) {\r
Class< ? >[] argTypes = m.getParameterTypes();\r
if (argTypes.length != 1)\r
return;\r
return;\r
}\r
\r
- static private Pattern propertyNamePattern = Pattern.compile("^(set|get|add|put|append)((\\S)(\\S*))?");\r
- static private Pattern pairedNamePattern = Pattern.compile("([A-Za-z0-9]*)_([A-Za-z0-9]*)");\r
+ static private Pattern propertyNamePattern = Pattern\r
+ .compile("^(set|get|add|put|append)((\\S)(\\S*))?");\r
+ static private Pattern pairedNamePattern = Pattern.compile("([A-Za-z0-9]*)_([A-Za-z0-9]*)");\r
\r
static String pickPropertyName(String methodName, boolean canonicalize) {\r
Matcher m = null;\r
public class ObjectMapper {
private static Logger _logger = Logger.getLogger(ObjectMapper.class);
+ //-------------------------------------
+ // dynamic parameters required for mapping tree-structured data to an object
// id -> corresponding object instance
+ //-------------------------------------
private HashMap<Long, Object> objectHolder = new HashMap<Long, Object>();
-
- // schema -> binder
- private HashMap<Schema, Binder> schema2binder = new HashMap<Schema, Binder>();
-
private Deque<Object> contextNodeStack = new ArrayDeque<Object>();
- private final QuerySet qs;
- private static HashMap<Class< ? >, ObjectMapper> prebuiltMapper = new HashMap<Class< ? >, ObjectMapper>();
+ private static QuerySet qs = null;
+ // schema -> binder
+ private static HashMap<Schema, Binder> schema2binder = new HashMap<Schema, Binder>();
/**
* interface for invoking setters or field setters of the object
}
}
- public <T> ObjectMapper(Class<T> targetType) throws XerialException {
- qs = buildQuery(targetType);
- }
-
- public static ObjectMapper getMapper(Class< ? > targetType) throws XerialException {
- if (prebuiltMapper.containsKey(targetType))
- return prebuiltMapper.get(targetType);
- else {
- ObjectMapper newInstance = new ObjectMapper(targetType);
- prebuiltMapper.put(targetType, newInstance);
- return newInstance;
- }
- }
-
- public <T> T map(Class<T> targetType, TreeParser parser) throws XerialException {
-
- T object = TypeInfo.createInstance(targetType);
- return map(object, parser);
- }
-
- public <T> T map(T object, TreeParser parser) throws XerialException {
- try {
- if (object == null)
- throw new XerialError(XerialErrorCode.INVALID_INPUT, "null object");
-
- if (_logger.isTraceEnabled())
- _logger.trace("query set: " + qs);
-
- // set the root object
- objectHolder.put(0L, object);
- contextNodeStack.addLast(object);
-
- AmoebaJoinHandler mapper = new RelationExtracter();
-
- StreamAmoebaJoin aj = new StreamAmoebaJoin(qs, mapper);
- aj.sweep(parser);
- return object;
- }
- catch (IOException e) {
- throw new XerialException(XerialErrorCode.IO_EXCEPTION, e);
- }
- catch (Exception e) {
- throw new XerialException(XerialErrorCode.INHERITED, e);
- }
-
- }
-
- public <T> void find(Class<T> targetType, TreeParser parser,
- String coreNodeNameOfTheTargetType, ObjectHandler<T> handler) throws XerialException {
-
- try {
- AmoebaJoinHandler mapper = new RelationExtracter();
-
- _logger.info(qs);
-
- StreamAmoebaJoin aj = new StreamAmoebaJoin(qs, mapper);
- aj.sweep(parser);
- }
- catch (IOException e) {
- throw new XerialException(XerialErrorCode.IO_EXCEPTION, e);
- }
- catch (Exception e) {
- throw new XerialException(XerialErrorCode.INHERITED, e);
- }
-
- }
-
private QuerySet buildQuery(Class< ? > targetType) {
QueryBuilder qb = new QueryBuilder();
qb.build(targetType, "root");
- return qb.qs.build();
+ return qb.qsBuilder.build();
}
private class QueryBuilder {
- QuerySetBuilder qs = new QuerySetBuilder();
+ QuerySetBuilder qsBuilder = new QuerySetBuilder();
private HashMap<String, Set<Class< ? >>> processedClassTable = new HashMap<String, Set<Class< ? >>>();
//Set<Class< ? >> processedClasses = new HashSet<Class< ? >>();
builder.add("entry");
builder.add(each.getParameterName());
Schema s = builder.build();
- qs.addQueryTarget(s);
+ qsBuilder.addQueryTarget(s);
schema2binder.put(s, new AttributeBinder(MapEntry.class, each));
continue;
}
builder.add(each.getParameterName());
Schema s = builder.build();
- qs.addQueryTarget(s);
+ qsBuilder.addQueryTarget(s);
schema2binder.put(s, new AttributeBinder(lens.getTargetType(), each));
}
Schema s = new SchemaBuilder().add(each.getCoreNodeName()).add(
each.getAttributeNodeName()).build();
- qs.addQueryTarget(s);
+ qsBuilder.addQueryTarget(s);
schema2binder.put(s, new RelationBinder(lens, each));
}
+ public <T> ObjectMapper(Class<T> targetType) throws XerialException {
+ if (qs == null) {
+ schema2binder.clear();
+ qs = buildQuery(targetType);
+ }
+ }
+
+ public static ObjectMapper getMapper(Class< ? > targetType) throws XerialException {
+ return new ObjectMapper(targetType);
+ }
+
+ public <T> T map(Class<T> targetType, TreeParser parser) throws XerialException {
+
+ T object = TypeInfo.createInstance(targetType);
+ return map(object, parser);
+ }
+
+ public <T> T map(T object, TreeParser parser) throws XerialException {
+ try {
+ if (object == null)
+ throw new XerialError(XerialErrorCode.INVALID_INPUT, "null object");
+
+ if (_logger.isTraceEnabled())
+ _logger.trace("query set: " + qs);
+
+ // set the root object
+ objectHolder.put(0L, object);
+ contextNodeStack.addLast(object);
+
+ AmoebaJoinHandler mapper = new RelationExtracter();
+
+ StreamAmoebaJoin aj = new StreamAmoebaJoin(qs, mapper);
+ aj.sweep(parser);
+ return object;
+ }
+ catch (IOException e) {
+ throw new XerialException(XerialErrorCode.IO_EXCEPTION, e);
+ }
+ catch (Exception e) {
+ throw new XerialException(XerialErrorCode.INHERITED, e);
+ }
+
+ }
+
+ public <T> void find(Class<T> targetType, TreeParser parser,
+ String coreNodeNameOfTheTargetType, ObjectHandler<T> handler) throws XerialException {
+
+ try {
+ AmoebaJoinHandler mapper = new RelationExtracter();
+
+ _logger.info(qs);
+
+ StreamAmoebaJoin aj = new StreamAmoebaJoin(qs, mapper);
+ aj.sweep(parser);
+ }
+ catch (IOException e) {
+ throw new XerialException(XerialErrorCode.IO_EXCEPTION, e);
+ }
+ catch (Exception e) {
+ throw new XerialException(XerialErrorCode.INHERITED, e);
+ }
+
+ }
+
private Object getNodeInstance(Node node, Class< ? > nodeType) throws XerialException {
Object instance = objectHolder.get(node.nodeID);
if (instance != null)
-// $ANTLR 3.1.3 Mar 17, 2009 19:23:44 LensQuery.g 2009-08-06 15:20:41\r
+// $ANTLR 3.1.3 Mar 17, 2009 19:23:44 LensQuery.g 2009-09-10 16:56:16\r
\r
/*--------------------------------------------------------------------------\r
* Copyright 2009 Taro L. Saito\r
-// $ANTLR 3.1.3 Mar 17, 2009 19:23:44 LensQuery.g 2009-08-06 15:20:40\r
+// $ANTLR 3.1.3 Mar 17, 2009 19:23:44 LensQuery.g 2009-09-10 16:56:16\r
\r
/*--------------------------------------------------------------------------\r
* Copyright 2009 Taro L. Saito\r
\r
\r
// AST REWRITE\r
- // elements: alias, nodeValue, nodeName\r
+ // elements: nodeName, nodeValue, alias\r
// token labels: \r
// rule labels: retval\r
// token list labels: \r
* @author leo
*
*/
-public class TypeInfo
-{
- static private Class< ? >[] _parameterClass = { int.class, double.class, float.class, long.class,
- boolean.class, char.class, short.class, String.class, Integer.class, Double.class, Float.class, Long.class,
- Boolean.class, Character.class, Short.class, Date.class, File.class };
+public class TypeInfo {
+ static private Class< ? >[] _parameterClass = { int.class, double.class, float.class,
+ long.class, boolean.class, char.class, short.class, String.class, Integer.class,
+ Double.class, Float.class, Long.class, Boolean.class, Character.class, Short.class,
+ Date.class, File.class };
- static private HashSet<Class< ? >> basicTypeSet = new HashSet<Class< ? >>();
+ static private HashSet<Class< ? >> basicTypeSet = new HashSet<Class< ? >>();
static {
for (Class< ? > c : _parameterClass)
basicTypeSet.add(c);
/**
* @param c
* @return true : if a given class is a single class or array of int,
- * double, float, boolean, String, Integer, Double, Float or
- * Boolean. otherwise false.
+ * double, float, boolean, String, Integer, Double, Float, Boolean,
+ * or File. otherwise false.
*/
public static boolean isBasicType(Class< ? > c) {
if (c.isArray())
public static <T> Object createPrimitiveTypeInstance(Class<T> c) throws XerialException {
if (!c.isPrimitive())
- throw new XerialException(XerialErrorCode.InvalidType, String.format("%s is not a primitive", c
- .getSimpleName()));
+ throw new XerialException(XerialErrorCode.InvalidType, String.format(
+ "%s is not a primitive", c.getSimpleName()));
// Boolean.TYPE, Character.TYPE, Byte.TYPE, Short.TYPE, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE, Void.TYPE
if (c == int.class)
}
}
- throw new XerialException(XerialErrorCode.NoPublicConstructor, "No public constructor for the class: "
- + c.getName() + " is available");
+ throw new XerialException(XerialErrorCode.NoPublicConstructor,
+ "No public constructor for the class: " + c.getName() + " is available");
}
}
}
}
- public static Class< ? > getElementTypeOfCollection(Class< ? extends Collection< ? >> collectionType) {
+ public static Class< ? > getElementTypeOfCollection(
+ Class< ? extends Collection< ? >> collectionType) {
// collectionType.get
//
// ParameterizedType pt = getParentParameterizedType(type, Collection.class);