|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.jmi.JmiObjUtil
public abstract class JmiObjUtil
Static JMI utilities.
Nested Class Summary | |
---|---|
static interface |
JmiObjUtil.Namer
Generates a name for a JMI element. |
Field Summary | |
---|---|
private static int |
DEFAULT_MAX_STRING_LENGTH
Default maximum repository string length. |
Constructor Summary | |
---|---|
JmiObjUtil()
|
Method Summary | ||
---|---|---|
private static
|
addFeatures(List<T> list,
MofClass mofClass,
Class<T> filterClass,
boolean includeMultiValued)
|
|
static void |
assertConstraints(RefObject obj)
Deprecated. use RefBaseObject.refVerifyConstraints(boolean) instead |
|
private static boolean |
compositeEquals(RefObject obj1,
RefObject obj2)
|
|
static void |
copyAttributes(RefObject dst,
RefObject src)
Copies attribute values from one RefObject to another compatible RefObject. |
|
static void |
dumpGraph(JmiDependencyGraph graph,
PrintWriter pw,
JmiObjUtil.Namer namer)
Prints a dependency graph to a given writer. |
|
static void |
dumpGraph(JmiModelView view,
PrintWriter pw)
Prints a model view to a given writer. |
|
static String |
exportToXmiString(Collection<?> collection)
Exports a collection of JMI objects as XMI. |
|
static String |
getAccessorName(ModelElement modelElement)
Constructs the generated name of an accessor method. |
|
static SortedMap<String,Object> |
getAttributeValues(RefObject src)
Gets a SortedMap (from String to Object) containing the attribute values for a RefObject. |
|
static Class<? extends RefObject> |
getClassForRefClass(ClassLoader classLoader,
RefClass refClass,
boolean nullIfNotFound)
Finds the Java class generated for a particular RefClass. |
|
static Class<? extends RefObject> |
getClassForRefClass(MDRepository repos,
RefClass refClass)
Finds the Java class generated for a particular RefClass, or RefObject .class if not found. |
|
static Class<? extends RefObject> |
getClassForRefClass(RefClass refClass)
Deprecated. use getClassForRefClass(MDRepository, RefClass) |
|
static RefBaseObject |
getContainer(RefBaseObject refObject)
Gets an object's container. |
|
static String |
getEnumFieldName(String enumSymbol)
Constructs the generated name of an enum symbol. |
|
static
|
getFeatures(RefClass refClass,
Class<T> filterClass,
boolean includeMultiValued)
Gets a List of instance-level StructuralFeatures for a RefClass. |
|
private static
|
getJavaInterfaceForProxy(Class<?> proxyClass,
Class<T> resultClass,
String delimiter)
|
|
static Class<? extends RefAssociation> |
getJavaInterfaceForRefAssoc(RefAssociation refAssoc)
Finds the Java interface corresponding to a JMI association |
|
static Class<? extends RefClass> |
getJavaInterfaceForRefClass(RefClass refClass)
Finds the Java interface corresponding to a JMI class. |
|
static Class<? extends RefObject> |
getJavaInterfaceForRefObject(RefClass refClass)
Finds the Java interface corresponding to object instances of a JMI class. |
|
static Class<? extends RefPackage> |
getJavaInterfaceForRefPackage(RefPackage refPackage)
Finds the Java interface corresponding to a JMI package. |
|
static int |
getMaxLength(RefClass refClass,
Attribute attr)
|
|
static String |
getMetaObjectName(RefBaseObject refObject)
Gets the name of the model element corresponding to a RefBaseObject |
|
static
|
getNamedFeature(RefClass refClass,
Class<T> filterClass,
String featureName,
boolean includeMultiValued)
Limits the result of getFeatures(RefClass, Class, boolean) to
the first feature with the given name. |
|
static long |
getObjectId(RefObject refObject)
Gets the 64-bit object ID for a JMI object. |
|
static RefPackage |
getSubPackage(RefPackage rootPackage,
String[] names,
int prefix)
Looks up a subpackage by name. |
|
static String |
getTypeName(RefObject refObject)
Returns the type name of an object. |
|
static Collection<RefBaseObject> |
importFromXmiString(RefPackage extent,
String string)
Imports a collection of JMI objects from XMI. |
|
static boolean |
isBlank(String value)
Tests an attribute value to see if it is blank. |
|
static RefObject |
newClone(RefObject refObject)
Clones a RefObject. |
|
static void |
setAttributeValues(RefObject dst,
SortedMap<String,Object> map)
Sets values for attributes of a RefObject. |
|
static void |
setMandatoryPrimitiveDefaults(RefObject obj)
Sets default values for mandatory attributes of primitive type (e.g. |
|
static String |
toMofId(long objectId)
Gets the MofId for a given 64-bit object ID for a JMI object. |
|
static String |
toString(RefClass refClass)
Returns the name of a class. |
|
static String |
toString(RefObject refObject)
Generates a string describing an object and its attributes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int DEFAULT_MAX_STRING_LENGTH
Constructor Detail |
---|
public JmiObjUtil()
Method Detail |
---|
public static SortedMap<String,Object> getAttributeValues(RefObject src)
src
- RefObject to query
public static void setAttributeValues(RefObject dst, SortedMap<String,Object> map)
dst
- object to modifymap
- see return of getAttributeValuesprivate static boolean compositeEquals(RefObject obj1, RefObject obj2)
public static <T extends StructuralFeature> List<T> getFeatures(RefClass refClass, Class<T> filterClass, boolean includeMultiValued)
refClass
- class of interestfilterClass
- only objects which are instances of this Class will be
returned; so, for example, pass Attribute.class if you want only
attributes, or StructuralFeature.class if you want everythingincludeMultiValued
- if true, multi-valued attributes will be
included; otherwise, they will be filtered out
private static <T extends StructuralFeature> void addFeatures(List<T> list, MofClass mofClass, Class<T> filterClass, boolean includeMultiValued)
public static void copyAttributes(RefObject dst, RefObject src)
dst
- RefObject to copy tosrc
- RefObject to copy frompublic static String exportToXmiString(Collection<?> collection)
collection
- JMI objects to be exported
public static Collection<RefBaseObject> importFromXmiString(RefPackage extent, String string)
extent
- targetstring
- string representation of XMI
public static RefObject newClone(RefObject refObject)
refObject
- RefObject to clone; must have neither associations nor
composite types
public static Class<? extends RefClass> getJavaInterfaceForRefClass(RefClass refClass) throws ClassNotFoundException
refClass
- the JMI class
ClassNotFoundException
public static Class<? extends RefAssociation> getJavaInterfaceForRefAssoc(RefAssociation refAssoc) throws ClassNotFoundException
refAssoc
- the JMI association
ClassNotFoundException
public static Class<? extends RefObject> getJavaInterfaceForRefObject(RefClass refClass) throws ClassNotFoundException
refClass
- the JMI class
ClassNotFoundException
public static Class<? extends RefPackage> getJavaInterfaceForRefPackage(RefPackage refPackage) throws ClassNotFoundException
refPackage
- the JMI package
ClassNotFoundException
private static <T> Class<? extends T> getJavaInterfaceForProxy(Class<?> proxyClass, Class<T> resultClass, String delimiter) throws ClassNotFoundException
ClassNotFoundException
public static long getObjectId(RefObject refObject)
refObject
- JMI object
public static String toMofId(long objectId)
objectId
- JMI object id (as from getObjectId(RefObject)
)
public static String getTypeName(RefObject refObject)
refObject
- Object
public static String toString(RefClass refClass)
refClass
- Class
public static String toString(RefObject refObject)
Useful for debugging. Typical result:
FemDataWrapper(creationTimestamp='2007-09-02 16:57:22.252', description='null', foreign='true', language='JAVA', libraryFile='class net.sf.farrago.namespace.mdr.MedMdrForeignDataWrapper', lineageId='1dacd3af-9181-47fd-94f3-64fb3a0506a4', modificationTimestamp='2007-09-02 17:21:08.846', name='SYS_MDR', visibility='vk_public')
refObject
- Object
public static RefPackage getSubPackage(RefPackage rootPackage, String[] names, int prefix)
rootPackage
- starting package from which to descendnames
- array of package names representing pathprefix
- number of elements of names to use
public static String getMetaObjectName(RefBaseObject refObject)
refObject
- RefBaseObject representation of a model element
public static String getAccessorName(ModelElement modelElement)
modelElement
- ModelElement to be accessed
public static String getEnumFieldName(String enumSymbol)
enumSymbol
- name of enumeration symbol
public static Class<? extends RefObject> getClassForRefClass(MDRepository repos, RefClass refClass)
RefObject
.class if not found.
repos
- the MDRepository that the given RefClass belongs torefClass
- the reflective JMI class representation
@Deprecated public static Class<? extends RefObject> getClassForRefClass(RefClass refClass)
getClassForRefClass(MDRepository, RefClass)
public static Class<? extends RefObject> getClassForRefClass(ClassLoader classLoader, RefClass refClass, boolean nullIfNotFound)
classLoader
- Class loader. Must not be null: if in doubt, use
ClassLoader.getSystemClassLoader()
refClass
- the reflective JMI class representationnullIfNotFound
- If true, return null if not found; if false, return
RefObject
.class if not found
public static RefBaseObject getContainer(RefBaseObject refObject)
refObject
- object for which to find the container
public static void assertConstraints(RefObject obj)
RefBaseObject.refVerifyConstraints(boolean)
instead
obj
- the object to be verifiedpublic static void setMandatoryPrimitiveDefaults(RefObject obj)
obj
- the object being updatedpublic static <T extends StructuralFeature> T getNamedFeature(RefClass refClass, Class<T> filterClass, String featureName, boolean includeMultiValued)
getFeatures(RefClass, Class, boolean)
to
the first feature with the given name.
refClass
- class of interestfilterClass
- only objects which are instances of this Class will be
returned; so, for example, pass Attribute.class if you want only
attributes, or StructuralFeature.class if you want everythingfeatureName
- name of the feature to returnincludeMultiValued
- if true, multi-valued attributes will be
included; otherwise, they will be filtered out
public static int getMaxLength(RefClass refClass, Attribute attr)
public static boolean isBlank(String value)
value
- Value
public static void dumpGraph(JmiDependencyGraph graph, PrintWriter pw, JmiObjUtil.Namer namer)
graph
- Dependency graphpw
- Writernamer
- Maps JMI objects in the graph to a descriptive stringpublic static void dumpGraph(JmiModelView view, PrintWriter pw)
view
- Model viewpw
- Writer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |