org.datanucleus.metadata
Class MetaDataUtils

java.lang.Object
  extended by org.datanucleus.metadata.MetaDataUtils

public class MetaDataUtils
extends java.lang.Object

Utilities needed for the processing of MetaData.


Field Summary
protected static Localiser LOCALISER
           
 
Constructor Summary
protected MetaDataUtils()
          Protected constructor to prevent outside instantiation
 
Method Summary
 boolean arrayStorableAsByteArrayInSingleColumn(AbstractMemberMetaData fmd)
          Convenience method to determine if an array is storable in a single column as a byte array.
static boolean getBooleanForString(java.lang.String str, boolean dflt)
          Convenience method to return a boolean from the String value.
static java.lang.String getClassNameFromDiscriminatorValue(java.lang.String discrimValue, DiscriminatorMetaData dismd, ExecutionContext ec)
          Convenience method that takes a result set that contains a discriminator column and returns the class name that it represents.
 java.lang.String[] getImplementationNamesForReferenceField(AbstractMemberMetaData fmd, int fieldRole, ClassLoaderResolver clr, MetaDataManager mmgr)
          Convenience method to return the class names of the available implementation types for an interface/Object field, given its required role.
static MetaDataUtils getInstance()
          Gets an instance of MetaDataUtils
static java.lang.String getValueForExtensionRecursively(MetaData metadata, java.lang.String key)
          Searches the meta data tree upwards starting with the given leaf, stops as soon as it finds an extension with the given key.
 java.lang.String[] getValuesForCommaSeparatedAttribute(java.lang.String attr)
          Convenience method that splits a comma-separated list of values into a String array (removing whitespace).
static java.lang.String[] getValuesForExtensionRecursively(MetaData metadata, java.lang.String key)
          Searches the meta data tree upwards starting with the given leaf, stops as soon as it finds an extension with the given key.
static boolean isJdbcTypeNumeric(java.lang.String jdbcType)
          Convenience method to return if a jdbc-type is numeric.
static boolean isJdbcTypeString(java.lang.String jdbcType)
          Convenience method to return if a jdbc-type is character based.
 boolean storesFCO(AbstractMemberMetaData fmd, ExecutionContext ec)
          Convenience method that returns if a field stores a First-Class object (FCO).
 boolean storesPersistable(AbstractMemberMetaData fmd, ExecutionContext ec)
          Convenience method that returns if a field stores a persistable object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Constructor Detail

MetaDataUtils

protected MetaDataUtils()
Protected constructor to prevent outside instantiation

Method Detail

getInstance

public static MetaDataUtils getInstance()
Gets an instance of MetaDataUtils

Returns:
a singleton instance of MetaDataUtils

arrayStorableAsByteArrayInSingleColumn

public boolean arrayStorableAsByteArrayInSingleColumn(AbstractMemberMetaData fmd)
Convenience method to determine if an array is storable in a single column as a byte array.

Parameters:
fmd - The field
Returns:
Whether this is an array that can be stored in a single column as non-serialised

storesPersistable

public boolean storesPersistable(AbstractMemberMetaData fmd,
                                 ExecutionContext ec)
Convenience method that returns if a field stores a persistable object. Doesn't care if the persistable object is serialised or embedded, just that it is persistable.

Parameters:
fmd - MetaData for the field
ec - ObjectManager
Returns:
Whether it stores a persistable object

storesFCO

public boolean storesFCO(AbstractMemberMetaData fmd,
                         ExecutionContext ec)
Convenience method that returns if a field stores a First-Class object (FCO). If a field object is serialised/embedded then doesn't count the object as FCO - use storesPersistable() if you want that not checking.

Parameters:
fmd - MetaData for the field
ec - ExecutionContext
Returns:
Whether it stores a FCO

getValuesForCommaSeparatedAttribute

public java.lang.String[] getValuesForCommaSeparatedAttribute(java.lang.String attr)
Convenience method that splits a comma-separated list of values into a String array (removing whitespace).

Parameters:
attr - The attribute value
Returns:
The string components

getImplementationNamesForReferenceField

public java.lang.String[] getImplementationNamesForReferenceField(AbstractMemberMetaData fmd,
                                                                  int fieldRole,
                                                                  ClassLoaderResolver clr,
                                                                  MetaDataManager mmgr)
Convenience method to return the class names of the available implementation types for an interface/Object field, given its required role. Removes all duplicates from the list.

Parameters:
fmd - MetaData for the field
fieldRole - The role of the field
clr - the ClassLoaderResolver
mmgr - MetaData manager
Returns:
Names of the classes of the possible implementations of this interface/Object
Throws:
NucleusUserException - if no implementation types are found for the reference type field

getBooleanForString

public static boolean getBooleanForString(java.lang.String str,
                                          boolean dflt)
Convenience method to return a boolean from the String value. If the string is null then dflt is returned.

Parameters:
str - The string (should be "true", "false")
dflt - The default
Returns:
The boolean to use

getClassNameFromDiscriminatorValue

public static java.lang.String getClassNameFromDiscriminatorValue(java.lang.String discrimValue,
                                                                  DiscriminatorMetaData dismd,
                                                                  ExecutionContext ec)
Convenience method that takes a result set that contains a discriminator column and returns the class name that it represents.

Parameters:
discrimValue - Discriminator value
dismd - Metadata for the discriminator at the root (defining the strategy)
ec - ExecutionContext
Returns:
The class name for the object represented by this value

getValueForExtensionRecursively

public static java.lang.String getValueForExtensionRecursively(MetaData metadata,
                                                               java.lang.String key)
Searches the meta data tree upwards starting with the given leaf, stops as soon as it finds an extension with the given key.

Parameters:
metadata - Leaf of the meta data tree, where the search should start
key - The key of the extension
Returns:
The value of the extension (null if not existing)

getValuesForExtensionRecursively

public static java.lang.String[] getValuesForExtensionRecursively(MetaData metadata,
                                                                  java.lang.String key)
Searches the meta data tree upwards starting with the given leaf, stops as soon as it finds an extension with the given key.

Parameters:
metadata - Leaf of the meta data tree, where the search should start
key - The key of the extension
Returns:
The values of the extension (null if not existing)

isJdbcTypeNumeric

public static boolean isJdbcTypeNumeric(java.lang.String jdbcType)
Convenience method to return if a jdbc-type is numeric.

Parameters:
jdbcType - The type string
Returns:
Whether it is numeric

isJdbcTypeString

public static boolean isJdbcTypeString(java.lang.String jdbcType)
Convenience method to return if a jdbc-type is character based.

Parameters:
jdbcType - The type string
Returns:
Whether it is character based


Copyright © 2011. All Rights Reserved.