Package com.streambase.sb
Class Schema.Field
java.lang.Object
com.streambase.sb.Schema.Field
- All Implemented Interfaces:
Serializable
- Enclosing class:
- Schema
Information (name, type, and optionally size) about a field in a Schema.
A field can be looked up within a schema in three ways:
- By index: By the zero-based ordinal position of the field within the schema
- By simple name: By the name of the field itself (e.g., "myint")
- By path name: By a dot-separated list of names that define a path through a set of nested schemas that arise through the use of fields of type Tuple (e.g., "mynestedtuple.myint").
A Field object can be used to obtain the value of a field in a tuple. However, there are rules that must be obeyed in doing so. For example, one must obtain the Field object from a Schema object that describes the schema of the tuple (i.e., as opposed to directly from a Field constructor).
See the "client" StreamBase sample (streambase-install-dir/sample/client) for examples of proper use of Field objects.
Note: Serializations of instances of this class that are created (e.g., by using
ObjectOutputStream
) in one version of StreamBase in general will not be
deserializable in any other version of StreamBase.
- See Also:
-
Constructor Summary
ConstructorDescriptionField
(Schema.Field field) Construct a Field from an existing Field.Field
(String name, CompleteDataType completeType, com.streambase.sb.util.Location loc) ConstructorDeprecated.Deprecated.UseField(String, CompleteDataType)
instead with new Schema(name, CompleteDataType.forTuple(s)), orSchema.createTupleField(String, Schema)
Field
(String name, Schema.Field field) Construct a Field from an existing Field, giving the new field a specified name -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkType
(CompleteDataType dataType) Check to make sure that the given type is the same as the type of this Fieldvoid
Deprecated.boolean
equalsNoCapture
(Schema.Field other) Compare non-capture fieldsReturn the CompleteDataType of the Field(package private) Schema
Returns the schema of which this field is a part.Return the DataType of the FieldReturns the description currently set for this field.Return the element type for this field.(package private) List<Schema.Field>
Returns a list of Field's for navigating from this field's containing schema to the subtuple containing this field.int
getIndex()
Return the index of this field within the Schemacom.streambase.sb.util.Location
Get locationgetName()
Return the name of the Field.getNestedField
(String fieldPathName) Return a field that identifies a field in a nested tuple field.Return an array of fields, each of which identifies a field in a nested tuple field.Return the schema for this field.Return the last (which might be the only) segment of this Fieldint
getSize()
Return the size of the field (in bytes) without any header information.(package private) static Schema.Field
sanitizedField
(int index, CompleteDataType type) Create a sanitized field from the parameters, using cached string name if possible and bypassing identifier validation.void
setDescription
(String description) Sets this field's description.(package private) Schema.Field
Return a Field like this Field except with any field path stripped out.toString()
Return a String representation of this field.
-
Constructor Details
-
Field
Constructor- Parameters:
name
- Field namecompleteType
- Field data typeloc
- Source location
-
Field
Construct a Field from an existing Field.- Parameters:
field
- Field to copy data from
-
Field
Construct a Field from an existing Field, giving the new field a specified name- Parameters:
name
- The name of the fieldfield
- Field to copy data from
-
Field
Deprecated.UseSchema.createField(DataType, String)
insteadConstruct a Field of a specified type, giving the new field a specified name.- Parameters:
name
- The name of the FielddataType
- The DataType of the Field- Throws:
IllegalArgumentException
- if dataType requires a schema or an element type
-
Field
Deprecated.UseField(String, CompleteDataType)
instead with new Schema(name, CompleteDataType.forTuple(s)), orSchema.createTupleField(String, Schema)
Construct a Field of a specified type and bound to a specified schema, giving the new field a specified name.- Parameters:
name
- The name of the FielddataType
- The DataType of the Fields
- The schema of the Field- Throws:
IllegalArgumentException
- if dataType doesn't require a schema or requires an element type
-
-
Method Details
-
sanitizedField
Create a sanitized field from the parameters, using cached string name if possible and bypassing identifier validation.- Parameters:
index
- The index to create a field fortype
- The type of field- Returns:
- A newly created field
-
getLocation
public com.streambase.sb.util.Location getLocation()Get location- Returns:
- Location
-
equalsNoCapture
Compare non-capture fields- Parameters:
other
- Compare with this field- Returns:
- true if equal
-
checkType
Deprecated.Check to make sure that the given type is the same as the type of this Field- Parameters:
dataType
- The DataType to check- Throws:
TupleException
- thrown when the types do not match
-
checkType
Check to make sure that the given type is the same as the type of this Field- Parameters:
dataType
- The CompleteDataType to check- Throws:
TupleException
- thrown when the types do not match- Since:
- 6.3.7
-
getDataType
Return the DataType of the Field- Returns:
- DataType of the Field
-
getCompleteDataType
Return the CompleteDataType of the Field- Returns:
- CompleteDataType of the Field
- Since:
- 6.3
-
getName
Return the name of the Field. If the Field was constructed from a field path name, that path name is returned- Returns:
- The name of the Field
-
getShortName
Return the last (which might be the only) segment of this Field- Returns:
- the last segment of this Field
-
getIndex
public int getIndex()Return the index of this field within the Schema- Returns:
- The index of the field within the Schema
-
getSize
public int getSize()Return the size of the field (in bytes) without any header information.- Returns:
- The size of the Field in bytes (without header information)
-
getSchema
Return the schema for this field. Valid only if the type of the field is Tuple.- Returns:
- The schema, or null if field type is not Tuple
- Since:
- 6.0
-
getNestedField
Return a field that identifies a field in a nested tuple field. This method can be applied only to a field whose type is Tuple.- Parameters:
fieldPathName
- the path name to the desired nested tuple field- Returns:
- the field
- Throws:
TupleException
- if the field path name is invalid or this field isn't of type Tuple- Since:
- 6.0
-
getNestedFields
Return an array of fields, each of which identifies a field in a nested tuple field. This method can be applied only to a field whose type is Tuple.- Returns:
- the array of fields
- Throws:
TupleException
- if this field is not of type Tuple.- Since:
- 6.0
-
toString
Return a String representation of this field. -
getDescription
Returns the description currently set for this field. At runtime this method will returnnull
, and the description can only be guaranteed to have meaning during application development in the authoring environment.- Returns:
- this field's description String
null
when unknown
-
setDescription
Sets this field's description.- Parameters:
description
- the description String for this field
-
getContainingSchema
Schema getContainingSchema()Returns the schema of which this field is a part.- Returns:
- the schema
-
getFieldPath
List<Schema.Field> getFieldPath()Returns a list of Field's for navigating from this field's containing schema to the subtuple containing this field. If this field is "top-level" within the result is null.- Returns:
- a list of Field's or null.
-
toPathlessField
Schema.Field toPathlessField()Return a Field like this Field except with any field path stripped out. If this field has no path, it's what's returned.- Returns:
- a simple Field
-
getElementType
Return the element type for this field. Valid only if the type of the field is List.- Returns:
- The schema, or null if field type is not List
- Since:
- 6.3
-
Schema.createField(DataType, String)
instead