Cumulus4j API
(1.2.0-SNAPSHOT)

org.cumulus4j.store.model
Class ClassMeta

java.lang.Object
  extended by org.cumulus4j.store.model.ClassMeta
All Implemented Interfaces:
DetachCallback, LoadCallback, StoreCallback
Direct Known Subclasses:
EmbeddedClassMeta

public class ClassMeta
extends Object
implements DetachCallback, StoreCallback, LoadCallback

Persistent meta-data for a persistence-capable Class. Since class names are very long, we use the classID instead in our index and data entities (e.g. in the relation DataEntry.classMeta).

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

Nested Class Summary
protected static class ClassMeta.NamedQueries
           
 
Field Summary
protected static ThreadLocal<Set<ClassMeta>> attachedClassMetasInPostDetachThreadLocal
           
protected static String UNIQUE_SCOPE_CLASS_META
           
 
Constructor Summary
protected ClassMeta()
           
  ClassMeta(Class<?> clazz)
           
 
Method Summary
 void addFieldMeta(FieldMeta fieldMeta)
           
 boolean equals(Object obj)
           
 long getClassID()
           
 String getClassName()
          Get the fully qualified class name (composed of packageName and simpleClassName).
static String getClassName(String packageName, String simpleClassName)
           
 AbstractClassMetaData getDataNucleusClassMetaData(ExecutionContext executionContext)
           
 FieldMeta getFieldMeta(long fieldID)
          Get the FieldMeta with the specified fieldID.
 FieldMeta getFieldMeta(String fieldName)
          Get the FieldMeta for a field that is directly declared in the class referenced by this ClassMeta.
 FieldMeta getFieldMeta(String className, String fieldName)
           Get the FieldMeta for a field that is either directly declared in the class referenced by this ClassMeta or in a super-class.
 Collection<FieldMeta> getFieldMetas()
          Get all FieldMeta instances known to this instance.
 Map<String,FieldMeta> getFieldName2FieldMeta()
           
 String getPackageName()
          Get the package name or an empty String for the default package.
protected  PersistenceManager getPersistenceManager()
          Get the PersistenceManager assigned to this.
 String getSimpleClassName()
           
 ClassMeta getSuperClassMeta()
          The super-class' meta-data or null, if there is no persistence-capable super-class.
protected  String getUniqueScope()
           
 int hashCode()
           
 void jdoPostDetach(Object o)
           
 void jdoPostLoad()
           
 void jdoPreDetach()
           
 void jdoPreStore()
           
 void removeFieldMeta(FieldMeta fieldMeta)
           
 void setSuperClassMeta(ClassMeta superClassMeta)
           
protected  void setUniqueScope(String uniqueScope)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNIQUE_SCOPE_CLASS_META

protected static final String UNIQUE_SCOPE_CLASS_META
See Also:
Constant Field Values

attachedClassMetasInPostDetachThreadLocal

protected static final ThreadLocal<Set<ClassMeta>> attachedClassMetasInPostDetachThreadLocal
Constructor Detail

ClassMeta

protected ClassMeta()

ClassMeta

public ClassMeta(Class<?> clazz)
Method Detail

getClassID

public long getClassID()

getUniqueScope

protected String getUniqueScope()

setUniqueScope

protected void setUniqueScope(String uniqueScope)

getPackageName

public String getPackageName()
Get the package name or an empty String for the default package.

Returns:
the package name (maybe empty, but never null).

getSimpleClassName

public String getSimpleClassName()

getClassName

public String getClassName()
Get the fully qualified class name (composed of packageName and simpleClassName).

Returns:
the fully qualified class name.

getClassName

public static String getClassName(String packageName,
                                  String simpleClassName)

getSuperClassMeta

public ClassMeta getSuperClassMeta()
The super-class' meta-data or null, if there is no persistence-capable super-class.

Returns:
the super-class' meta-data or null.

setSuperClassMeta

public void setSuperClassMeta(ClassMeta superClassMeta)

getPersistenceManager

protected PersistenceManager getPersistenceManager()
Get the PersistenceManager assigned to this. If there is none, this method checks, if this is new. If this was persisted before, it must have one or an IllegalStateException is thrown.

Returns:
the PersistenceManager assigned to this or null.

getFieldName2FieldMeta

public Map<String,FieldMeta> getFieldName2FieldMeta()

getFieldMetas

public Collection<FieldMeta> getFieldMetas()
Get all FieldMeta instances known to this instance. This is the meta-data for all fields directly declared in the class referenced by this ClassMeta not including super-classes.

Returns:
Collection of FieldMeta objects for this class

getFieldMeta

public FieldMeta getFieldMeta(String fieldName)
Get the FieldMeta for a field that is directly declared in the class referenced by this ClassMeta. This method thus does not take super-classes into account.

Parameters:
fieldName - the simple field name (no class prefix).
Returns:
the FieldMeta corresponding to the specified fieldName or null, if no such field exists.
See Also:
getFieldMeta(long), getFieldMeta(String, String)

getFieldMeta

public FieldMeta getFieldMeta(String className,
                              String fieldName)

Get the FieldMeta for a field that is either directly declared in the class referenced by this ClassMeta or in a super-class.

If className is null, this method searches recursively in the inheritance hierarchy upwards (i.e. first this class then the super-class, then the next super-class etc.) until it finds a field matching the given fieldName.

If className is not null, this method searches only in the specified class. If className is neither the current class nor any super-class, this method always returns null.

Parameters:
className - the fully qualified class-name of the class referenced by this ClassMeta or any super-class. null to search the entire class hierarchy upwards (through all super-classes until the field is found or the last super-class was investigated).
fieldName - the simple field name (no class prefix).
Returns:
the FieldMeta matching the given criteria or null if no such field could be found.

getFieldMeta

public FieldMeta getFieldMeta(long fieldID)
Get the FieldMeta with the specified fieldID. It does not matter, if this field is directly in the class referenced by this ClassMeta or in a super-class.

Parameters:
fieldID - the fieldID of the FieldMeta to be found.
Returns:
the FieldMeta referenced by the given fieldID or null, if no such field exists in the class or any super-class.

addFieldMeta

public void addFieldMeta(FieldMeta fieldMeta)

removeFieldMeta

public void removeFieldMeta(FieldMeta fieldMeta)

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

getDataNucleusClassMetaData

public AbstractClassMetaData getDataNucleusClassMetaData(ExecutionContext executionContext)

jdoPreDetach

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

jdoPostDetach

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

jdoPreStore

public void jdoPreStore()
Specified by:
jdoPreStore in interface StoreCallback

jdoPostLoad

public void jdoPostLoad()
Specified by:
jdoPostLoad in interface LoadCallback

Cumulus4j API
(1.2.0-SNAPSHOT)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.