- java.lang.Object
-
- com.pervasive.datarush.types.TokenTypeConstant
-
public class TokenTypeConstant extends Object
A collection of constant descriptors and utilities for the supported token types. Included are a number of convenience methods for use in statically constructing record types. Using these methods with static imports provides a concise and clear way to describe schemas. An example of this is described in the documentation forrecord(Field...)
.
-
-
Field Summary
Fields Modifier and Type Field Description static ScalarTokenType
BINARY
A description of the binary token type.static ScalarTokenType
BOOLEAN
A description of the boolean token type.static ScalarTokenType
CHAR
A description of the character token type.static ScalarTokenType
DATE
A description of the date token type.static ScalarTokenType
DOUBLE
A description of the double token type.static ScalarTokenType
DURATION
A description of the duration token type.static ScalarTokenType
FLOAT
A description of the float token type.static GenericTokenType
GENERIC
An abstract type representing any type.static ScalarTokenType
INT
A description of the integer token type.static ScalarTokenType
IP4ADDRESS
A description of the ip4address token type.static ScalarTokenType
IP6ADDRESS
A description of the ip6address token type.static ScalarTokenType
LONG
A description of the long token type.static ScalarTokenType
MONEY
A description of the money token type.static ScalarTokenType
NULL
A description of the null token type.static ScalarTokenType
NUMERIC
A description of the numeric token type.static ScalarTokenType
PERIOD
A description of the period token type.static RecordTokenType
RECORD
An abstract type representing any record type.static ScalarTokenType
SCALAR
An abstract type representing any scalar type.static ScalarTokenType
STRING
A description of the string token type.static ScalarTokenType
TIME
A description of the time token type.static ScalarTokenType
TIMESTAMP
A description of the timestamp token type.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Field
BINARY(String name)
Constructs a binary typed field with the given name.static Field
BOOLEAN(String name)
Constructs a boolean typed field with the given name.static Field
CHAR(String name)
Constructs a character typed field with the given name.static Field
DATE(String name)
Constructs a date typed field with the given name.static Field
domain(Field field, FieldDomain domain)
Returns a new field object with the same type and name as the original, but with the domain set to the given value.static Field
DOMAIN(Field field, String... values)
Creates a field with the domain set to the given valuesstatic FieldDomain
DOMAIN(String... values)
Creates a field domain with the domain set to the given valuesstatic Field
DOUBLE(String name)
Constructs a double typed field with the given name.static Field
DURATION(String name)
Constructs a duration typed field with the given name.static <O> ObjectTokenType<O>
EXTENDED(Class<O> type, String extendedType)
Gets a description of an extended object token type.static Field
field(ScalarTokenType type, String name)
Constructs a field with the given name of the specified type.static Field
FLOAT(String name)
Constructs a float typed field with the given name.static ScalarTokenType
getScalar(String name)
Gets the constant scalar token type descriptor for the specified name.static Field
INT(String name)
Constructs a integer typed field with the given name.static Field
IP4ADDRESS(String name)
Constructs a ip4address typed field with the given name.static Field
IP6ADDRESS(String name)
Constructs a ip6address typed field with the given name.static Field
LONG(String name)
Constructs a long typed field with the given name.static Field
MONEY(String name)
Constructs a money typed field with the given name.static Field
NUMERIC(String name)
Constructs a numeric typed field with the given name.static <O> ObjectTokenType<O>
OBJECT(Class<O> type)
Gets a description of an object token type.static <O> Field
OBJECT(Class<O> type, String name)
Constructs an object typed field with the given name.static <O> ObjectTokenType<O>
PARAMETERIZED(Class<O> type, String extendedType, Type... genericParams)
Gets a description of an parameterized object token type.static <O> Field
PARAMETERIZED(Class<O> type, String extendedType, Type[] genericParams, String name)
Constructs an object typed field with the given name.static Field
PERIOD(String name)
Constructs a period typed field with the given name.static RecordTokenType
record(Field... fields)
Constructs a record type descriptor with the given fields.static ScalarTokenType[]
scalars()
Gets the descriptors for all supported scalar token types.static RecordTokenType
sparseRecord(Field... fields)
Constructs a record type descriptor with the given fields.static Field
STRING(String name)
Constructs a string typed field with the given name.static Field
STRING(String name, String... values)
Constructs a string typed field with the given name.static Field
STRING(String name, List<String> values)
Constructs a string typed field with the given name.static Field
TIME(String name)
Constructs a time typed field with the given name.static Field
TIMESTAMP(String name)
Constructs a timestamp typed field with the given name.static TokenType[]
values()
Gets the descriptors for all supported token types.
-
-
-
Field Detail
-
GENERIC
public static final GenericTokenType GENERIC
An abstract type representing any type. It is assignable from any type, but is not equal to any. This type can be used as a placeholder for a more concrete type.
-
SCALAR
public static final ScalarTokenType SCALAR
An abstract type representing any scalar type. It is assignable from any scalar type, but is not equal to any. This type can be used as a placeholder for a more concrete scalar type.
-
BINARY
public static final ScalarTokenType BINARY
A description of the binary token type.Binary tokens are a variable length type, corresponding to Java
byte[]
.
-
BOOLEAN
public static final ScalarTokenType BOOLEAN
A description of the boolean token type.Boolean tokens correspond to the Java
boolean
primitive type.
-
CHAR
public static final ScalarTokenType CHAR
A description of the character token type.Character tokens correspond to the Java
char
primitive type.
-
DURATION
public static final ScalarTokenType DURATION
A description of the duration token type.Duration tokens correspond to the Java
Duration
type.
-
DATE
public static final ScalarTokenType DATE
A description of the date token type. A date represents a specific calendar date: a day, month, and year.Date tokens correspond to the JDBC
Date
type.
-
IP4ADDRESS
public static final ScalarTokenType IP4ADDRESS
A description of the ip4address token type. An ip4address represents an IPv4 address.Ip4address tokens correspond to the
Inet4Address
type.
-
IP6ADDRESS
public static final ScalarTokenType IP6ADDRESS
A description of the ip6address token type. An ip6address represents an IPv6 address.Ip4address tokens correspond to the
Inet4Address
type.
-
INT
public static final ScalarTokenType INT
A description of the integer token type.Integer tokens correspond to the Java
int
primitive type.
-
LONG
public static final ScalarTokenType LONG
A description of the long token type.Long tokens correspond to the Java
long
primitive type.
-
MONEY
public static final ScalarTokenType MONEY
A description of the money token type.money tokens are represented as a decimal with a scale of 2.
-
NULL
public static final ScalarTokenType NULL
A description of the null token type.A null token type cannot contain any data. It is assignable to any other scalar type.
-
NUMERIC
public static final ScalarTokenType NUMERIC
A description of the numeric token type.Numeric data is represented as
BigDecimal
objects. The numeric data type can be useful to represent floating point data that cannot tolerate possible rounding errors encountered with Javadouble
orfloat
primitive data types.
-
FLOAT
public static final ScalarTokenType FLOAT
A description of the float token type.Float tokens correspond to the Java
float
primitive type.
-
DOUBLE
public static final ScalarTokenType DOUBLE
A description of the double token type.Double tokens correspond to the Java
double
primitive type.
-
PERIOD
public static final ScalarTokenType PERIOD
A description of the period token type.Period tokens correspond to the Java
Period
type.
-
STRING
public static final ScalarTokenType STRING
A description of the string token type.String tokens are a variable length type, corresponding to
String
.
-
TIME
public static final ScalarTokenType TIME
A description of the time token type. A time represents an specific time of day (hour, minute, second) with millisecond precision.
-
TIMESTAMP
public static final ScalarTokenType TIMESTAMP
A description of the timestamp token type. A timestamp represents an instance in time, containing both date (day, month, year) and time information with nanosecond precision.Timestamp tokens correspond to the JDBC
Timestamp
type.
-
RECORD
public static final RecordTokenType RECORD
An abstract type representing any record type. It is assignable from any record type, but is not equal to any. This type can be used as a placeholder for a more concrete record type.To construct a concrete record token type, use the
record(Field...)
method orRecordTokenTypeBuilder
class.
-
-
Method Detail
-
field
public static Field field(ScalarTokenType type, String name)
Constructs a field with the given name of the specified type.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
type
- the token type of the fieldname
- the name of the field- Returns:
- a field of the specified type with the given name.
-
BINARY
public static Field BINARY(String name)
Constructs a binary typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of binary type with the given name.
-
BOOLEAN
public static Field BOOLEAN(String name)
Constructs a boolean typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of boolean type with the given name.
-
CHAR
public static Field CHAR(String name)
Constructs a character typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of character type with the given name.
-
DURATION
public static Field DURATION(String name)
Constructs a duration typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of duration type with the given name.
-
DATE
public static Field DATE(String name)
Constructs a date typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of date type with the given name.
-
IP4ADDRESS
public static Field IP4ADDRESS(String name)
Constructs a ip4address typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of ip4address type with the given name.
-
IP6ADDRESS
public static Field IP6ADDRESS(String name)
Constructs a ip6address typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of ip6address type with the given name.
-
INT
public static Field INT(String name)
Constructs a integer typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of integer type with the given name.
-
LONG
public static Field LONG(String name)
Constructs a long typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of long type with the given name.
-
MONEY
public static Field MONEY(String name)
Constructs a money typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of money type with the given name.
-
NUMERIC
public static Field NUMERIC(String name)
Constructs a numeric typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of numeric type with the given name.
-
OBJECT
public static <O> ObjectTokenType<O> OBJECT(Class<O> type)
Gets a description of an object token type.Object tokens are of indeterminate length, corresponding to Java
Object
.- Type Parameters:
O
- the object type- Parameters:
type
- theClass
object for the type of Java objects the token type describes- Returns:
- an
ObjectTokenType
for the specified class.
-
EXTENDED
public static <O> ObjectTokenType<O> EXTENDED(Class<O> type, String extendedType)
Gets a description of an extended object token type.Object tokens are of indeterminate length, corresponding to Java
Object
.- Type Parameters:
O
- the object type- Parameters:
type
- theClass
object for the type of Java objects the token type describesextendedType
- the extended type if for the type- Returns:
- an
ObjectTokenType
for the specified class.
-
PARAMETERIZED
public static <O> ObjectTokenType<O> PARAMETERIZED(Class<O> type, String extendedType, Type... genericParams)
Gets a description of an parameterized object token type.Object tokens are of indeterminate length, corresponding to Java
Object
.- Type Parameters:
O
- the object type- Parameters:
type
- theClass
object for the type of Java objects the token type describesextendedType
- the extended type if for the typegenericParams
- the orderedClass
objects for the generic type parameters of the object token type- Returns:
- an
ObjectTokenType
for the specified class.
-
OBJECT
public static <O> Field OBJECT(Class<O> type, String name)
Constructs an object typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Type Parameters:
O
- the object type- Parameters:
type
- theClass
object for the type of the Java objects in the fieldname
- the name of the field- Returns:
- a field of the appropriate object type with the given name.
-
PARAMETERIZED
public static <O> Field PARAMETERIZED(Class<O> type, String extendedType, Type[] genericParams, String name)
Constructs an object typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Type Parameters:
O
- the object type- Parameters:
type
- theClass
object for the type of the Java objects in the fieldname
- the name of the field- Returns:
- a field of the appropriate object type with the given name.
-
FLOAT
public static Field FLOAT(String name)
Constructs a float typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of float type with the given name.
-
DOUBLE
public static Field DOUBLE(String name)
Constructs a double typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of double type with the given name.
-
PERIOD
public static Field PERIOD(String name)
Constructs a period typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of period type with the given name.
-
STRING
public static Field STRING(String name)
Constructs a string typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of string type with the given name.
-
STRING
public static Field STRING(String name, String... values)
Constructs a string typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the fieldvalues
- the domain of the string field- Returns:
- a field of string type with the given name.
-
STRING
public static Field STRING(String name, List<String> values)
Constructs a string typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the fieldvalues
- the domain of the string field- Returns:
- a field of string type with the given name.
-
TIME
public static Field TIME(String name)
Constructs a time typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of time type with the given name.
-
TIMESTAMP
public static Field TIMESTAMP(String name)
Constructs a timestamp typed field with the given name.This method is used in conjunction with
record(Field...)
to construct record types.- Parameters:
name
- the name of the field- Returns:
- a field of timestamp type with the given name.
-
record
public static RecordTokenType record(Field... fields)
Constructs a record type descriptor with the given fields.This method, in conjunction with the
Field
factory methods in this class, provides a convenient and concise way of statically specifying record type schemas. An example of this follows:import static com.pervasive.tokens.type.TokenTypeConstant.RECORD; import static com.pervasive.tokens.type.TokenTypeConstant.INT; import static com.pervasive.tokens.type.TokenTypeConstant.STRING; import static com.pervasive.tokens.type.TokenTypeConstant.TIMESTAMP; public static final RecordTokenType ORDER_RECORD= RECORD(INT("orderId"), STRING("customer"), TIMESTAMP("orderDate"));
This defines a record type for a hypothetical order processing system. Each record contains an integer order ID, a string with customer name, and a timestamp with the order date.If no fields are providide, this yields the abstract record type.
- Parameters:
fields
- the fields describing the schema of this record type- Returns:
- a record type descriptor for the given schema
-
domain
public static Field domain(Field field, FieldDomain domain)
Returns a new field object with the same type and name as the original, but with the domain set to the given value.- Parameters:
field
- The fielddomain
- The value domain- Returns:
- a new field with the domain as specified
-
DOMAIN
public static Field DOMAIN(Field field, String... values)
Creates a field with the domain set to the given values- Parameters:
field
- the field. must be a string fieldvalues
- the string values in the domain- Returns:
- a field the domain set to the given values
- Throws:
IllegalArgumentException
- if the field is not a string field
-
DOMAIN
public static FieldDomain DOMAIN(String... values)
Creates a field domain with the domain set to the given values- Parameters:
values
- the string values in the domain- Returns:
- a field domain
-
sparseRecord
public static RecordTokenType sparseRecord(Field... fields)
Constructs a record type descriptor with the given fields.This method, in conjunction with the
Field
factory methods in this class, provides a convenient and concise way of statically specifying record type schemas. An example of this follows:import static com.pervasive.tokens.type.TokenTypeConstant.RECORD; import static com.pervasive.tokens.type.TokenTypeConstant.INT; import static com.pervasive.tokens.type.TokenTypeConstant.STRING; import static com.pervasive.tokens.type.TokenTypeConstant.TIMESTAMP; public static final RecordTokenType ORDER_RECORD= RECORD(INT("orderId"), STRING("customer"), TIMESTAMP("orderDate"), RECORD("lineItems", INT("itemId"), INT("count")));
This defines a nested record type for a hypothetical order processing system. Each record contains an integer order ID, a string with customer name, a timestamp with the order date, and nested line items, each with an integer count and item ID.- Parameters:
fields
- the fields describing the schema of this record type- Returns:
- a record type descriptor for the given schema
-
values
public static TokenType[] values()
Gets the descriptors for all supported token types.- Returns:
- descriptors for all types
-
scalars
public static ScalarTokenType[] scalars()
Gets the descriptors for all supported scalar token types.- Returns:
- descriptors for all scalar types
-
getScalar
public static ScalarTokenType getScalar(String name)
Gets the constant scalar token type descriptor for the specified name.- Parameters:
name
- the scalar type for which to get the type descriptor- Returns:
- the constant descriptor for the scalar type
-
-