Package com.db4o.internal
Class FieldMetadata
- java.lang.Object
-
- com.db4o.internal.ClassAspect
-
- com.db4o.internal.FieldMetadata
-
- All Implemented Interfaces:
StoredField
- Direct Known Subclasses:
NullFieldMetadata
,TranslatedAspect
,UnknownTypeHandlerAspect
,VirtualFieldMetadata
public class FieldMetadata extends ClassAspect implements StoredField
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassMetadata
_fieldType
protected int
_fieldTypeID
protected boolean
_isArray
-
Fields inherited from class com.db4o.internal.ClassAspect
_handle
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FieldMetadata(int fieldTypeID)
FieldMetadata(ClassMetadata classMetadata)
protected
FieldMetadata(ClassMetadata containingClass, java.lang.String name)
FieldMetadata(ClassMetadata containingClass, java.lang.String name, int fieldTypeID, boolean primitive, boolean isArray, boolean isNArray)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate(UnmarshallingContext context)
void
addFieldIndex(ObjectIdContextImpl context)
protected void
addIndexEntry(StatefulBuffer a_bytes, java.lang.Object indexEntry)
void
addIndexEntry(Transaction trans, int parentID, java.lang.Object indexEntry)
boolean
alive()
AspectType
aspectType()
void
attemptUpdate(UnmarshallingContext context)
boolean
canBeDisabled()
boolean
canLoadByIndex()
boolean
canUpdateFast()
boolean
canUseNullBitmap()
void
cascadeActivation(ActivationContext context)
protected java.lang.Object
cascadingTarget(ActivationContext context)
java.lang.Object
coerce(ReflectClass valueClass, java.lang.Object value)
void
collectIDs(CollectIdContext context)
ObjectContainerBase
container()
ClassMetadata
containingClass()
protected FieldIndexKey
createFieldIndexKey(int parentID, java.lang.Object indexEntry)
void
createIndex()
creates an index on this field at runtime.void
deactivate(ActivationContext context)
void
defragAspect(DefragmentContext context)
void
delete(DeleteContextImpl context, boolean isUpdate)
void
dropIndex()
drops an existing index on this field at runtime.void
dropIndex(LocalTransaction systemTrans)
boolean
equals(java.lang.Object obj)
ClassMetadata
fieldType()
int
fieldTypeID()
java.lang.Object
get(Transaction trans, java.lang.Object onObject)
java.lang.Object
get(java.lang.Object onObject)
returns the field value on the passed object.TypeHandler4
getHandler()
BTree
getIndex(Transaction trans)
java.lang.String
getName()
returns the name of the field.java.lang.Object
getOn(Transaction trans, java.lang.Object onObject)
java.lang.Object
getOrCreate(Transaction trans, java.lang.Object onObject)
dirty hack for com.db4o.types some of them (BlobImpl) need to be set automatically TODO: Derive from FieldMetadata for Db4oTypesReflectClass
getStoredType()
returns the Class (Java) / Type (.NET) of the field.boolean
hasConfig()
int
hashCode()
boolean
hasIndex()
Returns whether this field has an index or not.protected java.lang.Object
indexEntryFor(java.lang.Object indexEntry)
protected Indexable4
indexHandler(ObjectContainerBase stream)
void
init(java.lang.String name)
void
init(java.lang.String name, int fieldTypeID, boolean isPrimitive, boolean isArray, boolean isNArray)
void
initIndex(Transaction systemTrans, int id)
boolean
isArray()
returns true if the field is an array.boolean
isPrimitive()
int
linkLength(HandlerVersionContext context)
void
loadFieldTypeById()
void
marshall(MarshallingContext context, java.lang.Object obj)
boolean
needsArrayAndPrimitiveInfo()
protected BTree
newBTree(Transaction systemTrans, int id)
PreparedComparison
prepareComparison(Context context, java.lang.Object obj)
QField
qField(Transaction a_trans)
java.lang.Object
read(ObjectIdContext context)
java.lang.Object
readIndexEntry(ObjectIdContext context)
boolean
rebuildIndexForClass(LocalObjectContainer stream, ClassMetadata classMetadata)
protected void
rebuildIndexForObject(LocalObjectContainer stream, ClassMetadata classMetadata, int objectId)
protected void
rebuildIndexForWriter(LocalObjectContainer stream, StatefulBuffer writer, int objectId)
GenericReflector
reflector()
void
removeIndexEntry(Transaction trans, int parentID, java.lang.Object indexEntry)
void
rename(java.lang.String newName)
modifies the name of this stored field.BTreeRange
search(Transaction transaction, java.lang.Object value)
void
set(java.lang.Object onObject, java.lang.Object obj)
protected void
setAvailable()
java.lang.String
toString()
protected java.lang.Class
translatorStoredClass(ObjectTranslator translator)
void
traverseValues(Visitor4 userVisitor)
specialized highspeed API to collect all values of a field for all instances of a class, if the field is indexed.void
traverseValues(Transaction transaction, Visitor4 userVisitor)
protected TypeHandler4
typeHandlerForClass(ObjectContainerBase container, ReflectClass fieldType)
boolean
updating()
protected TypeHandler4
wrapHandlerToArrays(TypeHandler4 handler)
-
Methods inherited from class com.db4o.internal.ClassAspect
checkEnabled, disableFromAspectCountVersion, incrementOffset, isEnabledOn, isVirtual, setHandle
-
-
-
-
Field Detail
-
_isArray
protected boolean _isArray
-
_fieldType
protected ClassMetadata _fieldType
-
_fieldTypeID
protected int _fieldTypeID
-
-
Constructor Detail
-
FieldMetadata
public FieldMetadata(ClassMetadata classMetadata)
-
FieldMetadata
protected FieldMetadata(int fieldTypeID)
-
FieldMetadata
public FieldMetadata(ClassMetadata containingClass, java.lang.String name, int fieldTypeID, boolean primitive, boolean isArray, boolean isNArray)
-
FieldMetadata
protected FieldMetadata(ClassMetadata containingClass, java.lang.String name)
-
-
Method Detail
-
translatorStoredClass
protected final java.lang.Class translatorStoredClass(ObjectTranslator translator)
-
setAvailable
protected void setAvailable()
-
addFieldIndex
public void addFieldIndex(ObjectIdContextImpl context) throws FieldIndexException
- Throws:
FieldIndexException
-
addIndexEntry
protected final void addIndexEntry(StatefulBuffer a_bytes, java.lang.Object indexEntry)
-
addIndexEntry
public void addIndexEntry(Transaction trans, int parentID, java.lang.Object indexEntry)
-
createFieldIndexKey
protected FieldIndexKey createFieldIndexKey(int parentID, java.lang.Object indexEntry)
-
indexEntryFor
protected java.lang.Object indexEntryFor(java.lang.Object indexEntry)
-
canUseNullBitmap
public boolean canUseNullBitmap()
-
readIndexEntry
public final java.lang.Object readIndexEntry(ObjectIdContext context) throws CorruptionException, Db4oIOException
- Throws:
CorruptionException
Db4oIOException
-
removeIndexEntry
public void removeIndexEntry(Transaction trans, int parentID, java.lang.Object indexEntry)
-
alive
public boolean alive()
-
updating
public boolean updating()
-
reflector
public GenericReflector reflector()
-
coerce
public java.lang.Object coerce(ReflectClass valueClass, java.lang.Object value)
-
canLoadByIndex
public final boolean canLoadByIndex()
-
cascadeActivation
public final void cascadeActivation(ActivationContext context)
- Specified by:
cascadeActivation
in classClassAspect
-
cascadingTarget
protected final java.lang.Object cascadingTarget(ActivationContext context)
-
collectIDs
public final void collectIDs(CollectIdContext context) throws FieldIndexException
- Specified by:
collectIDs
in classClassAspect
- Throws:
FieldIndexException
-
wrapHandlerToArrays
protected final TypeHandler4 wrapHandlerToArrays(TypeHandler4 handler)
-
deactivate
public void deactivate(ActivationContext context)
- Specified by:
deactivate
in classClassAspect
-
delete
public void delete(DeleteContextImpl context, boolean isUpdate) throws FieldIndexException
- Specified by:
delete
in classClassAspect
- Throws:
FieldIndexException
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
get
public final java.lang.Object get(java.lang.Object onObject)
Description copied from interface:StoredField
returns the field value on the passed object.
This method will also work, if the field is not present in the current version of the class.
It is recommended to use this method for refactoring purposes, if fields are removed and the field values need to be copied to other fields.- Specified by:
get
in interfaceStoredField
-
get
public final java.lang.Object get(Transaction trans, java.lang.Object onObject)
-
getName
public java.lang.String getName()
Description copied from interface:StoredField
returns the name of the field.- Specified by:
getName
in interfaceStoredField
- Specified by:
getName
in classClassAspect
-
fieldType
public final ClassMetadata fieldType()
-
getHandler
public TypeHandler4 getHandler()
-
fieldTypeID
public int fieldTypeID()
-
getOn
public java.lang.Object getOn(Transaction trans, java.lang.Object onObject)
-
getOrCreate
public java.lang.Object getOrCreate(Transaction trans, java.lang.Object onObject)
dirty hack for com.db4o.types some of them (BlobImpl) need to be set automatically TODO: Derive from FieldMetadata for Db4oTypes
-
containingClass
public final ClassMetadata containingClass()
-
getStoredType
public ReflectClass getStoredType()
Description copied from interface:StoredField
returns the Class (Java) / Type (.NET) of the field.
For array fields this method will return the type of the array. UseStoredField.isArray()
to detect arrays.- Specified by:
getStoredType
in interfaceStoredField
-
container
public ObjectContainerBase container()
-
hasConfig
public boolean hasConfig()
-
hasIndex
public boolean hasIndex()
Description copied from interface:StoredField
Returns whether this field has an index or not.- Specified by:
hasIndex
in interfaceStoredField
- Returns:
- true if this field has an index.
-
init
public final void init(java.lang.String name)
-
init
public void init(java.lang.String name, int fieldTypeID, boolean isPrimitive, boolean isArray, boolean isNArray)
-
activate
public void activate(UnmarshallingContext context)
- Specified by:
activate
in classClassAspect
-
attemptUpdate
public void attemptUpdate(UnmarshallingContext context)
-
isArray
public boolean isArray()
Description copied from interface:StoredField
returns true if the field is an array.- Specified by:
isArray
in interfaceStoredField
-
linkLength
public int linkLength(HandlerVersionContext context)
- Specified by:
linkLength
in classClassAspect
-
loadFieldTypeById
public void loadFieldTypeById()
-
typeHandlerForClass
protected TypeHandler4 typeHandlerForClass(ObjectContainerBase container, ReflectClass fieldType)
-
marshall
public void marshall(MarshallingContext context, java.lang.Object obj)
- Specified by:
marshall
in classClassAspect
-
needsArrayAndPrimitiveInfo
public boolean needsArrayAndPrimitiveInfo()
-
prepareComparison
public PreparedComparison prepareComparison(Context context, java.lang.Object obj)
-
qField
public QField qField(Transaction a_trans)
-
read
public java.lang.Object read(ObjectIdContext context)
-
rename
public void rename(java.lang.String newName)
Description copied from interface:StoredField
modifies the name of this stored field.
After renaming one or multiple fields the ObjectContainer has to be closed and reopened to allow internal caches to be refreshed.- Specified by:
rename
in interfaceStoredField
- Parameters:
newName
- the new name
-
set
public void set(java.lang.Object onObject, java.lang.Object obj)
-
traverseValues
public final void traverseValues(Visitor4 userVisitor)
Description copied from interface:StoredField
specialized highspeed API to collect all values of a field for all instances of a class, if the field is indexed.
The field values will be taken directly from the index without the detour through class indexes or object instantiation.
If this method is used to get the values of a first class object index, deactivated objects will be passed to the visitor.- Specified by:
traverseValues
in interfaceStoredField
- Parameters:
userVisitor
- the visitor to be called with each index value.
-
traverseValues
public final void traverseValues(Transaction transaction, Visitor4 userVisitor)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
initIndex
public void initIndex(Transaction systemTrans, int id)
-
newBTree
protected final BTree newBTree(Transaction systemTrans, int id)
-
indexHandler
protected Indexable4 indexHandler(ObjectContainerBase stream)
-
getIndex
public BTree getIndex(Transaction trans)
- Parameters:
trans
-
-
isPrimitive
public boolean isPrimitive()
-
search
public BTreeRange search(Transaction transaction, java.lang.Object value)
-
rebuildIndexForClass
public boolean rebuildIndexForClass(LocalObjectContainer stream, ClassMetadata classMetadata)
-
rebuildIndexForObject
protected void rebuildIndexForObject(LocalObjectContainer stream, ClassMetadata classMetadata, int objectId) throws FieldIndexException
- Throws:
FieldIndexException
-
rebuildIndexForWriter
protected void rebuildIndexForWriter(LocalObjectContainer stream, StatefulBuffer writer, int objectId)
-
dropIndex
public final void dropIndex(LocalTransaction systemTrans)
-
defragAspect
public void defragAspect(DefragmentContext context)
- Specified by:
defragAspect
in classClassAspect
-
createIndex
public void createIndex()
Description copied from interface:StoredField
creates an index on this field at runtime.- Specified by:
createIndex
in interfaceStoredField
-
aspectType
public AspectType aspectType()
- Specified by:
aspectType
in classClassAspect
-
canBeDisabled
public boolean canBeDisabled()
- Specified by:
canBeDisabled
in classClassAspect
-
dropIndex
public void dropIndex()
Description copied from interface:StoredField
drops an existing index on this field at runtime.- Specified by:
dropIndex
in interfaceStoredField
-
canUpdateFast
public boolean canUpdateFast()
-
-