Package com.streambase.sb
Class Schema.Field
- java.lang.Object
-
- com.streambase.sb.Schema.Field
-
- All Implemented Interfaces:
Serializable
- Enclosing class:
- Schema
public static class Schema.Field extends Object implements Serializable
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Field(Schema.Field field)
Construct a Field from an existing Field.Field(String name, CompleteDataType completeType, Location loc)
ConstructorField(String name, DataType dataType)
Deprecated.UseSchema.createField(DataType, String)
insteadField(String name, DataType dataType, Schema s)
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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
checkType(CompleteDataType dataType)
Check to make sure that the given type is the same as the type of this Fieldvoid
checkType(DataType dataType)
Deprecated.boolean
equalsNoCapture(Schema.Field other)
Compare non-capture fieldsCompleteDataType
getCompleteDataType()
Return the CompleteDataType of the FieldDataType
getDataType()
Return the DataType of the FieldString
getDescription()
Returns the description currently set for this field.CompleteDataType
getElementType()
Return the element type for this field.int
getIndex()
Return the index of this field within the SchemaLocation
getLocation()
Get locationString
getName()
Return the name of the Field.Schema.Field
getNestedField(String fieldPathName)
Return a field that identifies a field in a nested tuple field.Schema.Field[]
getNestedFields()
Return an array of fields, each of which identifies a field in a nested tuple field.Schema
getSchema()
Return the schema for this field.String
getShortName()
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.void
setDescription(String description)
Sets this field's description.String
toString()
Return a String representation of this field.
-
-
-
Constructor Detail
-
Field
public Field(String name, CompleteDataType completeType, Location loc)
Constructor- Parameters:
name
- Field namecompleteType
- Field data typeloc
- Source location
-
Field
public Field(Schema.Field field)
Construct a Field from an existing Field.- Parameters:
field
- Field to copy data from
-
Field
public Field(String name, Schema.Field 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 public Field(String name, DataType dataType)
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
public Field(String name, DataType dataType, Schema s)
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 Detail
-
getLocation
public Location getLocation()
Get location- Returns:
- Location
-
equalsNoCapture
public boolean equalsNoCapture(Schema.Field other)
Compare non-capture fields- Parameters:
other
- Compare with this field- Returns:
- true if equal
-
checkType
public void checkType(DataType dataType) throws TupleException
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
public void checkType(CompleteDataType dataType) throws TupleException
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
public DataType getDataType()
Return the DataType of the Field- Returns:
- DataType of the Field
-
getCompleteDataType
public CompleteDataType getCompleteDataType()
Return the CompleteDataType of the Field- Returns:
- CompleteDataType of the Field
- Since:
- 6.3
-
getName
public String 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
public String 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
public Schema 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
public Schema.Field getNestedField(String fieldPathName) throws TupleException
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
public Schema.Field[] getNestedFields() throws TupleException
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
public String toString()
Return a String representation of this field.
-
getDescription
public String 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
public void setDescription(String description)
Sets this field's description.- Parameters:
description
- the description String for this field
-
getElementType
public CompleteDataType 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
-
-