|
Media Authoring with Java API |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttv.amwa.maj.meta.MetaDefinition
tv.amwa.maj.meta.ClassDefinition
@AAFClass(uuid1=218169601, uuid2=513, uuid3=0, uuid4={6,14,43,52,2,6,1,1}, definedName="ClassDefinition", description="The ClassDefinition class is used to programatically represent the class hierarchy defined in the AAF object specification.") public final class ClassDefinition
Implementation of the definition of an AAF class.
THE COMMENTS FOR THIS CLASS ARE INCOMPLETE.
Nested Class Summary | |
---|---|
static class |
ClassDefinition.XMLHandler
|
Constructor Summary | |
---|---|
ClassDefinition(AUID identification,
String className,
ClassDefinition parentClass,
boolean isConcrete)
Creates and initializes a class definition object that inherits from the given parent class. |
Method Summary | |
---|---|
void |
appendXMLChildren(Node parent)
Append child elements to the given parent node to serialize the value of an object to an XML fragment. |
int |
countPropertyDefinitions()
Returns number of property definitions in this class. |
Object |
createInstance()
Creates an instance of this class, and returns it. |
boolean |
deepEquals(Object o)
Check to see if this definition is equal to the given object by comparing each property. |
static ClassDefinition |
forAUID(AUID identification)
|
static ClassDefinition |
forClass(Class<?> aafClass)
For any given Java class, this method finds the corresponding AAF class definition or creates it if it does not yet exists within the current Java virtual machine. |
boolean |
getIsConcrete()
|
String |
getJavaClassName()
|
Class<?> |
getJavaImplementation()
Returns the Java class implementation associated with the defined class. |
ClassDefinition |
getParent()
Gets the Parent class for this class definition. |
Set<PropertyDefinition> |
getPropertyDefinitions()
Returns all of the AAF property definitions attached to the current class. |
PropertyDefinition |
getUniqueIdentifier()
Returns the property definition corresponding to this class' unique identifier. |
static PropertyDefinition |
globalPropertyIDLookup(short tag)
|
boolean |
isConcrete()
Returns true if the defined class can be instantiated; returns false
otherwise. |
boolean |
isRoot()
Returns true if the defined class is the base of the inheritance
hierarchy; returns false otherwise. |
boolean |
isUniquelyIdentified()
Returns true if the defined class is uniquely identified, which means that it
has a single property that is a unique identifier for any given instance. |
PropertyDefinition |
lookupPropertyDefinition(AUID propertyID)
Looks up and returns the property definition corresponding to the given AUID in the set of propertise defined for this class. |
PropertyDefinition |
lookupPropertyDefinition(short propertyTag)
|
PropertyDefinition |
lookupPropertyDefinition(String propertyName)
|
PropertyDefinition |
registerNewPropertyDefinition(AUID identification,
String name,
TypeDefinition typeDefinition,
boolean isOptional,
boolean isUniqueIdentifier,
Short pid)
Creates a new property definition and registers it in this class definition. |
PropertyDefinition |
registerOptionalPropertyDefinition(AUID identification,
String name,
TypeDefinition typeDefinition)
Creates a new property definition and registers it in this class definition. |
void |
setJavaImplementation(Class<?> javaImplementation)
Sets the Java class implementation associated with the defined class. |
void |
setPropertiesFromInterface(ClassDefinition castFrom)
|
Methods inherited from class tv.amwa.maj.meta.MetaDefinition |
---|
castFromInterface, equals, getAUID, getDescription, getIdentification, getName, hashCode, setDescription, setName, setPropertiesFromInterface, toString |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface tv.amwa.maj.iface.MetaDefinition |
---|
getAUID, getDescription, getName, setDescription, setName |
Methods inherited from interface tv.amwa.maj.meta.MAJCommon |
---|
equals, hashCode, toString |
Constructor Detail |
---|
public ClassDefinition(AUID identification, String className, ClassDefinition parentClass, boolean isConcrete) throws NullPointerException
Creates and initializes a class definition object that inherits from the
given parent class. If the is concrete property is set to true
, objects of
this class can be instantiated; otherwise, it will be illegal to
instantiate such objects.
When creating the class implementation, it is advisable to set the Java
class implementation of the given definition using
setJavaImplementation(Class)
.
identification
- Identification of the new class definition.className
- Friendly name of the new class definition.parentClass
- Specifies the parent of the class being defined from
which this class inherits. If set to null
, the new definition is
assumed to be for a root class.isConcrete
- Can objects of this class be instantiated?
NullPointerException
- The identification argument is null
.Method Detail |
---|
public static final ClassDefinition forClass(Class<?> aafClass) throws NullPointerException, IllegalArgumentException
For any given Java class, this method finds the corresponding AAF class definition or creates it if it does not yet exists within the current Java virtual machine. The creation of class definitions is done by lazy evaluation as required using Java reflection and annotations. All generated values are cached in a local, static hashtable so that once generated, the work is not repeated.
The values returned by this method are only as good as the annotations provided with
the sourcecode, as labelled using AAFClass
and AAFProperty
. If an AAFClass
annotation is not present in the given class, an IllegalArgumentException
is thrown. Any
problems found with the AAFProperty
annotations, such as two properties having the same
name, will also result in an IllegalArgumentException
.
aafClass
- Java class to find the AAF class definition of.
NullPointerException
- The given Java class is null
.
IllegalArgumentException
- The given Java class is not annotated with AAFClass
or
the AAFProperty
annotations contain errors.public final void setPropertiesFromInterface(ClassDefinition castFrom)
MetaDefinition.setPropertiesFromInterface(tv.amwa.maj.iface.MetaDefinition)
public int countPropertyDefinitions()
ClassDefinition
Returns number of property definitions in this class.
countPropertyDefinitions
in interface ClassDefinition
public Object createInstance() throws NotImplementedException
ClassDefinition
Creates an instance of this class, and returns it. This method is not supported in the
MAJ API and will always throw a NotImplementedException
. Use implementations of the
AAF factory instead.
createInstance
in interface ClassDefinition
NotImplementedException
public String getJavaClassName() throws PropertyNotPresentException
PropertyNotPresentException
public Class<?> getJavaImplementation() throws PropertyNotPresentException
ClassDefinition
Returns the Java class implementation associated with the defined class.
getJavaImplementation
in interface ClassDefinition
PropertyNotPresentException
- The optional java implementation property is not present
in this AAF class definition.AAFClass
,
forClass(Class)
public void setJavaImplementation(Class<?> javaImplementation)
ClassDefinition
Sets the Java class implementation associated with the defined class.
setJavaImplementation
in interface ClassDefinition
javaImplementation
- Java class implementation associated with this AAF class definition.AAFClass
,
forClass(Class)
@AAFProperty(uuid1=100729095, uuid2=256, uuid3=0, uuid4={6,14,43,52,1,1,1,2}, definedName="ParentClass", typeName="WeakReference to ClassDefinition", optional=false, uniqueIdentifier=false, pid=8) public ClassDefinition getParent()
ClassDefinition
Gets the Parent class for this class definition. If there is no parent then
null
is returned. The only classes which have no parent will
be InterchangeObject
and MetaDefinition
. These classes return
themselves as their own parents to indicate that they are the root of the
type hierarchy.
getParent
in interface ClassDefinition
null
if no parent class has been defined.@AAFProperty(uuid1=100729095, uuid2=512, uuid3=0, uuid4={6,14,43,52,1,1,1,2}, definedName="Properties", typeName="StrongReferenceSet of PropertyDefinition", optional=true, uniqueIdentifier=false, pid=9) public Set<PropertyDefinition> getPropertyDefinitions()
ClassDefinition
Returns all of the AAF property definitions attached to the current class.
getPropertyDefinitions
in interface ClassDefinition
public PropertyDefinition getUniqueIdentifier()
ClassDefinition
Returns the property definition corresponding to this class' unique identifier.
getUniqueIdentifier
in interface ClassDefinition
null
if the class does not have a unique identifier
property definition.ClassDefinition.isUniquelyIdentified()
,
PropertyDefinition.getIsUniqueIdentifier()
public boolean isConcrete()
ClassDefinition
Returns true
if the defined class can be instantiated; returns false
otherwise. If the class is not concrete,
then it is abstract and implemented by an abstract Java class in the MAJ API.
Any object in an AAF file that belongs to an
abstract class shall also belong to a concrete subclass of the
abstract class.
isConcrete
in interface ClassDefinition
@AAFProperty(uuid1=100729095, uuid2=768, uuid3=0, uuid4={6,14,43,52,1,1,1,2}, definedName="IsConcrete", typeName="Boolean", optional=false, uniqueIdentifier=false, pid=10) public boolean getIsConcrete()
public boolean isRoot()
ClassDefinition
Returns true
if the defined class is the base of the inheritance
hierarchy; returns false
otherwise.
isRoot
in interface ClassDefinition
public boolean isUniquelyIdentified()
ClassDefinition
Returns true
if the defined class is uniquely identified, which means that it
has a single property that is a unique identifier for any given instance.
isUniquelyIdentified
in interface ClassDefinition
ClassDefinition.getUniqueIdentifier()
,
PropertyDefinition.getIsUniqueIdentifier()
public PropertyDefinition lookupPropertyDefinition(AUID propertyID) throws NullPointerException, BadParameterException
ClassDefinition
Looks up and returns the property definition corresponding to the given AUID in the set of propertise defined for this class.
lookupPropertyDefinition
in interface ClassDefinition
propertyID
- AUID identifying the property to look up.
NullPointerException
- The given property identifier is null
.
BadParameterException
- The given property identifier is not registered as a property definition for
this class.public PropertyDefinition lookupPropertyDefinition(String propertyName) throws NullPointerException, BadParameterException
NullPointerException
BadParameterException
public PropertyDefinition lookupPropertyDefinition(short propertyTag) throws BadParameterException
BadParameterException
public static final PropertyDefinition globalPropertyIDLookup(short tag)
public PropertyDefinition registerNewPropertyDefinition(AUID identification, String name, TypeDefinition typeDefinition, boolean isOptional, boolean isUniqueIdentifier, Short pid) throws NullPointerException, AlreadyUniquelyIdentifiedException, ObjectAlreadyAttachedException
ClassDefinition
Creates a new property definition and registers it in this class definition. The new property definition is returned.
Note that it is illegal to add mandatory properties to an existing
(registered) class. This method will allow adding
either optional or mandatory properties to a class, but they must
be added to a class which has not yet been registered in the
dictionary. If this class has already been registered, it is
possible to add optional properties, but not through this
method. Optional properties added to an existing (registered)
class may be added through the InterchangeObject.createOptionalPropertyValue(PropertyDefinition, Object)
method.
registerNewPropertyDefinition
in interface ClassDefinition
identification
- AUID to be used to identify this property.name
- Name of the new property.typeDefinition
- Type of the new property.isOptional
- True if new property is to be optional.isUniqueIdentifier
- True if new property is to be the unique
identifier of the class.pid
- Short tag used to identify the property, or null
if it is not known.
NullPointerException
- One of the name or type definition arguments is null.
AlreadyUniquelyIdentifiedException
- This class already has
a unique identifier property.
ObjectAlreadyAttachedException
- A property with the given identifier has already been registered.Dictionary.getClassDefinitions()
,
PropertyDefinition
,
InterchangeObject.createOptionalPropertyValue(PropertyDefinition, Object)
public PropertyDefinition registerOptionalPropertyDefinition(AUID identification, String name, TypeDefinition typeDefinition) throws NullPointerException, ObjectAlreadyAttachedException
ClassDefinition
Creates a new property definition and registers it in this class definition. The new property definition is returned.
Note that it is illegal to add mandatory properties to an already
existing (registered) class. It is assumed that this property is
being added to a class which is already registered. If so, it
must be optional and this method will declare it so. If it is
wished to add a mandatory property, that may be done through the
registerNewPropertyDef()
method, but that must be called on
a class which is not yet registered.
registerOptionalPropertyDefinition
in interface ClassDefinition
identification
- AUID to be used to identify this property.name
- Name of the new property.typeDefinition
- Type of the new property.
NullPointerException
- Name or typeDef argument is null.
ObjectAlreadyAttachedException
- The given property identifier has already been registered.public final boolean deepEquals(Object o)
MetaDefinition
Check to see if this definition is equal to the given object by comparing each
property. The MetaDefinition.equals(Object)
method only checks that the identies of two
definitions are equal, relying on the unqiueness ensured by identity registration.
This method is provided for debugging and validation purposes.
deepEquals
in class MetaDefinition
o
- Object to compare to this definition.
MetaDefinition.deepEquals(java.lang.Object)
public void appendXMLChildren(Node parent)
XMLSerializable
Append child elements to the given parent node to serialize the value of an object
to an XML fragment. Methods of the XMLBuilder
class are provided to help with this
process.
appendXMLChildren
in interface XMLSerializable
appendXMLChildren
in class MetaDefinition
parent
- XML parent element to append child nodes to.public static final ClassDefinition forAUID(AUID identification)
|
Media Authoring with Java API |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |