Media Authoring
with Java API

tv.amwa.maj.embeddable
Class EdgecodeValue

java.lang.Object
  extended by tv.amwa.maj.embeddable.EdgecodeValue
All Implemented Interfaces:
Serializable, Cloneable, MAJCommon, XMLSerializable, EdgecodeValue

public final class EdgecodeValue
extends Object
implements EdgecodeValue, Serializable, XMLSerializable, Cloneable, MAJCommon

Implementation of a value that represents film edge code information. The properties of an edgecode are specified by the AAF edgecode class.

The internal representation of the header is as a byte array. Conversion to and from Java String values can take place using setHeaderFromString(String) and getHeaderAsString().

An edgecode value can be represented in a database by the following columns:

     `CodeFormat` int(11) NOT NULL,
     `FilmKind` int(11) NOT NULL,
     `StartFrame` bigint(20) NOT NULL,
     `Header` tinyblob
 

Author:
Richard Cartwright
See Also:
EdgecodeSegment, EdgecodeHeader, Serialized Form

Field Summary
static String CODEFORMAT_TAG
           
static String FILMKIND_TAG
           
static String HEADER_TAG
           
static String START_TAG
           
 
Constructor Summary
EdgecodeValue()
          Create a default edgecode value.
EdgecodeValue(long startFrame, FilmType filmKind, EdgeType codeFormat)
          Creates and initializes a new edgecode value.
 
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.
 void appendXMLGrandchildren(Node edgecodeElement)
          Appends the sub-elements of an XML representation of this value to the given XML node, without the enclosing EdgecodeValue tag.
static EdgecodeValue castFromInterface(EdgecodeValue alien)
          Create an instance of this edgecode value implementation using a possibly alien implementation that at least implements tv.amwa.maj.record.EdgecodeValue.
 EdgecodeValue clone()
          Creates a cloned deep copy of this embeddable value.
 boolean equals(Object o)
          Two edgecode values are equals if and only if each of their properties are equals.
 EdgeType getCodeFormat()
          Returns the format of the edge code.
 FilmType getFilmKind()
          Returns the film type of this edge code.
 byte[] getHeader()
          Returns the text prefix that identifies the film.
 String getHeaderAsString()
          Returns the value of the edge code header as a string.
 long getStartFrame()
          Returns the edge code at the beginning of the corresponding segment.
 int hashCode()
          Returns a hash code value for this embeddable object.
 void setCodeFormat(EdgeType codeFormat)
          Sets the format of the edge code.
 void setFilmKind(FilmType filmKind)
          Sets the type of film for this edge code.
 void setHeader(byte[] header)
          Sets the text prefix that identifies the film.
 void setHeaderFromString(String header)
          Set the value of the edge code header from the given string.
 void setPropertiesFromInterface(EdgecodeValue castFrom)
          Set the properties of this value from those available in the given value, which is specified by the edgecode value interface.
 void setStartFrame(long startFrame)
          Sets the edge code at the beginning of the corresponding segment.
 String toString()
          Formats this edgecode value in a pseudo-XML representation that is compatible with the AAF XML schema.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

START_TAG

public static final String START_TAG
See Also:
Constant Field Values

FILMKIND_TAG

public static final String FILMKIND_TAG
See Also:
Constant Field Values

CODEFORMAT_TAG

public static final String CODEFORMAT_TAG
See Also:
Constant Field Values

HEADER_TAG

public static final String HEADER_TAG
See Also:
Constant Field Values
Constructor Detail

EdgecodeValue

public EdgecodeValue(@PositionType
                     long startFrame,
                     FilmType filmKind,
                     EdgeType codeFormat)
              throws NullPointerException

Creates and initializes a new edgecode value.

Parameters:
startFrame - Specifies the edge code at the beginning of the corresponding segment.
filmKind - Specifies the type of film.
codeFormat - Specifies the edge code format.
Throws:
NullPointerException - One or more of the arguments is/are null.

EdgecodeValue

public EdgecodeValue()

Create a default edgecode value. The newly created edgecode value has the following initial value:

     <EdgecodeValue>
       <EdgeCodeStart>0</EdgeCodeStart>
       <FilmKind>FtNull</FilmKind>
       <CodeFormat>EtNull</CodeFormat>
       <!-- Header property is omitted -->
     </EdgecodeValue>
 

Method Detail

castFromInterface

public static final EdgecodeValue castFromInterface(EdgecodeValue alien)
                                             throws NullPointerException

Create an instance of this edgecode value implementation using a possibly alien implementation that at least implements tv.amwa.maj.record.EdgecodeValue. If the given value is an instance of this class, the value is returned directly, otherwise a new edgecode value is constructed with an equivalent value to the given value.

Parameters:
alien - Object implementing EdgecodeValue to use to create an instance of this implementation from.
Returns:
Instance of this edgecode value implementation with a value equivalent to that of the given object.
Throws:
NullPointerException - The alien value argument is null.
See Also:
setPropertiesFromInterface(tv.amwa.maj.record.EdgecodeValue)

setPropertiesFromInterface

public final void setPropertiesFromInterface(EdgecodeValue castFrom)

Set the properties of this value from those available in the given value, which is specified by the edgecode value interface.

Parameters:
castFrom - Value to extract properties from.
Throws:
NullPointerException - The given value to use to set this value is null.
See Also:
castFromInterface(tv.amwa.maj.record.EdgecodeValue)

getCodeFormat

public EdgeType getCodeFormat()
Description copied from interface: EdgecodeValue

Returns the format of the edge code.

Specified by:
getCodeFormat in interface EdgecodeValue
Returns:
Format of the edge code.

setCodeFormat

public void setCodeFormat(EdgeType codeFormat)
                   throws NullPointerException
Description copied from interface: EdgecodeValue

Sets the format of the edge code.

Specified by:
setCodeFormat in interface EdgecodeValue
Parameters:
codeFormat - Format of the edge code.
Throws:
NullPointerException - The given edge code format is null.

getFilmKind

public FilmType getFilmKind()
Description copied from interface: EdgecodeValue

Returns the film type of this edge code.

Specified by:
getFilmKind in interface EdgecodeValue
Returns:
Type of film for this edge code.

setFilmKind

public void setFilmKind(FilmType filmKind)
                 throws NullPointerException
Description copied from interface: EdgecodeValue

Sets the type of film for this edge code.

Specified by:
setFilmKind in interface EdgecodeValue
Parameters:
filmKind - Type of film for this edge code.
Throws:
NullPointerException - The given film type for the edge code is null.

getHeader

@EdgecodeHeader
public byte[] getHeader()
                 throws PropertyNotPresentException
Description copied from interface: EdgecodeValue

Returns the text prefix that identifies the film. Typically, this is a text string of no more than 8 7-bit ISO characters. This is an optional property.

Specified by:
getHeader in interface EdgecodeValue
Returns:
Text prefix that identifies the film.
Throws:
PropertyNotPresentException - The optional header property is not present for this edgecode value.
See Also:
getHeaderAsString()

setHeader

public void setHeader(@EdgecodeHeader
                      byte[] header)
Description copied from interface: EdgecodeValue

Sets the text prefix that identifies the film. Typically, this is a text string of no more than 8 7-bit ISO characters. Set the value to null to omit this optoinal property.

To convert a String to an array of bytes, use String.getBytes(String).

Specified by:
setHeader in interface EdgecodeValue
Parameters:
header - Text prefix that identifies the film.
See Also:
setHeaderFromString(String)

getHeaderAsString

public String getHeaderAsString()
                         throws PropertyNotPresentException

Returns the value of the edge code header as a string. Conversion to bytes takes place using the platforms default character set, using String.String(byte[]).

Returns:
String representation of the edge code header.
Throws:
PropertyNotPresentException - The optional header property is not present in this edgecode value.
See Also:
getHeader()

setHeaderFromString

public void setHeaderFromString(String header)
                         throws NullPointerException

Set the value of the edge code header from the given string. Conversion to bytes takes place using the platforms default character set, according to String.String(byte[]).

Parameters:
header - String representation of the edge code header.
Throws:
NullPointerException
See Also:
setHeader(byte[])

getStartFrame

public long getStartFrame()
Description copied from interface: EdgecodeValue

Returns the edge code at the beginning of the corresponding segment.

Specified by:
getStartFrame in interface EdgecodeValue
Returns:
Edge code the the beginning of the corresponding segment.

setStartFrame

public void setStartFrame(long startFrame)
Description copied from interface: EdgecodeValue

Sets the edge code at the beginning of the corresponding segment.

Specified by:
setStartFrame in interface EdgecodeValue
Parameters:
startFrame - Edge code the the beginning of the corresponding segment.

equals

public boolean equals(Object o)

Two edgecode values are equals if and only if each of their properties are equals.

Specified by:
equals in interface MAJCommon
Overrides:
equals in class Object
Parameters:
o - Object to test for equality with.
Returns:
Is the given object equals to this value?
See Also:
Object.equals(java.lang.Object)

toString

public String toString()

Formats this edgecode value in a pseudo-XML representation that is compatible with the AAF XML schema. For example:

     <EdgecodeValue>
       <EdgeCodeStart>321</EdgeCodeStart>
       <FilmKind>Ft35MM</FilmKind>
       <CodeFormat>EtKeycode</CodeFormat>
       <!--Header as text: 'abcdefgh'-->
       <EdgeCodeHeader>6162636465666768</EdgeCodeHeader>
     </EdgecodeValue>
 

Specified by:
toString in interface MAJCommon
Overrides:
toString in class Object
Returns:
Pseudo-XML representation of this edgecode value.
See Also:
Object.toString()

clone

public EdgecodeValue clone()
Description copied from interface: MAJCommon

Creates a cloned deep copy of this embeddable value. The clone will be initialized to have the same value as this value but exists independently from then on. Changes to this value will not effect the clone and changes to the clone will not effect this. MAJ API clones are true deep clones with no shared references to areas of memory within the original.

This method does not throw a CloneNotSupportedException as all embeddable values must implement the Cloneable interface.

Specified by:
clone in interface MAJCommon
Overrides:
clone in class Object
Returns:
Independent clone of this value, which is a deep copy.
See Also:
Object.clone()

hashCode

public int hashCode()
Description copied from interface: MAJCommon

Returns a hash code value for this embeddable object.

Specified by:
hashCode in interface MAJCommon
Overrides:
hashCode in class Object
Returns:
Hash code value for this embeddable object.
See Also:
Object.hashCode()

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
Parameters:
parent - XML parent element to append child nodes to.

appendXMLGrandchildren

public void appendXMLGrandchildren(Node edgecodeElement)

Appends the sub-elements of an XML representation of this value to the given XML node, without the enclosing EdgecodeValue tag. This allows the elements of an edgecode to be appended to the XML representation of an edgecode segment.

Parameters:
edgecodeElement - XML node to append start time, film kind, code format and header elements to, which represent this value.

Media Authoring
with Java API

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