Package com.yahoo.document.datatypes
Class StructuredFieldValue
- java.lang.Object
-
- com.yahoo.vespa.objects.Selectable
-
- com.yahoo.vespa.objects.Identifiable
-
- com.yahoo.document.datatypes.FieldValue
-
- com.yahoo.document.datatypes.CompositeFieldValue
-
- com.yahoo.document.datatypes.StructuredFieldValue
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Comparable<FieldValue>
public abstract class StructuredFieldValue extends CompositeFieldValue
- Author:
- HÃ¥kon Humberset
-
-
Field Summary
Fields Modifier and Type Field Description static int
classId
-
Constructor Summary
Constructors Modifier Constructor Description protected
StructuredFieldValue(StructuredDataType type)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
clear()
protected abstract void
doSetFieldValue(Field field, FieldValue value)
StructuredDataType
getDataType()
abstract Field
getField(java.lang.String fieldName)
Returns the named field object, or null if that field does not exist.abstract int
getFieldCount()
abstract FieldValue
getFieldValue(Field field)
Returns the value of the given field.FieldValue
getFieldValue(java.lang.String fieldName)
Convenience method to return the value of a named field.protected boolean
isGenerated()
Generated Document subclasses should override this and return true.FieldPathIteratorHandler.ModificationStatus
iterateNested(FieldPath fieldPath, int pos, FieldPathIteratorHandler handler)
abstract java.util.Iterator<java.util.Map.Entry<Field,FieldValue>>
iterator()
abstract FieldValue
removeFieldValue(Field field)
Removes and returns a field value.FieldValue
removeFieldValue(java.lang.String fieldName)
Convenience method to remove the value of a named field.FieldValue
setFieldValue(Field field, FieldValue value)
Sets the value of the given field.FieldValue
setFieldValue(Field field, java.lang.Byte value)
FieldValue
setFieldValue(Field field, java.lang.Double value)
FieldValue
setFieldValue(Field field, java.lang.Integer value)
FieldValue
setFieldValue(Field field, java.lang.Long value)
FieldValue
setFieldValue(Field field, java.lang.String value)
FieldValue
setFieldValue(java.lang.String fieldName, FieldValue value)
Convenience method to set the value of a named field.FieldValue
setFieldValue(java.lang.String field, java.lang.Byte value)
FieldValue
setFieldValue(java.lang.String field, java.lang.Double value)
FieldValue
setFieldValue(java.lang.String field, java.lang.Integer value)
FieldValue
setFieldValue(java.lang.String field, java.lang.Long value)
FieldValue
setFieldValue(java.lang.String field, java.lang.String value)
-
Methods inherited from class com.yahoo.document.datatypes.CompositeFieldValue
equals, hashCode, setDataType
-
Methods inherited from class com.yahoo.document.datatypes.FieldValue
assign, clone, compareTo, create, deserialize, deserialize, getRecursiveValue, getRecursiveValue, getWrappedValue, onDeserialize, onSerialize, printXml, serialize, serialize, toXml
-
-
-
-
Constructor Detail
-
StructuredFieldValue
protected StructuredFieldValue(StructuredDataType type)
-
-
Method Detail
-
getDataType
public StructuredDataType getDataType()
- Overrides:
getDataType
in classCompositeFieldValue
-
getField
public abstract Field getField(java.lang.String fieldName)
Returns the named field object, or null if that field does not exist.- Parameters:
fieldName
- The name of the field to return.- Returns:
- The corresponding field, or null.
-
getFieldValue
public abstract FieldValue getFieldValue(Field field)
Returns the value of the given field. If the field does not exist, this method returns null.- Parameters:
field
- The field whose value to return.- Returns:
- The value of the field, or null.
-
getFieldValue
public FieldValue getFieldValue(java.lang.String fieldName)
Convenience method to return the value of a named field. This is the same as callinggetField(String)
, and using the returned value to callgetFieldValue(Field)
. If the named field does not exist, this method returns null.- Parameters:
fieldName
- The name of the field whose value to return.- Returns:
- The value of the field, or null.
-
setFieldValue
public FieldValue setFieldValue(Field field, FieldValue value)
Sets the value of the given field. The type of the value must match the type of this field, i.e.field.getDataType().getValueClass().isAssignableFrom(value.getClass())
must be true.- Parameters:
field
- The field whose value to set.value
- The value to set.- Returns:
- The previous value of the field, or null.
- Throws:
java.lang.IllegalArgumentException
- If the value is not compatible with the field.
-
doSetFieldValue
protected abstract void doSetFieldValue(Field field, FieldValue value)
-
setFieldValue
public FieldValue setFieldValue(java.lang.String fieldName, FieldValue value)
Convenience method to set the value of a named field. This is the same as callinggetField(String)
, and using the returned value to callsetFieldValue(Field, FieldValue)
. If the named field does not exist, this method returns null.- Parameters:
fieldName
- The name of the field whose value to set.value
- The value to set.- Returns:
- The previous value of the field, or null.
-
setFieldValue
public final FieldValue setFieldValue(Field field, java.lang.String value)
-
setFieldValue
public final FieldValue setFieldValue(Field field, java.lang.Double value)
-
setFieldValue
public final FieldValue setFieldValue(Field field, java.lang.Integer value)
-
setFieldValue
public final FieldValue setFieldValue(Field field, java.lang.Long value)
-
setFieldValue
public final FieldValue setFieldValue(Field field, java.lang.Byte value)
-
setFieldValue
public final FieldValue setFieldValue(java.lang.String field, java.lang.String value)
-
setFieldValue
public final FieldValue setFieldValue(java.lang.String field, java.lang.Double value)
-
setFieldValue
public final FieldValue setFieldValue(java.lang.String field, java.lang.Integer value)
-
setFieldValue
public final FieldValue setFieldValue(java.lang.String field, java.lang.Long value)
-
setFieldValue
public final FieldValue setFieldValue(java.lang.String field, java.lang.Byte value)
-
removeFieldValue
public abstract FieldValue removeFieldValue(Field field)
Removes and returns a field value.- Parameters:
field
- The field whose value to remove.- Returns:
- The previous value of the field, or null.
-
removeFieldValue
public FieldValue removeFieldValue(java.lang.String fieldName)
Convenience method to remove the value of a named field. This is the same as callinggetField(String)
, and using the returned value to callremoveFieldValue(Field)
. If the named field does not exist, this method returns null.- Parameters:
fieldName
- The name of the field whose value to remove.- Returns:
- The previous value of the field, or null.
-
clear
public abstract void clear()
- Specified by:
clear
in classFieldValue
-
getFieldCount
public abstract int getFieldCount()
-
iterator
public abstract java.util.Iterator<java.util.Map.Entry<Field,FieldValue>> iterator()
-
iterateNested
public FieldPathIteratorHandler.ModificationStatus iterateNested(FieldPath fieldPath, int pos, FieldPathIteratorHandler handler)
-
isGenerated
protected boolean isGenerated()
Generated Document subclasses should override this and return true. This is used instead of using class.getAnnotation(Generated.class), because that is so slow.- Returns:
- true if in a concrete subtype of Document
-
-