@MediaClass(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.", symbol="ClassDefinition") public final class ClassDefinitionImpl extends MetaDefinitionImpl implements ClassDefinition, Serializable, XMLSerializable, WeakReferenceTarget, CommonConstants, Cloneable
Implementation of the definition of an AAF class.
AAF_METADICT_NAMESPACE, AAF_METADICT_PREFIX, AAF_XML_NAMESPACE, AAF_XML_PREFIX, ApplicationPluginObjectID, ApplicationPluginsID, MAX_NUM_RGBA_COMPS, MemberOfID, ObjectClassID, ParentClassID, PropertiesID, XMLClassIDAsAttributeName| Constructor and Description |
|---|
ClassDefinitionImpl(AUID identification,
String className,
ClassDefinition parentClass,
boolean isConcrete)
Creates and initializes a class definition object that inherits from the
given parent class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyDefinition(PropertyDefinition propertyDefinition) |
void |
appendMetadictXML(Node metadict,
String namespace,
String prefix)
Append an XML representation of this meta definition to the given XML node.
|
void |
clearPropertyDefinitions() |
ClassDefinition |
clone()
Create a cloned copy of this meta definition.
|
boolean |
containsPropertyDefinition(PropertyDefinition propertyDefinition) |
static int |
countClassDefinitions() |
int |
countProperties(MetadataObject metadataObject)
Returns the number of properties currently present in the
given metadata object, including all required properties.
|
int |
countPropertyDefinitions()
Returns number of property definitions in this class.
|
MetadataObject |
createInstance()
Creates an instance of this class and returns it, or
null if the instantiation
failed. |
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.
|
Set<PropertyDefinition> |
getAllPropertyDefinitions()
Returns all AAF property definitions attached directly to the
current class and its ancestors.
|
static Collection<ClassDefinition> |
getClassDefinitions() |
String |
getComment()
Include a comment when serializing a value to XML.
|
EmitXMLClassIDAs |
getEmitXMLClassIDAs()
Determines how the identifier of the class should be serialized to XML.
|
boolean |
getIsConcrete() |
String |
getJavaClassName() |
Class<?> |
getJavaImplementation()
Returns the Java class implementation associated with the defined class.
|
String |
getNamespace()
Returns the namespace in which the subject of this meta definition is defined.
|
ClassDefinition |
getParent()
Gets the Parent class for this class definition.
|
String |
getPrefix()
Returns the namespace prefix to use when serializing a value of the subject of this meta
definition to XML.
|
SortedMap<? extends PropertyDefinition,? extends PropertyValue> |
getProperties(MetadataObject metadataObject)
Returns the set of properties of the given object,
where each property contains its property definition
and current value.
|
Set<PropertyDefinition> |
getPropertyDefinitions()
Returns the AAF property definitions attached directly to the
current class.
|
PropertyDefinition |
getUniqueIdentifierProperty()
Returns the property definition corresponding to this class'
unique identifier.
|
PropertyValue |
getUniqueIdentifierValue(MetadataObject uniquelyIdentifiedObject)
Returns the current value of the unique identifier for a value of a type
defined by this class definition.
|
String |
getWeakTargetReference()
Provides a name that can be used to make a weak object reference to an
instance of the implementing class.
|
static PropertyDefinition |
globalPropertyIDLookup(AUID propertyID) |
static void |
initalizeClassNameMap() |
static boolean |
initializeIsConcrete() |
ClassDefinition |
initializeParentClass() |
boolean |
isConcrete()
Returns
true if the defined class can be instantiated; returns false
otherwise. |
static boolean |
isKnownProperty(PropertyDefinition property) |
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 properties defined for this
class.
|
PropertyDefinition |
lookupPropertyDefinition(short propertyTag)
Looks up and returns the property definition corresponding to
the given short tag in the set of all properties defined for this class.
|
PropertyDefinition |
lookupPropertyDefinition(String propertyName)
Looks up and returns the property definition corresponding to
the given name in the set of all properties defined for this class.
|
String |
nameToAAFName(String name) |
PropertyDefinition |
registerNewPropertyDefinition(AUID identification,
String name,
String[] aliases,
String symbol,
String typeName,
boolean isOptional,
boolean isUniqueIdentifier,
Short pid)
Creates a new property definition and registers it in this class
definition.
|
PropertyDefinition |
registerOptionalPropertyDefinition(AUID identification,
String name,
String[] aliases,
String symbol,
String typeName)
Creates a new property definition and registers it in this class
definition.
|
void |
removePropertyDefinition(PropertyDefinition propertyDefinition) |
void |
setIsConcrete(boolean concrete) |
void |
setJavaImplementation(Class<?> javaImplementation)
Sets the Java class implementation associated with the defined class.
|
void |
setParent(ClassDefinition parent) |
aafNameToName, appendXMLChildren, deepEquals, equals, getAAFNamesInUse, getAliases, getAUID, getDescription, getIdentification, getName, getSymbol, hashCode, initializeMetaDefinitionIdentification, initializeMetaDefinitionName, setAAFNamesInUse, setAliases, setDescription, setIdentification, setName, setNamespace, setPrefix, setSymbol, toStringgetSymboldeepEquals, equals, getAAFNamesInUse, getAliases, getAUID, getDescription, getName, hashCode, setAAFNamesInUse, setDescription, setName, setNamespace, setPrefix, setSymbol, toStringappendXMLChildrenpublic ClassDefinitionImpl(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.public static final void initalizeClassNameMap()
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 MediaClass and MediaProperty. If an MediaClass
annotation is not present in the given class, an IllegalArgumentException is thrown. Any
problems found with the MediaProperty 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 MediaClass or
the MediaProperty annotations contain errors.tv.amwa.maj.industry.ClassDefinitionWarehouse@MediaPropertyCount(value="Properties") public int countPropertyDefinitions()
ClassDefinitionReturns number of property definitions in this class.
countPropertyDefinitions in interface ClassDefinition@MediaPropertyClear(value="Properties") public void clearPropertyDefinitions()
public MetadataObject createInstance()
ClassDefinitionCreates an instance of this class and returns it, or null if the instantiation
failed. This method is not the recommended way of creating objects in the MAJ API as the values
of the class will not be initialized to sensible values. To create implementations of the objects safely,
use the make methods of the media engine instead.
This method is provided for implementations of file reading mechanisms that need to create uninitialized objects before setting all required properties from the input stream.
createInstance in interface ClassDefinitionnull if the
instantiation failed.Forge.make(Class, Object...)public String getJavaClassName() throws PropertyNotPresentException
PropertyNotPresentExceptionpublic Class<?> getJavaImplementation() throws PropertyNotPresentException
ClassDefinitionReturns the Java class implementation associated with the defined class.
getJavaImplementation in interface ClassDefinitionPropertyNotPresentException - The optional java implementation property is not present
in this AAF class definition.MediaClass,
Warehouse.lookForClass(Class)public void setJavaImplementation(Class<?> javaImplementation)
ClassDefinitionSets the Java class implementation associated with the defined class.
setJavaImplementation in interface ClassDefinitionjavaImplementation - Java class implementation associated with this AAF class definition.MediaClass,
Warehouse.lookForClass(Class)@MediaProperty(uuid1=100729095, uuid2=256, uuid3=0, uuid4={6,14,43,52,1,1,1,2}, definedName="ParentClass", typeName="ClassDefinitionWeakReference", optional=false, uniqueIdentifier=false, pid=8, symbol="ParentClass") public ClassDefinition getParent()
ClassDefinitionGets 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 ClassDefinitionnull if no parent class has been defined.@MediaPropertySetter(value="ParentClass") public void setParent(ClassDefinition parent) throws NullPointerException
NullPointerExceptionpublic ClassDefinition initializeParentClass()
@MediaProperty(uuid1=100729095, uuid2=512, uuid3=0, uuid4={6,14,43,52,1,1,1,2}, definedName="Properties", typeName="PropertyDefinitionStrongReferenceSet", optional=true, uniqueIdentifier=false, pid=9, symbol="Properties") public Set<PropertyDefinition> getPropertyDefinitions()
ClassDefinitionReturns the AAF property definitions attached directly to the current class.
getPropertyDefinitions in interface ClassDefinitionClassDefinition.getAllPropertyDefinitions(),
TypeDefinitions.PropertyDefinitionStrongReferenceSet@MediaSetAdd(value="Properties") public void addPropertyDefinition(PropertyDefinition propertyDefinition) throws NullPointerException
NullPointerException@MediaPropertyContains(value="Properties") public boolean containsPropertyDefinition(PropertyDefinition propertyDefinition) throws NullPointerException
NullPointerException@MediaPropertyRemove(value="Properties") public void removePropertyDefinition(PropertyDefinition propertyDefinition) throws NullPointerException
NullPointerExceptionpublic PropertyDefinition getUniqueIdentifierProperty()
ClassDefinitionReturns the property definition corresponding to this class' unique identifier.
getUniqueIdentifierProperty in interface ClassDefinitionnull if the class does not have a unique identifier
property definition.ClassDefinition.isUniquelyIdentified(),
PropertyDefinition.getIsUniqueIdentifier(),
ClassDefinition.getUniqueIdentifierValue(MetadataObject)public boolean isConcrete()
ClassDefinitionReturns 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@MediaProperty(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, symbol="IsConcrete") public boolean getIsConcrete()
@MediaPropertySetter(value="IsConcrete") public void setIsConcrete(boolean concrete)
public static final boolean initializeIsConcrete()
public boolean isRoot()
ClassDefinitionReturns true if the defined class is the base of the inheritance
hierarchy; returns false otherwise.
isRoot in interface ClassDefinitionpublic boolean isUniquelyIdentified()
ClassDefinitionReturns 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 ClassDefinitionClassDefinition.getUniqueIdentifierProperty(),
PropertyDefinition.getIsUniqueIdentifier(),
ClassDefinition.getUniqueIdentifierValue(MetadataObject)public PropertyDefinition lookupPropertyDefinition(AUID propertyID) throws NullPointerException, BadParameterException
ClassDefinitionLooks up and returns the property definition corresponding to the given AUID in the set of properties defined for this class.
lookupPropertyDefinition in interface ClassDefinitionpropertyID - 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.ClassDefinition.lookupPropertyDefinition(String),
ClassDefinition.lookupPropertyDefinition(short),
ClassDefinition.getAllPropertyDefinitions(),
TypeDefinitions.PropertyDefinitionWeakReferencepublic PropertyDefinition lookupPropertyDefinition(String propertyName) throws NullPointerException, BadParameterException
ClassDefinitionLooks up and returns the property definition corresponding to the given name in the set of all properties defined for this class. The name may be either the property's defined name, symbol name or one of its aliases.
lookupPropertyDefinition in interface ClassDefinitionpropertyName - String 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.ClassDefinition.lookupPropertyDefinition(AUID),
ClassDefinition.lookupPropertyDefinition(String),
ClassDefinition.getAllPropertyDefinitions()public PropertyDefinition lookupPropertyDefinition(short propertyTag) throws BadParameterException
ClassDefinitionLooks up and returns the property definition corresponding to the given short tag in the set of all properties defined for this class.
Note that not all properties have defined tags, also known as local identification, and tags can be generated automatically when required.
lookupPropertyDefinition in interface ClassDefinitionpropertyTag - Short identifier for the property to look up.BadParameterException - The given property identifier is not registered as a property definition for
this class.ClassDefinition.lookupPropertyDefinition(AUID),
ClassDefinition.lookupPropertyDefinition(String),
ClassDefinition.getAllPropertyDefinitions()public static final PropertyDefinition globalPropertyIDLookup(AUID propertyID)
public PropertyDefinition registerNewPropertyDefinition(AUID identification, String name, String[] aliases, String symbol, String typeName, boolean isOptional, boolean isUniqueIdentifier, Short pid) throws NullPointerException, AlreadyUniquelyIdentifiedException, ObjectAlreadyAttachedException
ClassDefinitionCreates 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 are not supported dynamically in the MAJ API.
registerNewPropertyDefinition in interface ClassDefinitionidentification - AUID to be used to identify this property.name - Name of the new property.aliases - A set of additional names that can be used to identify the property.symbol - Registered data symbol for the property.typeName - Name of the type of value represented by 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.MetaDictionary.getClassDefinitions(),
PropertyDefinition,
ClassDefinition.registerOptionalPropertyDefinition(AUID, String, String[], String, String)public PropertyDefinition registerOptionalPropertyDefinition(AUID identification, String name, String[] aliases, String symbol, String typeName) throws NullPointerException, ObjectAlreadyAttachedException
ClassDefinitionCreates 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
registerNewPropertyDefinition() method, but that must be called on
a class which is not yet registered.
registerOptionalPropertyDefinition in interface ClassDefinitionidentification - AUID to be used to identify this property.name - Name of the new property.aliases - A set of additional names that can be used to identify the property.symbol - Registered data symbol for the property.typeName - Name of the type of value represented by the new property.NullPointerException - Name or typeDef argument is null.ObjectAlreadyAttachedException - The given property identifier has already been registered.ClassDefinition.registerNewPropertyDefinition(AUID, String, String[], String, String, boolean, boolean, Short)public String getComment()
XMLSerializableInclude a comment when serializing a value to XML. The comment will be inserted as the first child node of the element representing the class.
getComment in interface XMLSerializablegetComment in class MetaDefinitionImplpublic static final ClassDefinition forAUID(AUID identification)
public Set<PropertyDefinition> getAllPropertyDefinitions()
ClassDefinitionReturns all AAF property definitions attached directly to the current class and its ancestors.
getAllPropertyDefinitions in interface ClassDefinitionClassDefinition.getPropertyDefinitions(),
ClassDefinition.getProperties(MetadataObject)public int countProperties(MetadataObject metadataObject) throws NullPointerException, IllegalArgumentException
ClassDefinitionReturns the number of properties currently present in the given metadata object, including all required properties.
countProperties in interface ClassDefinitionmetadataObject - Object of this class to count the number of present
properties.NullPointerException - The metadata object is null.IllegalArgumentException - The metadata object is not an instance of
this class.public static final boolean isKnownProperty(PropertyDefinition property)
public SortedMap<? extends PropertyDefinition,? extends PropertyValue> getProperties(MetadataObject metadataObject)
ClassDefinitionReturns the set of properties of the given object, where each property contains its property definition and current value. The set contains both required properties and optional properties that are currently present.
getProperties in interface ClassDefinitionmetadataObject - Object of this class to retrieve the properties for.public String getNamespace()
MetaDefinitionReturns the namespace in which the subject of this meta definition is defined.
getNamespace in interface MetaDefinitiongetNamespace in class MetaDefinitionImplMediaProperty.namespace(),
MediaClass.namespace(),
ExtensionScheme.getSchemeURI()public String getPrefix()
MetaDefinitionReturns the namespace prefix to use when serializing a value of the subject of this meta definition to XML.
getPrefix in interface MetaDefinitiongetPrefix in class MetaDefinitionImplMediaProperty.prefix(),
MediaClass.prefix()public EmitXMLClassIDAs getEmitXMLClassIDAs()
ClassDefinitionDetermines how the identifier of the class should be serialized to XML. For more details, see the description of the emit XML class ID as enumeration.
getEmitXMLClassIDAs in interface ClassDefinitionMediaClass.emitXMLClassID(),
CommonConstants.XMLClassIDAsAttributeNamepublic String getWeakTargetReference()
WeakReferenceTargetProvides a name that can be used to make a weak object reference to an instance of the implementing class.
getWeakTargetReference in interface WeakReferenceTargetgetWeakTargetReference in class MetaDefinitionImplpublic PropertyValue getUniqueIdentifierValue(MetadataObject uniquelyIdentifiedObject) throws NullPointerException, IllegalArgumentException
ClassDefinitionReturns the current value of the unique identifier for a value of a type defined by this class definition. The class must have a unique identifier for this method to by successful.
getUniqueIdentifierValue in interface ClassDefinitionuniquelyIdentifiedObject - Object to find the unique identifier for.NullPointerException - Cannot find the unique identifier for a
null value.IllegalArgumentException - The given object does not have a unique
identifier property.ClassDefinition.isUniquelyIdentified(),
ClassDefinition.getUniqueIdentifierProperty()public static final int countClassDefinitions()
public static final Collection<ClassDefinition> getClassDefinitions()
public String nameToAAFName(String name)
nameToAAFName in class MetaDefinitionImplpublic void appendMetadictXML(Node metadict, String namespace, String prefix)
MetaDefinitionAppend an XML representation of this meta definition to the given XML node.
appendMetadictXML in interface MetaDefinitionappendMetadictXML in class MetaDefinitionImplmetadict - Meta dictionary node to append a description of this node to.CommonConstants.AAF_METADICT_NAMESPACEpublic ClassDefinition clone()
MetaDefinitionCreate a cloned copy of this meta definition.
clone in interface ClassDefinitionclone in interface MetaDefinitionclone in class MetaDefinitionImpl(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.