|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.Metadata<C>
public class Metadata<C>
Utility methods for retreiving metadata about items.
Nested Class Summary | |
---|---|
(package private) static class |
Metadata.BasicData2ItemPropertyPath<C extends BasicData,V extends BasicItem<C>>
Property path implementation that converts a BasicData object to a BasicItem. |
(package private) static class |
Metadata.BasicItem2DataPropertyPath<C extends BasicItem<V>,V extends BasicData>
Property path implementation that converts a BasicItem to a BasicData object. |
(package private) static class |
Metadata.CollectionPropertyPath<C>
Property path implementation which wraps a collection inside an unmodifiable collection. |
(package private) static class |
Metadata.CombinedPropertyPath<C,V>
Property path implementation that combines a list of property paths to create a long chain. |
(package private) static class |
Metadata.ComponentPropertyPath<C,V>
Property path implementation which gets a value from a component. |
(package private) static class |
Metadata.DateCopyPropertyPath
Property path implementation clones a Date. |
(package private) static class |
Metadata.EntityPropertyPath<C,V>
Property path implementation which gets a value from an entity. |
(package private) static class |
Metadata.EvictPropertyPath<C>
Property path implementation that evicts the selected item from the Hibernate first-level cache. |
(package private) static class |
Metadata.IdentifierPropertyPath
Property path implementation which gets the id from an entity. |
(package private) static class |
Metadata.MapPropertyPath
Property path implementation which wraps a map inside an unmodifiable map. |
(package private) static class |
Metadata.NoopPropertyPath<C>
Property path implementation that does nothing. |
static interface |
Metadata.PropertyPath<C,V>
Contract for getting the value of a specific property for an item. |
(package private) static class |
Metadata.ReporterScore2DataPropertyPath
Property path implementation that converts a ReporterScore to a ReporterListScoreData object. |
Field Summary | |
---|---|
private static Set<Item> |
annotatableItems
|
private Map<String,Metadata.PropertyPath> |
cachedPaths
|
private org.hibernate.metadata.ClassMetadata |
classMetadata
|
private Class<C> |
clazz
|
private static Set<Item> |
diskConsumableItems
|
private String |
entityName
|
private static Set<Item> |
fileStoreEnabledItems
|
private static Map<String,Metadata<?>> |
instances
Cache of Metadata instances. |
private static boolean |
isInitialised
|
private static Set<Item> |
ownableItems
|
private static Set<Item> |
removableItems
|
private static Set<Item> |
shareableItems
|
Constructor Summary | |
---|---|
private |
Metadata(Class<C> clazz,
String entityName)
|
Method Summary | ||
---|---|---|
static Set<Item> |
getAnnotatableItems()
Get a set containing all Annotatable item types. |
|
static Set<Item> |
getDiskConsumableItems()
Get a set containing all DiskConsumable item types. |
|
static Set<Item> |
getFileStoreEnabledItems()
Get a set containing all FileStoreEnabled item types. |
|
private static Set<Item> |
getImplementingItems(Class<?> clazz)
Get all Item :s implementing/extinding the specified
interface/class. |
|
private int |
getIndex(String s,
String[] list,
Comparator<String> check)
|
|
static
|
getInstance(Class<I> itemClass)
Get the metadata instance for the specified type of item. |
|
static
|
getInstance(Class<I> clazz,
String entityName)
Get the metadata instance for the item with the specified entity name. |
|
static Set<Item> |
getOwnableItems()
Get a set containing all Ownable item types. |
|
|
getPropertyPath(String path,
boolean ignoreCase)
Get a property path that can be used to retrieve a value from an item instead of using the regular get
methods. |
|
static Object |
getPropertyValue(BasicItem item,
String propertyName)
Deprecated. In 2.15, use getPropertyPath(String, boolean) instead |
|
Object |
getPropertyValue(DbControl dc,
C item,
String propertyName)
Deprecated. In 2.15, use getPropertyPath(String, boolean) instead |
|
static Set<Item> |
getRemovableItems()
Get a set containing all Removable item types. |
|
static Set<Item> |
getShareableItems()
Get a set containing all Shareable item types. |
|
(package private) static void |
init()
|
|
String |
toString()
|
|
(package private) static void |
unload()
Unload all settings. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static Set<Item> annotatableItems
private static Set<Item> shareableItems
private static Set<Item> removableItems
private static Set<Item> ownableItems
private static Set<Item> diskConsumableItems
private static Set<Item> fileStoreEnabledItems
private static boolean isInitialised
private static final Map<String,Metadata<?>> instances
private final org.hibernate.metadata.ClassMetadata classMetadata
private final String entityName
private final Class<C> clazz
private final Map<String,Metadata.PropertyPath> cachedPaths
Constructor Detail |
---|
private Metadata(Class<C> clazz, String entityName) throws BaseException
BaseException
Method Detail |
---|
static void init()
static void unload()
@Deprecated public static Object getPropertyValue(BasicItem item, String propertyName) throws BaseException
getPropertyPath(String, boolean)
instead
get
method of the item. Ie.
the following method calls are equivalent:
String name = item.getName(); String name = (String)Metadata.getProperty(item, "name");You can even use dot notation to navigate to associated items:
String quota = item.getOwner().getQuota().getName(); String quota = (String)Metadata.getProperty(item, "owner.quota.name");
item
- The item object to get the value from. Null is not allowedpropertyName
- The name of the property to get
BaseException
- If something goes wrong.
InvalidUseOfNullException
- If required parameter is nullprivate static Set<Item> getImplementingItems(Class<?> clazz)
Item
:s implementing/extinding the specified
interface/class.
public static Set<Item> getAnnotatableItems()
Annotatable
item types.
The set cannot be modified.
public static Set<Item> getShareableItems()
Shareable
item types.
The set cannot be modified.
public static Set<Item> getRemovableItems()
Removable
item types.
The set cannot be modified.
public static Set<Item> getOwnableItems()
Ownable
item types.
The set cannot be modified.
public static Set<Item> getDiskConsumableItems()
DiskConsumable
item types.
The set cannot be modified.
public static Set<Item> getFileStoreEnabledItems()
FileStoreEnabled
item types.
The set cannot be modified.
public static <I> Metadata<I> getInstance(Class<I> itemClass) throws BaseException
I
- itemClass
- The class of the item
BaseException
- If a new instance could not be created.public static <I> Metadata<I> getInstance(Class<I> clazz, String entityName) throws BaseException
I
- clazz
- The class of the item, should be either a
BasicItem or BasicData classentityName
- The entity name for the item, normally
this is clazz.getName()
but some entities,
for example RawData
, have multiple names
BaseException
- If a new instance could not be created.public <V> Metadata.PropertyPath<C,V> getPropertyPath(String path, boolean ignoreCase)
get
methods. The following method calls are equivalent:
// Using getter method String name = item.getName(); // Using PropertyPath PropertyPath path = metadata.getPropertyPath("name"); String name = (String)path.getValue(dc, item);You can even use dot notation to navigate to associated items:
// Using getter methods String quota = item.getOwner().getQuota().getName(); // Using PropertyPath PropertyPath path = metadata.getPropertyPath("owner.quota.name"); String quota = (String)path.getValue(dc, item);
V
- The class of the returned valuespath
- The name of the property to get. Null is not allowed. Use
. or # as a separator between property and association names
NullPointerException
- If the path is null
InvalidDataException
- If the path is not a valid pathprivate int getIndex(String s, String[] list, Comparator<String> check)
@Deprecated public Object getPropertyValue(DbControl dc, C item, String propertyName) throws BaseException
getPropertyPath(String, boolean)
instead
get
method of the item. Ie.
the following method calls are equivalent:
String name = item.getName(); String name = (String)Metadata.getProperty(item, "name");You can even use dot notation to navigate to associated items:
String quota = item.getOwner().getQuota().getName(); String quota = (String)Metadata.getProperty(item, "owner.quota.name");
dc
- The DbControl object used if database access is neededitem
- The item object to get the value from. Null is not allowed.propertyName
- The name of the property to get. Null is not allowed.
BaseException
- If getting the property value goes wrong.
InvalidUseOfNullException
- if any of the required arguments is null.public String toString()
toString
in class Object
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |