Media Authoring
with Java API

tv.amwa.maj.meta
Class TypeDefinitionInteger

java.lang.Object
  extended by tv.amwa.maj.meta.MetaDefinition
      extended by tv.amwa.maj.meta.TypeDefinition
          extended by tv.amwa.maj.meta.TypeDefinitionInteger
All Implemented Interfaces:
Serializable, DefinitionType, MetaDefinition, TypeDefinition, TypeDefinitionInteger, XMLSerializable, MAJCommon

@AAFClass(uuid1=218169601,
          uuid2=516,
          uuid3=0,
          uuid4={6,14,43,52,2,6,1,1},
          definedName="TypeDefinitionInteger",
          description="The TypeDefinitionInteger class defines a property type that is an integer with the specified number of bytes.")
public final class TypeDefinitionInteger
extends TypeDefinition
implements TypeDefinitionInteger, XMLSerializable, Serializable, MAJCommon

Implements the definition of a property type that is an integer with the specified number of bytes.

THE COMMENTS FOR THIS CLASS ARE INCOMPLETE.

Author:
Richard Cartwright
See Also:
Serialized Form

Nested Class Summary
static class TypeDefinitionInteger.BaseIntegerValue
           
static class TypeDefinitionInteger.ByteValue
           
static class TypeDefinitionInteger.IntegerValue
           
static class TypeDefinitionInteger.LongValue
           
static class TypeDefinitionInteger.ShortValue
           
static class TypeDefinitionInteger.XMLHandler
           
 
Field Summary
static int BYTE
          Number of bytes used to represent a Java byte value.
static int INT
          Number of bytes used to represent a Java int value.
static TypeDefinitionInteger Int16
           
static TypeDefinitionInteger Int32
           
static TypeDefinitionInteger Int64
           
static TypeDefinitionInteger Int8
           
static int LONG
          Number of bytes used to represent a Java long value.
static int SHORT
          Number of bytes used to represent a Java short value.
static TypeDefinitionInteger UInt16
           
static TypeDefinitionInteger UInt32
           
static TypeDefinitionInteger UInt64
           
static TypeDefinitionInteger UInt8
           
 
Constructor Summary
TypeDefinitionInteger(AUID identification, String typeName, byte intSize, boolean isSigned)
          Creates and initializes the integer type definition, which defines a property type that is a signed or an unsigned integer with the specified number of bytes.
 
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.
 PropertyValue createValue(Object javaValue)
          Create a property value from the given Java object.
 PropertyValue createValueFromNumber(Number value)
          Creates a property value as defined by this integer type definition using the given number.
 boolean deepEquals(Object o)
          Check to see if this definition is equal to the given object by comparing each property.
 Number getInteger(PropertyValue integerProperty)
          Returns the value of the given integer property value as a Number.
 boolean getIsSigned()
           
 byte getSize()
          Returns the size of integral value of the integer type definition, measured in number of bytes.
 TypeCategory getTypeCategory()
          Returns the type category to which this type definition belongs, which corresponds to its sub interface.
 boolean isSigned()
          Returns true if the integer type definition defines signed integer values; otherwise false.
 void setInteger(PropertyValue integerProperty, Number value)
          Convert the given number value to one appropriate for this integer type definition and set the value of the given integer property value to be the converted value.
 void setPropertiesFromInterface(TypeDefinitionInteger castFrom)
           
 
Methods inherited from class tv.amwa.maj.meta.TypeDefinition
setPropertiesFromInterface
 
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
 

Field Detail

UInt8

public static final TypeDefinitionInteger UInt8

UInt16

public static final TypeDefinitionInteger UInt16

UInt32

public static final TypeDefinitionInteger UInt32

UInt64

public static final TypeDefinitionInteger UInt64

Int8

public static final TypeDefinitionInteger Int8

Int16

public static final TypeDefinitionInteger Int16

Int32

public static final TypeDefinitionInteger Int32

Int64

public static final TypeDefinitionInteger Int64

BYTE

public static final int BYTE

Number of bytes used to represent a Java byte value.

See Also:
Constant Field Values

SHORT

public static final int SHORT

Number of bytes used to represent a Java short value.

See Also:
Constant Field Values

INT

public static final int INT

Number of bytes used to represent a Java int value.

See Also:
Constant Field Values

LONG

public static final int LONG

Number of bytes used to represent a Java long value.

See Also:
Constant Field Values
Constructor Detail

TypeDefinitionInteger

public TypeDefinitionInteger(AUID identification,
                             @AAFString
                             String typeName,
                             @UInt8
                             byte intSize,
                             @Bool
                             boolean isSigned)
                      throws NullPointerException,
                             IllegalArgumentException

Creates and initializes the integer type definition, which defines a property type that is a signed or an unsigned integer with the specified number of bytes.

The implementation of this method may only allow certain values for the intSize. It will allow at least 1, 2, 4, and 8-byte integers; some implementations may allow more than that.

Creating new and unregistered type definitions is not recommended as this may cause interoperability issues with other systems. The official registry of type definitions is available from SMPTE at SMPTE Metadata Registries And Related Items. The full range of data types documented in the AAF 1.1 object specification can be accessed by name and identification using either AAFFactory.typeDefinitionForName(String) or AAFFactory.typeDefinitionForIdentification(tv.amwa.maj.record.AUID) respectively.

Parameters:
identification - AUID to use to identify this type.
typeName - Friendly name for the integer type definition.
intSize - Number of bytes used to represent a value.
isSigned - Is the integer type signed?
Throws:
NullPointerException - The identification argument is null.
IllegalArgumentException - The implementation does not support the given number of bytes per integer value.
Method Detail

setPropertiesFromInterface

public final void setPropertiesFromInterface(TypeDefinitionInteger castFrom)
See Also:
MetaDefinition.setPropertiesFromInterface(tv.amwa.maj.iface.MetaDefinition)

createValueFromNumber

public PropertyValue createValueFromNumber(Number value)
                                    throws NullPointerException,
                                           IllegalArgumentException,
                                           BadSizeException
Description copied from interface: TypeDefinitionInteger

Creates a property value as defined by this integer type definition using the given number. The given number will he cast to a value that fits with this integer type definition.

It is possible that the given Java value cannot be converted to a value compatible with this integer type definition. If this is the case, an IllegalArgumentException is thrown. Conversion may not be possible for the following reasons:

To specifically cause truncation or rounding to take place, perform an appropriate cast before calling this method.

A BadSizeException may also be thrown if the given value is a BigInteger or BigDecimal value as an implementation is not required to support values greater than 8-bytes in length.

Specified by:
createValueFromNumber in interface TypeDefinitionInteger
Parameters:
value - Value to create a new integer property value from.
Returns:
New integer property value consistent with this integer type definition and set to the given value.
Throws:
NullPointerException - The given number value is null.
IllegalArgumentException - Due to its value, the given value cannot be converted to a property value defined by this integer type definition.
BadSizeException
See Also:
TypeDefinitionInteger.setInteger(PropertyValue, Number)

getInteger

public Number getInteger(PropertyValue integerProperty)
                  throws NullPointerException,
                         IllegalPropertyValueException
Description copied from interface: TypeDefinitionInteger

Returns the value of the given integer property value as a Number. This value can then be converted to the required type by calling Number.intValue(), Number.byteValue() etc..

Specified by:
getInteger in interface TypeDefinitionInteger
Parameters:
integerProperty - Property value of integer type.
Returns:
Integer value represented by an appropriate wrapper type from the java.lang package, e.g. Byte, Integer etc..
Throws:
NullPointerException - The given integer property value is null.
IllegalPropertyValueException - The given integer property value is not as defined by this integer type definition.

getSize

@AAFProperty(uuid1=50397699,
             uuid2=256,
             uuid3=0,
             uuid4={6,14,43,52,1,1,1,2},
             definedName="Size",
             typeName="UInt8",
             optional=false,
             uniqueIdentifier=false,
             pid=15)
public byte getSize()
Description copied from interface: TypeDefinitionInteger

Returns the size of integral value of the integer type definition, measured in number of bytes.

Specified by:
getSize in interface TypeDefinitionInteger
Returns:
Size of integral value of the integer type definition, measured in number of bytes.

isSigned

public boolean isSigned()
Description copied from interface: TypeDefinitionInteger

Returns true if the integer type definition defines signed integer values; otherwise false.

Specified by:
isSigned in interface TypeDefinitionInteger
Returns:
Does the integer type definition define signed integer values?

getIsSigned

@AAFProperty(uuid1=50397699,
             uuid2=512,
             uuid3=0,
             uuid4={6,14,43,52,1,1,1,2},
             definedName="IsSigned",
             typeName="Boolean",
             optional=false,
             uniqueIdentifier=false,
             pid=16)
public boolean getIsSigned()

setInteger

public void setInteger(PropertyValue integerProperty,
                       Number value)
                throws NullPointerException,
                       BadSizeException,
                       IllegalPropertyValueException,
                       IllegalArgumentException
Description copied from interface: TypeDefinitionInteger

Convert the given number value to one appropriate for this integer type definition and set the value of the given integer property value to be the converted value. This method can make use of Java's autoboxing features.

It is possible that the given Java value cannot be converted to a value compatible with the integer type definition. If this is the case, an IllegalArgumentException is thrown. Conversion may not be possible for the following reasons:

To specifically cause truncation or rounding to take place, perform an appropriate cast before calling this method.

Specified by:
setInteger in interface TypeDefinitionInteger
Parameters:
integerProperty - Property value to set the value of.
value - Value to set for the given integer property value to.
Throws:
NullPointerException - One or both of the integer property value and/or number value arguments is/are null.
IllegalPropertyValueException - The given property value is not compatible with this integer type definition.
IllegalArgumentException - Due to its value, the given value cannot be converted to a property value defined by the integer type definition.
BadSizeException
See Also:
TypeDefinitionInteger.createValueFromNumber(Number)

getTypeCategory

public TypeCategory getTypeCategory()
Description copied from interface: TypeDefinition

Returns the type category to which this type definition belongs, which corresponds to its sub interface. For example, TypeCategory.Int is returned for a TypeDefinitionInteger.

Specified by:
getTypeCategory in interface TypeDefinition
Specified by:
getTypeCategory in class TypeDefinition
Returns:
Type category to which the type definition belongs.
See Also:
TypeCategory

createValue

public PropertyValue createValue(Object javaValue)
                          throws ClassCastException
Description copied from class: TypeDefinition

Create a property value from the given Java object. If the type of the object is not compatible with this type definition, a ClassCastException is thrown.

Specified by:
createValue in interface TypeDefinition
Specified by:
createValue in class TypeDefinition
Parameters:
javaValue - Java object to use to create a property value of this type.
Returns:
Property value representing the given value.
Throws:
ClassCastException - The given object cannot be cast to a property value with this type definition.

deepEquals

public final boolean deepEquals(Object o)
Description copied from class: 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.

Overrides:
deepEquals in class MetaDefinition
Parameters:
o - Object to compare to this definition.
Returns:
Is the given object a meta definiition with all of its properties equal to this meta definition?

appendXMLChildren

public void appendXMLChildren(Node parent)
Description copied from interface: 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.

Specified by:
appendXMLChildren in interface XMLSerializable
Overrides:
appendXMLChildren in class MetaDefinition
Parameters:
parent - XML parent element to append child nodes to.

Media Authoring
with Java API

(c) 2007-2008 Richard Cartwright, all rights reserved. Subject to the terms of the AAF SDK Public Source License.