Gephi Toolkit Javadoc

org.gephi.data.attributes.type
Class TypeConvertor

java.lang.Object
  extended by org.gephi.data.attributes.type.TypeConvertor

public final class TypeConvertor
extends java.lang.Object

Class responsible for type manipulation and creation needed in Attributes API.

Author:
Martin Ć kurla, Mathieu Bastian

Method Summary
static
<T> T[]
convertPrimitiveToWrapperArray(java.lang.Object primitiveArray)
          Converts given array of primitive type into array of wrapper type.
static
<T> T[]
createArrayFromString(java.lang.String input, java.lang.String separator, java.lang.Class<T> finalType)
          Creates array of given type from single String value.
static
<T> T
createInstanceFromString(java.lang.String input, java.lang.Class<T> finalType)
          Transforms String value to any kind of object with given type.
static AttributeType getDynamicType(AttributeType staticType)
          Returns the corresponding dynamic type from staticType For example returns DYNAMIC_FLOAT if given type is FLOAT.
static AttributeType getStaticType(AttributeType dynamicType)
          Returns the underlying static type from dynamicType For example returns FLOAT if given type is DYNAMIC_FLOAT.
static java.lang.Class<?> getWrapperFromPrimitive(java.lang.Class<?> primitiveType)
          Returns wrapper type from given primitive type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createArrayFromString

public static <T> T[] createArrayFromString(java.lang.String input,
                                            java.lang.String separator,
                                            java.lang.Class<T> finalType)
Creates array of given type from single String value. String value is always parsed by given separator into smaller chunks. Every chunk will represent independent object in final array. The exact conversion process from String value into final type is done by createInstanceFromString method.

Type Parameters:
T - type parameter representing final array type
Parameters:
input - input
separator - separator which will be used in the process of tokenizing input
finalType - type of final array
Returns:
final array
Throws:
java.lang.NullPointerException - if any of given parameters is null
java.lang.IllegalArgumentException - if array of given type cannot be created
See Also:
createInstanceFromString

createInstanceFromString

public static <T> T createInstanceFromString(java.lang.String input,
                                             java.lang.Class<T> finalType)
Transforms String value to any kind of object with given type. The concrete conversion must be done by the type itself. This assumes, that given type defines at least one of the following:

convertPrimitiveToWrapperArray

public static <T> T[] convertPrimitiveToWrapperArray(java.lang.Object primitiveArray)
Converts given array of primitive type into array of wrapper type.

Type Parameters:
T - type parameter representing final wrapper type
Parameters:
primitiveArray - primitive array
Returns:
wrapper array
Throws:
java.lang.NullPointerException - if given parameter is null
java.lang.IllegalArgumentException - if given parameter is not array or given parameter is not array of primitive type

getWrapperFromPrimitive

public static java.lang.Class<?> getWrapperFromPrimitive(java.lang.Class<?> primitiveType)
Returns wrapper type from given primitive type.

Parameters:
primitiveType - primitive type
Returns:
wrapper type
Throws:
java.lang.NullPointerException - if given parameter is null
java.lang.IllegalArgumentException - if given parameter is not a primitive type

getStaticType

public static AttributeType getStaticType(AttributeType dynamicType)
Returns the underlying static type from dynamicType For example returns FLOAT if given type is DYNAMIC_FLOAT.

Parameters:
dynamicType - a dynamic type
Returns:
the underlying static type
Throws:
java.lang.IllegalArgumentException - if dynamicType is not dynamic

getDynamicType

public static AttributeType getDynamicType(AttributeType staticType)
Returns the corresponding dynamic type from staticType For example returns DYNAMIC_FLOAT if given type is FLOAT.

Parameters:
staticType - a static type
Returns:
the corresponding dynamic type
Throws:
java.lang.IllegalArgumentException - if staticType is not static

Gephi Toolkit Javadoc