Package com.yahoo.document
Class Field
- java.lang.Object
-
- com.yahoo.vespa.objects.FieldBase
-
- com.yahoo.document.Field
-
- All Implemented Interfaces:
FieldSet
,java.io.Serializable
,java.lang.Comparable
- Direct Known Subclasses:
ExtendedField
public class Field extends com.yahoo.vespa.objects.FieldBase implements FieldSet, java.lang.Comparable, java.io.Serializable
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
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Field(java.lang.String name)
Field(java.lang.String name, int id, DataType dataType)
Field(java.lang.String name, int id, DataType dataType, boolean isHeader)
Deprecated.Field(java.lang.String name, DataType dataType)
Constructor for header fieldsField(java.lang.String name, DataType dataType, boolean isHeader)
Deprecated.Field(java.lang.String name, DataType dataType, boolean isHeader, DocumentType owner)
Deprecated.Field(java.lang.String name, DataType dataType, DocumentType owner)
Field(java.lang.String name, Field field)
Creates a field with a new name and the other properties (excluding the id and owner) copied from another field
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected 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.FieldSet
clone()
int
compareTo(java.lang.Object o)
boolean
contains(FieldSet o)
boolean
equals(java.lang.Object o)
Two fields are equal if they have the same name and the same data typeDataType
getDataType()
Returns the datatype of the fieldint
getId()
int
getId(int version)
Deprecated.boolean
hasForcedId()
int
hashCode()
boolean
isHeader()
Deprecated.this has no longer any semantic meaning as this is no longer an aspect with a fieldvoid
setDataType(DataType type)
Deprecated.do not usevoid
setHeader(boolean header)
Deprecated.this has no longer any semantic meaning as this is no longer an aspect with a fieldvoid
setId(int newId, DocumentType owner)
Sets the id of this field.java.lang.String
toString()
-
-
-
Field Detail
-
dataType
protected DataType dataType
-
fieldId
protected int fieldId
-
-
Constructor Detail
-
Field
@Deprecated public Field(java.lang.String name, int id, DataType dataType, boolean isHeader)
Deprecated.Creates a new field.- Parameters:
name
- The name of the fielddataType
- The datatype of the fieldisHeader
- Whether this is a "header" field or a "content" field (true = "header").
-
Field
public Field(java.lang.String name, int id, DataType dataType)
-
Field
public Field(java.lang.String name)
-
Field
@Deprecated public Field(java.lang.String name, DataType dataType, boolean isHeader, DocumentType owner)
Deprecated.Creates a new field.- Parameters:
name
- The name of the fielddataType
- The datatype of the fieldisHeader
- Whether this is a "header" field or a "content" field (true = "header").owner
- the owning document (used to check for id collisions)
-
Field
public Field(java.lang.String name, DataType dataType, DocumentType owner)
-
Field
@Deprecated public Field(java.lang.String name, DataType dataType, boolean isHeader)
Deprecated.Creates a new field.- Parameters:
name
- The name of the fielddataType
- The datatype of the fieldisHeader
- Whether this is a "header" field or a "content" field (true = "header").
-
Field
public Field(java.lang.String name, DataType dataType)
Constructor for header fields- Parameters:
name
- The name of the fielddataType
- The datatype of the field
-
Field
public Field(java.lang.String name, Field field)
Creates a field with a new name and the other properties (excluding the id and owner) copied from another field
-
-
Method Detail
-
compareTo
public int compareTo(java.lang.Object o)
- Specified by:
compareTo
in interfacejava.lang.Comparable
-
calculateIdV7
protected 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. 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
public void setId(int newId, DocumentType owner)
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
public final DataType getDataType()
Returns the datatype of the field
-
setDataType
@Deprecated public void setDataType(DataType type)
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
@Deprecated public final int getId(int version)
Deprecated.Returns the numeric ID used to represent this field when serialized
-
getId
public final int getId()
-
hasForcedId
public final boolean hasForcedId()
- Returns:
- true if the field has a forced id
-
isHeader
@Deprecated public boolean isHeader()
Deprecated.this has no longer any semantic meaning as this is no longer an aspect with a field
-
setHeader
@Deprecated public void setHeader(boolean header)
Deprecated.this has no longer any semantic meaning as this is no longer an aspect with a field
-
equals
public boolean equals(java.lang.Object o)
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
public java.lang.String toString()
- Overrides:
toString
in classcom.yahoo.vespa.objects.FieldBase
-
-