Media Authoring
with Java API

tv.amwa.maj.iface
Interface TypeDefinitionInteger

All Superinterfaces:
MetaDefinition, TypeDefinition
All Known Implementing Classes:
TypeDefinitionInteger

public interface TypeDefinitionInteger
extends TypeDefinition

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

The representation of integers in the MAJ API is explained in the description of the integer package. The methods of this class cast values of subclasses of Number to values of Java type used to represent an integer value, as described in the type mapping table. The methods here are specified in such a way that rounding or truncations errors should be avoidable

Author:
Richard Cartwright
See Also:
makeTypeDefinitionInteger(), TypeCategory.Int, Int32, UInt8

Method Summary
 PropertyValue createValueFromNumber(Number value)
          Creates a property value as defined by this integer type definition using the given number.
 Number getInteger(PropertyValue integerProperty)
          Returns the value of the given integer property value as a Number.
 byte getSize()
          Returns the size of integral value of the integer type definition, measured in number of bytes.
 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.
 
Methods inherited from interface tv.amwa.maj.iface.TypeDefinition
createValue, getTypeCategory
 
Methods inherited from interface tv.amwa.maj.iface.MetaDefinition
getAUID, getDescription, getName, setDescription, setName
 

Method Detail

createValueFromNumber

PropertyValue createValueFromNumber(Number value)
                                    throws NullPointerException,
                                           BadSizeException,
                                           IllegalArgumentException

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.

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:
setInteger(PropertyValue, Number)

getInteger

Number getInteger(PropertyValue integerProperty)
                  throws NullPointerException,
                         IllegalPropertyValueException

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..

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.

setInteger

void setInteger(PropertyValue integerProperty,
                Number value)
                throws NullPointerException,
                       BadSizeException,
                       IllegalPropertyValueException,
                       IllegalArgumentException

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.

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:
createValueFromNumber(Number)

getSize

@UInt8
byte getSize()

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

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

isSigned

@Bool
boolean isSigned()

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

Returns:
Does the integer type definition define signed integer values?

Media Authoring
with Java API

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