Package com.yahoo.document
Class Field
java.lang.Object
com.yahoo.vespa.objects.FieldBase
com.yahoo.document.Field
- All Implemented Interfaces:
FieldSet
,Comparable<Field>
- Direct Known Subclasses:
ExtendedField
A name and type. Fields are contained in document types to describe their fields,
but is also used to represent name/type pairs which are not part of document types.
- Author:
- Thomas Gundersen, bratseth
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new field.Constructor for normal fieldsField
(String name, DataType dataType, DocumentType owner) Creates a new field.Creates a field with a new name and the other properties (excluding the id and owner) copied from another field -
Method Summary
Modifier and TypeMethodDescriptionprotected int
calculateIdV7
(DocumentType owner) The field id must be unique within a document type, and also within a (unknown at this time) hierarchy of document types.clone()
int
boolean
boolean
Two fields are equal if they have the same name and the same data typefinal DataType
Returns the datatype of the fieldfinal int
getId()
final boolean
int
hashCode()
void
setDataType
(DataType type) Deprecated.do not usevoid
setId
(int newId, DocumentType owner) Sets the id of this field.toString()
Methods inherited from class com.yahoo.vespa.objects.FieldBase
getName
-
Field Details
-
dataType
-
fieldId
protected int fieldId
-
-
Constructor Details
-
Field
Creates a new field.- Parameters:
name
- The name of the fieldid
- Serialized IDdataType
- The datatype of the field
-
Field
-
Field
Creates a new field.- Parameters:
name
- The name of the fielddataType
- The datatype of the fieldowner
- the owning document (used to check for id collisions)
-
Field
Constructor for normal fields- Parameters:
name
- The name of the fielddataType
- The datatype of the field
-
Field
Creates a field with a new name and the other properties (excluding the id and owner) copied from another field
-
-
Method Details
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Field>
-
calculateIdV7
The field id must be unique within a document type, and also within a (unknown at this time) hierarchy of document types. In addition it should be as resilient to doctype content changes and inheritance hierarchy changes as possible. All of this is enforced for names, so id's should follow names. Therefore we hash on name. -
setId
Sets the id of this field. Don't do this unless you know what you are doing- Parameters:
newId
- the id - if this is less than 100 it will cause document to serialize using just one byte for this field id. 100-127 are reserved valuesowner
- the owning document, this is checked for collisions and notified of the id change. It can not be null
-
getDataType
Returns the datatype of the field -
setDataType
Deprecated.do not useSet the data type of the field. This will cause recalculation of fieldid for version 7+.- Parameters:
type
- The new type of the field.
-
getId
public final int getId() -
hasForcedId
public final boolean hasForcedId()- Returns:
- true if the field has a forced id
-
equals
Two fields are equal if they have the same name and the same data type- Overrides:
equals
in classcom.yahoo.vespa.objects.FieldBase
-
hashCode
public int hashCode()- Overrides:
hashCode
in classcom.yahoo.vespa.objects.FieldBase
-
toString
- Overrides:
toString
in classcom.yahoo.vespa.objects.FieldBase
-
contains
-
clone
- Specified by:
clone
in interfaceFieldSet
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-