EdgeCodeValueImpl (Media Authoring with Java API)
Date: 2016-02-05

tv.amwa.maj.record.impl

## Class EdgeCodeValueImpl

- java.lang.Object
- - tv.amwa.maj.record.impl.EdgeCodeValueImpl

- All Implemented Interfaces:
    Serializable, Cloneable, CommonConstants, XMLSerializable, EdgeCodeValue

      public final class EdgeCodeValueImpl
      extends Object
      implements EdgeCodeValue, Serializable, XMLSerializable, Cloneable, CommonConstants

  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:

           `EdgeCodeFormat` int(11) NOT NULL,
           `EdgeCodeFileFormat` int(11) NOT NULL,
           `EdgeCodeStart` bigint(20) NOT NULL,
           `EdgeCodeHeader` tinyblob

  See Also:
    `EdgeCodeSegmentImpl`, `EdgecodeHeader`, Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CODEFORMAT_TAG`
    `static String` | `FILMKIND_TAG`
    `static String` | `HEADER_TAG`
    `static String` | `START_TAG`

    - ### Fields inherited from interface tv.amwa.maj.constant.CommonConstants

      `AAF_METADICT_NAMESPACE, AAF_METADICT_PREFIX, AAF_XML_NAMESPACE, AAF_XML_PREFIX, ApplicationPluginObjectID, ApplicationPluginsID, MAX_NUM_RGBA_COMPS, MemberOfID, ObjectClassID, ParentClassID, PropertiesID, XMLClassIDAsAttributeName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EdgeCodeValueImpl()` Create a default edgecode value.
    `EdgeCodeValueImpl(long startFrame, FilmType filmKind, EdgeType codeFormat)` Creates and initializes a new edgecode value.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `appendXMLChildren(Node parent)` Append extra 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.
    `EdgeCodeValue` | `clone()` Create a cloned copy of this edgecode value.
    `static String` | `convertHeaderToHexCoding(byte[] edgeCodeHeader)`
    `static byte[]` | `convertHexCodingToHeader(String hexCode)`
    `boolean` | `equals(Object o)` Two edgecode values are equals if and only if each of their properties are equals.
    `String` | `getComment()` Include a comment when serializing a value to XML.
    `FilmType` | `getEdgeCodeFilmFormat()` Returns the film format of the edge code.
    `EdgeType` | `getEdgeCodeFormat()` Returns the format of the edge code.
    `byte[]` | `getEdgeCodeHeader()` Returns the text prefix that identifies the film.
    `String` | `getEdgeCodeHeaderAsString()` Returns the text prefix the identifies the film as a string value.
    `long` | `getEdgeCodeStart()` Returns the edge code at the beginning of the corresponding segment.
    `int` | `hashCode()`
    `static EdgeCodeValue` | `parseFactory(String edgeCodeAsString)` Creates an edge code value from a pseudo-XML representation, including all those generated by `toString()`.
    `void` | `setEdgeCodeFilmFormat(FilmType edgeCodeFilmFormat)` Sets the film format for this edge code.
    `void` | `setEdgeCodeFormat(EdgeType edgeCodeFormat)` Sets the format of the edge code.
    `void` | `setEdgeCodeHeader(byte[] edgeCodeHeader)` Sets the text prefix that identifies the film.
    `void` | `setEdgeCodeHeader(String header)` Set the value of the edge code header from the given string.
    `void` | `setEdgeCodeStart(long edgeCodeStart)` 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

    - #### EdgeCodeValueImpl

          public EdgeCodeValueImpl(@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`.

    - #### EdgeCodeValueImpl

          public EdgeCodeValueImpl()

      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

    - #### getEdgeCodeFormat

          public EdgeType getEdgeCodeFormat()

      Description copied from interface: `EdgeCodeValue`

      Returns the format of the edge code.

      Specified by:
        `getEdgeCodeFormat` in interface `EdgeCodeValue`
      Returns:
        Format of the edge code.
      See Also:
        `EdgeType`

    - #### setEdgeCodeFormat

          public void setEdgeCodeFormat(EdgeType edgeCodeFormat)
                                 throws NullPointerException

      Description copied from interface: `EdgeCodeValue`

      Sets the format of the edge code.

      Specified by:
        `setEdgeCodeFormat` in interface `EdgeCodeValue`
      Parameters:
        `edgeCodeFormat` - Format of the edge code.
      Throws:
        `NullPointerException` - The given edge code format is `null`.

    - #### getEdgeCodeFilmFormat

          public FilmType getEdgeCodeFilmFormat()

      Description copied from interface: `EdgeCodeValue`

      Returns the film format of the edge code.

      Specified by:
        `getEdgeCodeFilmFormat` in interface `EdgeCodeValue`
      Returns:
        Film format for this edge code.
      See Also:
        `FilmType`

    - #### setEdgeCodeFilmFormat

          public void setEdgeCodeFilmFormat(FilmType edgeCodeFilmFormat)
                                     throws NullPointerException

      Description copied from interface: `EdgeCodeValue`

      Sets the film format for this edge code.

      Specified by:
        `setEdgeCodeFilmFormat` in interface `EdgeCodeValue`
      Parameters:
        `edgeCodeFilmFormat` - Film format for this edge code.
      Throws:
        `NullPointerException` - The given film type for the edge code is `null`.

    - #### getEdgeCodeHeader

          @EdgecodeHeader
          public byte[] getEdgeCodeHeader()
                                                   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:
        `getEdgeCodeHeader` 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()`

    - #### setEdgeCodeHeader

          public void setEdgeCodeHeader(@EdgecodeHeader
                                        byte[] edgeCodeHeader)

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

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

      Specified by:
        `setEdgeCodeHeader` in interface `EdgeCodeValue`
      Parameters:
        `edgeCodeHeader` - Text prefix that identifies the film.
      See Also:
        `#setHeaderFromString(String)`

    - #### getEdgeCodeHeaderAsString

          public String getEdgeCodeHeaderAsString()
                                           throws PropertyNotPresentException

      Description copied from interface: `EdgeCodeValue`

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

      Specified by:
        `getEdgeCodeHeaderAsString` in interface `EdgeCodeValue`
      Returns:
        Text prefix that identifies the film as a string.
      Throws:
        `PropertyNotPresentException` - The optional header property is not present for this edgecode value.
      See Also:
        `EdgeCodeValue.getEdgeCodeHeader()`, `EdgeCodeValue.setEdgeCodeHeader(String)`

    - #### setEdgeCodeHeader

          public void setEdgeCodeHeader(String header)

      Description copied from interface: `EdgeCodeValue`

      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[])`.

      Specified by:
        `setEdgeCodeHeader` in interface `EdgeCodeValue`
      Parameters:
        `header` - String representation of the edge code header.
      See Also:
        `EdgeCodeValue.setEdgeCodeHeader(byte[])`

    - #### getEdgeCodeStart

          public long getEdgeCodeStart()

      Description copied from interface: `EdgeCodeValue`

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

      Specified by:
        `getEdgeCodeStart` in interface `EdgeCodeValue`
      Returns:
        Edge code the the beginning of the corresponding segment.

    - #### setEdgeCodeStart

          public void setEdgeCodeStart(long edgeCodeStart)

      Description copied from interface: `EdgeCodeValue`

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

      Specified by:
        `setEdgeCodeStart` in interface `EdgeCodeValue`
      Parameters:
        `edgeCodeStart` - 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.

      Overrides:
        `equals` in class `Object`
      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 `EdgeCodeValue`
      Overrides:
        `toString` in class `Object`
      Returns:
        Pseudo-XML representation of this edgecode value.
      See Also:
        `Object.toString()`

    - #### parseFactory

          public static final EdgeCodeValue parseFactory(String edgeCodeAsString)
                                                  throws NullPointerException,
                                                         ParseException

      Creates an edge code value from a pseudo-XML representation, including all those generated by `toString()`. Edge code values are intended to match those generated for the AAF XML schema.

      An example edge code representation that would be parsed by this method is:

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

      Note that any unrecognised values will result in the setting of a default value rather than an error. Parse exceptions are only thrown when the validity of a value can only be determined beyond matching a simple regular expression.

      Parameters:
        `edgeCodeAsString` - Pseudo-XML representation of an edge code value.
      Returns:
        Edge code value with values with component values parsed from the given string.
      Throws:
        `NullPointerException` - The given string value is `null`.
        `ParseException` - A problem occurred when trying to decode the given string.
      See Also:
        `toString()`

    - #### clone

          public EdgeCodeValue clone()

      Description copied from interface: `EdgeCodeValue`

      Create a cloned copy of this edgecode value.

      Specified by:
        `clone` in interface `EdgeCodeValue`
      Overrides:
        `clone` in class `Object`
      Returns:
        Cloned copy of this edgecode value.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### appendXMLChildren

          public void appendXMLChildren(Node parent)

      Description copied from interface: `XMLSerializable`

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

    - #### convertHeaderToHexCoding

          public static final String convertHeaderToHexCoding(byte[] edgeCodeHeader)

    - #### convertHexCodingToHeader

          public static final byte[] convertHexCodingToHeader(String hexCode)
                                                       throws NumberFormatException

      Throws:
        `NumberFormatException`

    - #### getComment

          public String getComment()

      Description copied from interface: `XMLSerializable`

      Include a comment when serializing a value to XML. The comment will be inserted as the first child node of the element representing the class.

      Specified by:
        `getComment` in interface `XMLSerializable`
      Returns:
        Comment to add as the first child node of the element representing this class.

(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.