- java.lang.Object
-
- com.pervasive.datarush.schema.SchemaBuilder
-
public class SchemaBuilder extends Object
Collection of static methods helpful in building schemas (TextRecordinstances).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSchemaBuilder.SchemaFieldAn internal class used to transform schemas to/from JSON.static classSchemaBuilder.SchemaFieldTypeEnumeration of schema field types
-
Field Summary
Fields Modifier and Type Field Description static TextTypes.StringConversionNULLABLE_RAWNo trimming, empty string is treated as null.static TextTypes.StringConversionNULLABLE_TRIMMEDTrim white space and treat empty strings as null.static TextTypes.StringConversionRAWRaw string conversion, no trimming and empty strings are not null.static TextTypes.StringConversionTRIMMEDTrim white space, empty strings passed through.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SchemaBuilder.SchemaFieldBINARY(String fieldName)Create a binary field.static SchemaBuilder.SchemaFieldBOOLEAN(String fieldName)Create a default boolean field.static SchemaBuilder.SchemaFieldBOOLEAN(String fieldName, String trueValue, String falseValue)Create a boolean field with defined values for true/false.static SchemaBuilder.SchemaFieldBOOLEAN(String fieldName, String trueValue, String falseValue, boolean caseSensitive)Create a boolean field with defined values for true/false.static SchemaBuilder.SchemaFieldCHAR(String fieldName)Create a default char field.static SchemaBuilder.SchemaFieldDATE(String fieldName)Create a date field using ISO defined format.static SchemaBuilder.SchemaFieldDATE(String fieldName, String format)Create a date field using the defined format or pattern.static TextConversionDefaultsdefaults(TextTypes.StringConversion behavior)Create default settings for a schema.static TextConversionDefaultsdefaults(String nullIndicator)Create default settings for a schema.static TextConversionDefaultsdefaults(String nullIndicator, TextTypes.StringConversion behavior)Create default settings for a schema.static TextRecorddefine(SchemaBuilder.SchemaField... fields)Define (create) a new schema object.static TextRecorddefine(TextConversionDefaults defaults, SchemaBuilder.SchemaField... fields)Define (create) a new schema object.static TextRecorddefine(TextTypes.StringConversion conversion, SchemaBuilder.SchemaField... fields)Define (create) a new schema object.static TextRecorddefine(String nullIndicator, SchemaBuilder.SchemaField... fields)Define (create) a new schema object.static SchemaBuilder.SchemaFieldDOUBLE(String fieldName)Create a double field.static SchemaBuilder.SchemaFieldDOUBLE(String fieldName, String format)Create a double field using the defined format or pattern.static SchemaBuilder.SchemaFieldDURATION(String fieldName)Create a duration field.static SchemaBuilder.SchemaFieldDURATION(String fieldName, String format)Create a duration field using the defined format or pattern.static SchemaBuilder.SchemaFieldFLOAT(String fieldName)Create a float field.static SchemaBuilder.SchemaFieldFLOAT(String fieldName, String format)Create a float field using the defined format or pattern.static SchemaBuilderfromJSON(String jsonText)Create a schema builder from it's JSON representation.static SchemaBuilder.SchemaFieldINT(String fieldName)Create an integer field.static SchemaBuilder.SchemaFieldINT(String fieldName, String format)Create an integer field using the defined format or pattern.static SchemaBuilder.SchemaFieldIP4ADDRESS(String fieldName)Create an ip4address field.static SchemaBuilder.SchemaFieldIP6ADDRESS(String fieldName)Create an ip6address field.static SchemaBuilder.SchemaFieldLONG(String fieldName)Create a long field.static SchemaBuilder.SchemaFieldLONG(String fieldName, String format)Create a long field using the defined format or pattern.static SchemaBuilder.SchemaFieldMONEY(String fieldName)Create a money field.static SchemaBuilder.SchemaFieldMONEY(String fieldName, String format)Create a money field using the defined format or pattern.static SchemaBuildernewInstance(SchemaBuilder.SchemaField... fields)Create a new schema builder reference.static SchemaBuildernewInstance(TextConversionDefaults defaults, SchemaBuilder.SchemaField... fields)Create a new schema builder reference.static SchemaBuildernewInstance(TextTypes.StringConversion conversion, SchemaBuilder.SchemaField... fields)Create a new schema builder reference.static SchemaBuildernewInstance(String nullIndicator, SchemaBuilder.SchemaField... fields)Create a new schema builder reference.static SchemaBuilder.SchemaFieldNUMERIC(String fieldName)Create a numeric field.static SchemaBuilder.SchemaFieldNUMERIC(String fieldName, String format)Create a numeric field using the defined format or pattern.static SchemaBuilder.SchemaFieldOBJECT(String fieldName)Create an object field.static SchemaBuilder.SchemaFieldPERIOD(String fieldName)Create a period field.static SchemaBuilder.SchemaFieldPERIOD(String fieldName, String format)Create a period field using the defined format or pattern.static SchemaBuilder.SchemaFieldSTRING(String fieldName)Create a string field.static SchemaBuilder.SchemaFieldSTRING(String fieldName, String... domain)Create a string field.static SchemaBuilder.SchemaFieldSTRING(String fieldName, List<String> domain)Create a string field.static SchemaBuilder.SchemaFieldTIMEOFDAY(String fieldName)Create a timeofday field using ISO defined format.static SchemaBuilder.SchemaFieldTIMEOFDAY(String fieldName, String format)Create a timeofday field using the defined format or pattern.static SchemaBuilder.SchemaFieldTIMESTAMP(String fieldName)Create a timestamp field using ISO defined format.static SchemaBuilder.SchemaFieldTIMESTAMP(String fieldName, String format)Create a timestamp field using the defined format or pattern.StringtoJSON()Convert the defined schema into JSON format for serialization purposes.TextRecordtoTextRecord()Convert the defined schema into aTextRecordthat is usable by text readers.
-
-
-
Field Detail
-
RAW
public static TextTypes.StringConversion RAW
Raw string conversion, no trimming and empty strings are not null.
-
NULLABLE_RAW
public static TextTypes.StringConversion NULLABLE_RAW
No trimming, empty string is treated as null.
-
TRIMMED
public static TextTypes.StringConversion TRIMMED
Trim white space, empty strings passed through.
-
NULLABLE_TRIMMED
public static TextTypes.StringConversion NULLABLE_TRIMMED
Trim white space and treat empty strings as null.
-
-
Method Detail
-
BOOLEAN
public static SchemaBuilder.SchemaField BOOLEAN(String fieldName)
Create a default boolean field.- Parameters:
fieldName- name of the field- Returns:
- boolean field
-
BOOLEAN
public static SchemaBuilder.SchemaField BOOLEAN(String fieldName, String trueValue, String falseValue)
Create a boolean field with defined values for true/false.- Parameters:
fieldName- name of the fieldtrueValue- value representing truefalseValue- value representing false- Returns:
- boolean field
-
BOOLEAN
public static SchemaBuilder.SchemaField BOOLEAN(String fieldName, String trueValue, String falseValue, boolean caseSensitive)
Create a boolean field with defined values for true/false.- Parameters:
fieldName- name of the fieldtrueValue- value representing truefalseValue- value representing falsecaseSensitive- if true, values are case sensitive; case insensitive otherwise- Returns:
- boolean field
-
BINARY
public static SchemaBuilder.SchemaField BINARY(String fieldName)
Create a binary field.- Parameters:
fieldName- name of the field- Returns:
- binary field
-
CHAR
public static SchemaBuilder.SchemaField CHAR(String fieldName)
Create a default char field.- Parameters:
fieldName- name of the field- Returns:
- char field
-
DATE
public static SchemaBuilder.SchemaField DATE(String fieldName)
Create a date field using ISO defined format.- Parameters:
fieldName- name of the field- Returns:
- date field
-
DATE
public static SchemaBuilder.SchemaField DATE(String fieldName, String format)
Create a date field using the defined format or pattern. The pattern syntax is defined inDateFormat.- Parameters:
fieldName- name of the fieldformat- format pattern- Returns:
- date field
-
DOUBLE
public static SchemaBuilder.SchemaField DOUBLE(String fieldName)
Create a double field.- Parameters:
fieldName- name of the field- Returns:
- double field
-
DOUBLE
public static SchemaBuilder.SchemaField DOUBLE(String fieldName, String format)
Create a double field using the defined format or pattern. The pattern syntax is defined inDecimalFormat.- Parameters:
fieldName- name of the fieldformat- format pattern- Returns:
- double field
-
DURATION
public static SchemaBuilder.SchemaField DURATION(String fieldName)
Create a duration field.- Parameters:
fieldName- name of the field- Returns:
- duration field
-
DURATION
public static SchemaBuilder.SchemaField DURATION(String fieldName, String format)
Create a duration field using the defined format or pattern. The pattern syntax is defined inIntervalFormatting.- Parameters:
fieldName- name of the fieldformat- format pattern- Returns:
- duration field
-
FLOAT
public static SchemaBuilder.SchemaField FLOAT(String fieldName)
Create a float field.- Parameters:
fieldName- name of the field- Returns:
- float field
-
FLOAT
public static SchemaBuilder.SchemaField FLOAT(String fieldName, String format)
Create a float field using the defined format or pattern. The pattern syntax is defined inDecimalFormat.- Parameters:
fieldName- name of the fieldformat- format pattern- Returns:
- float field
-
INT
public static SchemaBuilder.SchemaField INT(String fieldName)
Create an integer field.- Parameters:
fieldName- name of the field- Returns:
- integer field
-
INT
public static SchemaBuilder.SchemaField INT(String fieldName, String format)
Create an integer field using the defined format or pattern. The pattern syntax is defined inDecimalFormat.- Parameters:
fieldName- name of the fieldformat- format pattern- Returns:
- integer field
-
IP4ADDRESS
public static SchemaBuilder.SchemaField IP4ADDRESS(String fieldName)
Create an ip4address field.- Parameters:
fieldName- name of the field- Returns:
- ip4address field
-
IP6ADDRESS
public static SchemaBuilder.SchemaField IP6ADDRESS(String fieldName)
Create an ip6address field.- Parameters:
fieldName- name of the field- Returns:
- ip6address field
-
LONG
public static SchemaBuilder.SchemaField LONG(String fieldName)
Create a long field.- Parameters:
fieldName- name of the field- Returns:
- long field
-
LONG
public static SchemaBuilder.SchemaField LONG(String fieldName, String format)
Create a long field using the defined format or pattern. The pattern syntax is defined inDecimalFormat.- Parameters:
fieldName- name of the fieldformat- format pattern- Returns:
- long field
-
MONEY
public static SchemaBuilder.SchemaField MONEY(String fieldName)
Create a money field.- Parameters:
fieldName- name of the field- Returns:
- money field
-
MONEY
public static SchemaBuilder.SchemaField MONEY(String fieldName, String format)
Create a money field using the defined format or pattern. The pattern syntax is defined inDecimalFormat.- Parameters:
fieldName- name of the fieldformat- format pattern- Returns:
- money field
-
NUMERIC
public static SchemaBuilder.SchemaField NUMERIC(String fieldName)
Create a numeric field.- Parameters:
fieldName- name of the field- Returns:
- numeric field
-
NUMERIC
public static SchemaBuilder.SchemaField NUMERIC(String fieldName, String format)
Create a numeric field using the defined format or pattern. The pattern syntax is defined inDecimalFormat.- Parameters:
fieldName- name of the fieldformat- format pattern- Returns:
- numeric field
-
PERIOD
public static SchemaBuilder.SchemaField PERIOD(String fieldName)
Create a period field.- Parameters:
fieldName- name of the field- Returns:
- period field
-
PERIOD
public static SchemaBuilder.SchemaField PERIOD(String fieldName, String format)
Create a period field using the defined format or pattern. The pattern syntax is defined inIntervalFormatting.- Parameters:
fieldName- name of the fieldformat- format pattern- Returns:
- period field
-
STRING
public static SchemaBuilder.SchemaField STRING(String fieldName)
Create a string field.- Parameters:
fieldName- name of the field- Returns:
- string field
-
OBJECT
public static SchemaBuilder.SchemaField OBJECT(String fieldName)
Create an object field.- Parameters:
fieldName- name of the field- Returns:
- object field
-
STRING
public static SchemaBuilder.SchemaField STRING(String fieldName, String... domain)
Create a string field.- Parameters:
fieldName- name of the fielddomain- the domain of the field- Returns:
- string field
-
STRING
public static SchemaBuilder.SchemaField STRING(String fieldName, List<String> domain)
Create a string field.- Parameters:
fieldName- name of the fielddomain- the domain of the field- Returns:
- string field
-
TIMEOFDAY
public static SchemaBuilder.SchemaField TIMEOFDAY(String fieldName)
Create a timeofday field using ISO defined format.- Parameters:
fieldName- name of the field- Returns:
- timeofday field
-
TIMEOFDAY
public static SchemaBuilder.SchemaField TIMEOFDAY(String fieldName, String format)
Create a timeofday field using the defined format or pattern. The pattern syntax is defined inDateFormat- Parameters:
fieldName- name of the fieldformat- format pattern- Returns:
- timeofday field
-
TIMESTAMP
public static SchemaBuilder.SchemaField TIMESTAMP(String fieldName)
Create a timestamp field using ISO defined format.- Parameters:
fieldName- name of the field- Returns:
- timestamp field
-
TIMESTAMP
public static SchemaBuilder.SchemaField TIMESTAMP(String fieldName, String format)
Create a timestamp field using the defined format or pattern. The pattern syntax is defined inDateFormat.- Parameters:
fieldName- name of the fieldformat- format pattern- Returns:
- timestamp field
-
define
public static TextRecord define(String nullIndicator, SchemaBuilder.SchemaField... fields)
Define (create) a new schema object.- Parameters:
nullIndicator- string representing a value is not available (null)fields- field definitions to add to the schema (order is important)- Returns:
- new schema object
-
define
public static TextRecord define(TextTypes.StringConversion conversion, SchemaBuilder.SchemaField... fields)
Define (create) a new schema object.- Parameters:
conversion- enumeration defining how to convert fields of type stringfields- field definitions to add to the schema (order is important)- Returns:
- new schema object
-
define
public static TextRecord define(TextConversionDefaults defaults, SchemaBuilder.SchemaField... fields)
Define (create) a new schema object.- Parameters:
defaults- default schema settings for the null indicator and the string conversion settingfields- field definitions to add to the schema (order is important)- Returns:
- new schema object
-
define
public static TextRecord define(SchemaBuilder.SchemaField... fields)
Define (create) a new schema object. Use default values for the default schema settings.- Parameters:
fields- field definitions to add to the schema (order is important)- Returns:
- new schema object
-
newInstance
public static SchemaBuilder newInstance(String nullIndicator, SchemaBuilder.SchemaField... fields)
Create a new schema builder reference.- Parameters:
nullIndicator- string representing a value is not available (null)fields- field definitions to add to the schema (order is important)- Returns:
- new schema builder object
-
newInstance
public static SchemaBuilder newInstance(TextTypes.StringConversion conversion, SchemaBuilder.SchemaField... fields)
Create a new schema builder reference.- Parameters:
conversion- enumeration defining how to convert fields of type stringfields- field definitions to add to the schema (order is important)- Returns:
- new schema builder object
-
newInstance
public static SchemaBuilder newInstance(TextConversionDefaults defaults, SchemaBuilder.SchemaField... fields)
Create a new schema builder reference.- Parameters:
defaults- default schema settings for the null indicator and the string conversion settingfields- field definitions to add to the schema (order is important)- Returns:
- new schema builder object
-
newInstance
public static SchemaBuilder newInstance(SchemaBuilder.SchemaField... fields)
Create a new schema builder reference. Use default values for the default schema settings.- Parameters:
fields- field definitions to add to the schema (order is important)- Returns:
- new schema builder object
-
fromJSON
public static SchemaBuilder fromJSON(String jsonText)
Create a schema builder from it's JSON representation.- Parameters:
jsonText- text containing the JSON representation of a schema builder- Returns:
- new schema builder reference
- Throws:
IllegalArgumentException- thrown if the given text cannot be parsed by the JSON parser
-
defaults
public static TextConversionDefaults defaults(String nullIndicator)
Create default settings for a schema.- Parameters:
nullIndicator- string representing a value is not available (null)- Returns:
- conversion defaults
-
defaults
public static TextConversionDefaults defaults(TextTypes.StringConversion behavior)
Create default settings for a schema.- Parameters:
behavior- enumeration defining how to convert fields of type string- Returns:
- conversion defaults
-
defaults
public static TextConversionDefaults defaults(String nullIndicator, TextTypes.StringConversion behavior)
Create default settings for a schema.- Parameters:
nullIndicator- string representing a value is not available (null)behavior- enumeration defining how to convert fields of type string- Returns:
- conversion defaults
-
toTextRecord
public TextRecord toTextRecord()
Convert the defined schema into aTextRecordthat is usable by text readers.- Returns:
- the generated text record
-
toJSON
public String toJSON()
Convert the defined schema into JSON format for serialization purposes.- Returns:
- a string containing the schema in JSON format
-
-