Cumulus4j API
(1.0.0)

org.cumulus4j.store.model
Class FieldMeta

java.lang.Object
  extended by org.cumulus4j.store.model.FieldMeta
All Implemented Interfaces:
DetachCallback

public class FieldMeta
extends Object
implements DetachCallback

Persistent meta-data for a field of a persistence-capable class. Since class- and field-names are very long we reference them indirectly via the long-identifiers of ClassMeta and FieldMeta, e.g. in the relation IndexEntry.fieldMeta.

Author:
Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de

Constructor Summary
protected FieldMeta()
          Internal constructor.
protected FieldMeta(ClassMeta classMeta, FieldMeta ownerFieldMeta, String fieldName, FieldMetaRole role)
          Internal constructor.
  FieldMeta(ClassMeta classMeta, String fieldName)
          Create a FieldMeta referencing a real field.
  FieldMeta(FieldMeta ownerFieldMeta, FieldMetaRole role)
          Create a FieldMeta referencing a part of a field.
 
Method Summary
 void addSubFieldMeta(FieldMeta subFieldMeta)
           
 boolean equals(Object obj)
           
 ClassMeta getClassMeta()
          Get the ClassMeta to which this FieldMeta belongs.
 int getDataNucleusAbsoluteFieldNumber()
          Get the non-persistent field-number in DataNucleus' meta-data.
 AbstractMemberMetaData getDataNucleusMemberMetaData(ExecutionContext executionContext)
           
 long getFieldID()
           
 String getFieldName()
          Get the simple field name (no class prefix) of the field referenced by this meta-data-instance.
 FieldMeta getMappedByFieldMeta(ExecutionContext executionContext)
           Get the FieldMeta of the opposite end of the mapped-by-relation.
 FieldMeta getOwnerFieldMeta()
          Get the primary FieldMeta, to which this sub-FieldMeta belongs or null, if this FieldMeta is primary.
 FieldMetaRole getRole()
          Get the role of the (sub-)field.
 FieldMeta getSubFieldMeta(FieldMetaRole role)
          Get a sub-field of this field or null, if no such sub-field exists.
 Collection<FieldMeta> getSubFieldMetas()
          Get all sub-fields' meta-data of this field.
 int hashCode()
           
 void jdoPostDetach(Object o)
           
 void jdoPreDetach()
           
 void removeAllSubFieldMetasExcept(FieldMetaRole... roles)
           
 void removeSubFieldMeta(FieldMeta fieldMeta)
           
 void setDataNucleusAbsoluteFieldNumber(int dataNucleusAbsoluteFieldNumber)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FieldMeta

protected FieldMeta()
Internal constructor. This exists only for JDO and should not be used by application code!


FieldMeta

public FieldMeta(ClassMeta classMeta,
                 String fieldName)
Create a FieldMeta referencing a real field.

Parameters:
classMeta - the class to which this field belongs.
fieldName - the field's name.
See Also:
FieldMeta(FieldMeta, FieldMetaRole)

FieldMeta

public FieldMeta(FieldMeta ownerFieldMeta,
                 FieldMetaRole role)
Create a FieldMeta referencing a part of a field. This is necessary to index keys and values of a Map field (i.e. 2 separate indexes for one field) as well as Collection-elements and similar.

Parameters:
ownerFieldMeta - the FieldMeta of the real field (to which the part belongs).
role - the role (aka type) of the sub-field (aka part).
See Also:
FieldMeta(ClassMeta, String)

FieldMeta

protected FieldMeta(ClassMeta classMeta,
                    FieldMeta ownerFieldMeta,
                    String fieldName,
                    FieldMetaRole role)
Internal constructor. This exists only for easier implementation of the other constructors and should not be used by application code!

Method Detail

getFieldID

public long getFieldID()

getClassMeta

public ClassMeta getClassMeta()
Get the ClassMeta to which this FieldMeta belongs. Every FieldMeta belongs to exactly one ClassMeta just like a field is declared in exactly one Java class. Note, that a FieldMeta might belong to another FieldMeta in order to reference sub-field-properties, e.g. a Map's key. In this case, the direct property classMeta is null, but this method still returns the correct ClassMeta by resolving it indirectly via the ownerFieldMeta.

Returns:
the ClassMeta to which this instance of FieldMeta belongs.

getOwnerFieldMeta

public FieldMeta getOwnerFieldMeta()
Get the primary FieldMeta, to which this sub-FieldMeta belongs or null, if this FieldMeta is primary.

Returns:
the owning primary field-meta or null.

getFieldName

public String getFieldName()
Get the simple field name (no class prefix) of the field referenced by this meta-data-instance.

Returns:
the simple field name.

getRole

public FieldMetaRole getRole()
Get the role of the (sub-)field. If this is not a sub-field, but a primary field (i.e. directly meaning a real field of the class referenced by classMeta) it will be FieldMetaRole.primary, hence this method never returns null.

Returns:
the role of this FieldMeta; never null.

getDataNucleusAbsoluteFieldNumber

public int getDataNucleusAbsoluteFieldNumber()
Get the non-persistent field-number in DataNucleus' meta-data. This is only a usable value, if this FieldMeta was obtained via Cumulus4jStoreManager.getClassMeta(org.datanucleus.store.ExecutionContext, Class); otherwise it is -1.

Returns:
the non-persistent field-number in DataNucleus' meta-data or -1.

setDataNucleusAbsoluteFieldNumber

public void setDataNucleusAbsoluteFieldNumber(int dataNucleusAbsoluteFieldNumber)

getSubFieldMeta

public FieldMeta getSubFieldMeta(FieldMetaRole role)
Get a sub-field of this field or null, if no such sub-field exists.

Parameters:
role - the role of the sub-field. Must not be null.
Returns:
the sub-FieldMeta or null.

getSubFieldMetas

public Collection<FieldMeta> getSubFieldMetas()
Get all sub-fields' meta-data of this field. If there are no sub-fields, this is an empty collection.

Returns:
all sub-FieldMetas of this field; never null.

addSubFieldMeta

public void addSubFieldMeta(FieldMeta subFieldMeta)

removeSubFieldMeta

public void removeSubFieldMeta(FieldMeta fieldMeta)

removeAllSubFieldMetasExcept

public void removeAllSubFieldMetasExcept(FieldMetaRole... roles)

getMappedByFieldMeta

public FieldMeta getMappedByFieldMeta(ExecutionContext executionContext)

Get the FieldMeta of the opposite end of the mapped-by-relation. If this is not a mapped-by field, this method returns null.

Though, it returns always the mapped-by opposite side, the semantics of this method still depend on the role of this FieldMeta:

Returns:
the FieldMeta of the other end of the mapped-by-relation.

jdoPreDetach

public void jdoPreDetach()
Specified by:
jdoPreDetach in interface DetachCallback

jdoPostDetach

public void jdoPostDetach(Object o)
Specified by:
jdoPostDetach in interface DetachCallback

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

getDataNucleusMemberMetaData

public AbstractMemberMetaData getDataNucleusMemberMetaData(ExecutionContext executionContext)

Cumulus4j API
(1.0.0)

Copyright © 2012 NightLabs Consulting GmbH. All Rights Reserved.