public class AttributeUtils extends Object
The attribute system is built with a set of supported column types. This class contains utilities to parse and convert supported types. It also contains utilities to manipulate primitive arrays (the preferred array type) and date/time types. Default time zone for parsing/printing dates is UTC.
Modifier and Type | Method and Description |
---|---|
static Class<? extends IntervalMap> |
getIntervalMapType(Class type)
Returns the dynamic timestamp map value type for the given type.
|
static Object |
getPrimitiveArray(Object[] array)
Returns the primitive array given a wrapped primitive array.
|
static Class |
getPrimitiveType(Class type)
Returns the primitive type for the given wrapped primitive.
|
static Class |
getStandardizedType(Class type)
Returns the standardized type for the given type class.
|
static Class |
getStaticType(Class<? extends TimeMap> type)
Returns the static type for the given time map type.
|
static Set<Class> |
getSupportedTypes()
Returns the set of types supported.
|
static Class<? extends TimestampMap> |
getTimestampMapType(Class type)
Returns the dynamic timestamp map value type for the given type.
|
static String |
getTypeName(Class type)
Returns the type name for the given type.
|
static boolean |
isArrayType(Class type)
Returns true if type is an array type.
|
static boolean |
isBooleanType(Class type)
Returns true if type is a boolean type
This can be true for static, arrays and dynamic types.
|
static boolean |
isCollectionType(Class type)
Returns true if type is a collection type.
|
static boolean |
isDynamicType(Class type)
Returns true if type is a dynamic type.
|
static boolean |
isEdgeColumn(Column colum)
Returns true if the given column is an edge column.
|
static boolean |
isMapType(Class type)
Returns true if type is a map type.
|
static boolean |
isNodeColumn(Column colum)
Returns true if the given column is a node column.
|
static boolean |
isNumberType(Class type)
Returns true if type is a number type.
|
static boolean |
isSimpleType(Class type)
Returns true if type is a simple type.
|
static boolean |
isStandardizedType(Class type)
Returns true if type is a standardized type.
|
static boolean |
isStringType(Class type)
Returns true if type is a string type
This can be true for static, arrays and dynamic types.
|
static boolean |
isSupported(Class type)
Returns true if type is a supported type.
|
static Object |
parse(String str,
Class typeClass)
Parses the given string using the type class provided and returns an
instance.
|
static Object |
parse(String str,
Class typeClass,
org.joda.time.DateTimeZone timeZone)
Parses the given string using the type class provided and returns an
instance.
|
static double |
parseDateTime(String dateTime)
Parses the given time and returns its milliseconds representation.
|
static double |
parseDateTime(String dateTime,
org.joda.time.DateTimeZone timeZone)
Parses the given time and returns its milliseconds representation.
|
static double |
parseDateTimeOrTimestamp(String timeStr)
Parses an ISO date with or without time or a timestamp (in milliseconds).
|
static double |
parseDateTimeOrTimestamp(String timeStr,
org.joda.time.DateTimeZone timeZone)
Parses an ISO date with or without time or a timestamp (in milliseconds).
|
static String |
print(Object value)
Returns the string representation of the given value.
|
static String |
print(Object value,
TimeFormat timeFormat,
org.joda.time.DateTimeZone timeZone)
Returns the string representation of the given value.
|
static String |
printArray(Object arr)
Returns the string representation of the given array.
|
static String |
printDate(double timestamp)
Returns the date's string representation of the given timestamp.
|
static String |
printDate(double timestamp,
org.joda.time.DateTimeZone timeZone)
Returns the date's string representation of the given timestamp.
|
static String |
printDateTime(double timestamp)
Returns the time's tring representation of the given timestamp.
|
static String |
printDateTime(double timestamp,
org.joda.time.DateTimeZone timeZone)
Returns the time's string representation of the given timestamp.
|
static String |
printTimestamp(double timestamp)
Returns the string representation of the given timestamp.
|
static String |
printTimestampInFormat(double timestamp,
TimeFormat timeFormat)
Returns the string representation of the given timestamp in the given
format.
|
static String |
printTimestampInFormat(double timestamp,
TimeFormat timeFormat,
org.joda.time.DateTimeZone timeZone)
Returns the string representation of the given timestamp in the given
format.
|
static Object |
standardizeValue(Object value)
Transform the given value instance in a standardized type if
necessary.
|
public static String print(Object value)
value
- valuepublic static String print(Object value, TimeFormat timeFormat, org.joda.time.DateTimeZone timeZone)
value
- valuetimeFormat
- time formattimeZone
- time zonepublic static Object parse(String str, Class typeClass, org.joda.time.DateTimeZone timeZone)
str
- string to parsetypeClass
- class of the desired typetimeZone
- time zone to use or null to use default time zone (UTC),
for dynamic types onlypublic static Object parse(String str, Class typeClass)
str
- string to parsetypeClass
- class of the desired typepublic static Class getPrimitiveType(Class type)
Example: Returns int.class given Integer.class
type
- type to get the primitive type frompublic static Object getPrimitiveArray(Object[] array)
Example: Returns int[] array given an Integer[] array
array
- wrapped primitive array instanceIllegalArgumentException
- Thrown if any of the array values is
nullpublic static Set<Class> getSupportedTypes()
public static boolean isSupported(Class type)
type
- type to test supportpublic static Class getStandardizedType(Class type)
For instance, getStandardizedType(int.class)
would return
Integer.class
.
type
- type to standardizepublic static boolean isStandardizedType(Class type)
Non standardized types are transformed into standardized types using
getStandardizedType(java.lang.Class)
.
type
- the type to testpublic static Class<? extends TimestampMap> getTimestampMapType(Class type)
type
- static typepublic static Class<? extends IntervalMap> getIntervalMapType(Class type)
type
- static typepublic static Class getStaticType(Class<? extends TimeMap> type)
type
- time map typepublic static Object standardizeValue(Object value)
This function transforms wrapped primitive arrays in primitive arrays.
value
- value to standardizepublic static boolean isNumberType(Class type)
This can be true for static, arrays and dynamic types.
type
- type to testpublic static boolean isStringType(Class type)
This can be true for static, arrays and dynamic types.
type
- type to testpublic static boolean isBooleanType(Class type)
This can be true for static, arrays and dynamic types.
type
- type to testpublic static boolean isDynamicType(Class type)
type
- type to testpublic static boolean isSimpleType(Class type)
Simple types are primitives, String and wrapper types (e.g. Integer).
type
- type to testpublic static boolean isArrayType(Class type)
type
- type to testpublic static boolean isCollectionType(Class type)
Collection types are either List or Set.
type
- type to testpublic static boolean isMapType(Class type)
Collection types implement the Map interface.
type
- type to testpublic static String getTypeName(Class type)
type
- type to get its namepublic static double parseDateTime(String dateTime, org.joda.time.DateTimeZone timeZone)
dateTime
- type to parsetimeZone
- time zone to use or null to use default time zone (UTC)public static double parseDateTime(String dateTime)
dateTime
- the type to parsepublic static double parseDateTimeOrTimestamp(String timeStr, org.joda.time.DateTimeZone timeZone)
timeStr
- Date or timestamp stringtimeZone
- Time zone to use or null to use default time zone (UTC)public static double parseDateTimeOrTimestamp(String timeStr)
timeStr
- Date or timestamp stringpublic static String printTimestamp(double timestamp)
timestamp
- the time, in millisecondspublic static String printDate(double timestamp, org.joda.time.DateTimeZone timeZone)
timestamp
- time, in millisecondstimeZone
- time zone to use or null to use default time zone (UTC)public static String printDate(double timestamp)
timestamp
- time, in millisecondspublic static String printDateTime(double timestamp, org.joda.time.DateTimeZone timeZone)
timestamp
- time, in millisecondstimeZone
- time zone to use or null to use default time zone (UTC)public static String printDateTime(double timestamp)
timestamp
- time, in millisecondspublic static String printTimestampInFormat(double timestamp, TimeFormat timeFormat, org.joda.time.DateTimeZone timeZone)
timestamp
- time, in millisecondstimeFormat
- time formattimeZone
- time zone to use or null to use default time zone (UTC).public static String printTimestampInFormat(double timestamp, TimeFormat timeFormat)
timestamp
- time, in millisecondstimeFormat
- time formatpublic static String printArray(Object arr)
parse(java.lang.String, java.lang.Class)
methodarr
- Input array. Can be an array of objects or primitives.public static boolean isNodeColumn(Column colum)
colum
- column to testpublic static boolean isEdgeColumn(Column colum)
colum
- column to testCopyright © 2007–2017 Gephi Consortium. All rights reserved.