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

tv.amwa.maj.record.impl

## Class RGBAComponentImpl

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

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

      public final class RGBAComponentImpl
      extends Object
      implements RGBAComponent, Serializable, XMLSerializable, Cloneable, CommonConstants

  Implements an element of an array representing the order and size of the component values within a pixel value as part of an RGBA Layout. The RGB layout type type is a fixed-size 8 element array, where each element consists of an RGBA component value. Each RGBA component has with the following fields:

  - `code` - RGBA component kind enumerated value specifying the component kind.
  - `size` - Java byte specifying the number of bits.
  See Also:
    `TypeDefinitions.RGBAComponent`, `RGBADescriptor`, `RGBAComponentKind`, `RGBALayout`, Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `RGBAComponentImpl.XMLHandler` XML parser event handler for converting RGBA component elements into RGBA component values.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `MYSQL_COLUMN_DEFINITION`
    `static String` | `RGBACOMPONENT_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
    `RGBAComponentImpl()` Create a new RGBA component with a `RGBAComponentKind.Null` code and a size of `0`.
    `RGBAComponentImpl(RGBAComponentKind code, byte size)` Create an element of an RGBAComponent array.

  - ### 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.
    `RGBAComponent` | `clone()` Create a cloned copy of this RGBA component value.
    `boolean` | `equals(Object o)`
    `static RGBAComponent` | `fromPersistentForm(String rgbaComponent)`
    `RGBAComponentKind` | `getCode()` Returns the type of an RGBA component.
    `String` | `getComment()` Include a comment when serializing a value to XML.
    `byte` | `getComponentSize()` Returns the size, measured in bits, of the RGBA component.
    `int` | `hashCode()`
    `static RGBAComponentImpl` | `parseFactory(String componentString)` Create a new value of this RGBA component type by parsing the given pseudo-XML representation.
    `void` | `setCode(RGBAComponentKind code)` Sets the type of an RGBA component.
    `void` | `setComponentSize(byte size)` Sets the size, measured in bits, of the RGBA component.
    `static String` | `toPersistentForm(RGBAComponent rgbaComponent)`
    `String` | `toString()` Creates a pseudo-XML string representation of this RGBA component value.

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### RGBACOMPONENT_TAG

          public static final String RGBACOMPONENT_TAG

      See Also:
        Constant Field Values

    - #### MYSQL_COLUMN_DEFINITION

          public static final String MYSQL_COLUMN_DEFINITION

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### RGBAComponentImpl

          public RGBAComponentImpl()

      Create a new RGBA component with a `RGBAComponentKind.Null` code and a size of `0`.

      This constructor is public to allow the `TypeDefinitionRecord#getObject(tv.amwa.maj.model.PropertyValue, Class)` method to create new instances of objects from record property values.

    - #### RGBAComponentImpl

          public RGBAComponentImpl(RGBAComponentKind code,
                                   @UInt8
                                   byte size)
                            throws NullPointerException,
                                   IllegalArgumentException

      Create an element of an RGBAComponent array.

      Parameters:
        `code` - Code for the component.
        `size` - Size of the component in bits.
      Throws:
        `NullPointerException` - The code argument is `null`.
        `IllegalArgumentException` - The size argument is negative.

  - ### Method Detail

    - #### getCode

          public final RGBAComponentKind getCode()

      Description copied from interface: `RGBAComponent`

      Returns the type of an RGBA component.

      Specified by:
        `getCode` in interface `RGBAComponent`
      Returns:
        Type of an RGBA component.

    - #### setCode

          public final void setCode(RGBAComponentKind code)
                             throws NullPointerException

      Description copied from interface: `RGBAComponent`

      Sets the type of an RGBA component.

      Specified by:
        `setCode` in interface `RGBAComponent`
      Parameters:
        `code` - Type of an RGBA component.
      Throws:
        `NullPointerException` - The given component kind is `null`.

    - #### getComponentSize

          @UInt8
          public final byte getComponentSize()

      Description copied from interface: `RGBAComponent`

      Returns the size, measured in bits, of the RGBA component.

      Specified by:
        `getComponentSize` in interface `RGBAComponent`
      Returns:
        Size of the RGBA component.

    - #### setComponentSize

          public final void setComponentSize(@UInt8
                                             byte size)
                                      throws IllegalArgumentException

      Description copied from interface: `RGBAComponent`

      Sets the size, measured in bits, of the RGBA component.

      Specified by:
        `setComponentSize` in interface `RGBAComponent`
      Parameters:
        `size` - Size of the RGBA component.
      Throws:
        `IllegalArgumentException` - The size value is negative.

    - #### equals

          public final boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### toString

          public final String toString()

      Creates a pseudo-XML string representation of this RGBA component value. The representation consists of a `RGBAComponent` element with `Code` and `Size` sub-elements. For example, an 8-bit red component is represented as follows:

             <RGBAComponent>
               <Code>CompRed</Code>
               <ComponentSize>8</ComponentSize>
             </RGBAComponent>

      Specified by:
        `toString` in interface `RGBAComponent`
      Overrides:
        `toString` in class `Object`
      Returns:
        Pseudo-XML representation of this RGBA component value.
      See Also:
        `parseFactory(String)`, `RGBAComponentImpl.XMLHandler`

    - #### parseFactory

          public static final RGBAComponentImpl parseFactory(String componentString)
                                                      throws NullPointerException,
                                                             ParseException

      Create a new value of this RGBA component type by parsing the given pseudo-XML representation. This method will create an instance from the result of calling the `toString()` method. The pseudo-XML format is illustrated below:

             <RGBAComponent>
               <Code>CompRed</Code>
               <ComponentSize>8</ComponentSize>
             </RGBAComponent>

      If any tags are missing, default values are used and the method returns successfully. This method ignores any namespace prefix found in an element name.

      Parameters:
        `componentString` - Pseudo-XML string to convert into a RGBA component instance.
      Returns:
        Newly created RGBA component instance.
      Throws:
        `NullPointerException` - The given psuedo-XML representation is `null`.
        `ParseException` - The component size could not be parsed into a byte value or the given component code was not recognized as an element of the RGBA component kind enumeration.
      See Also:
        `toString()`

    - #### clone

          public final RGBAComponent clone()

      Description copied from interface: `RGBAComponent`

      Create a cloned copy of this RGBA component value.

      Specified by:
        `clone` in interface `RGBAComponent`
      Overrides:
        `clone` in class `Object`
      Returns:
        Cloned copy of this RGBA component 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.

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

    - #### toPersistentForm

          public static final String toPersistentForm(RGBAComponent rgbaComponent)

    - #### fromPersistentForm

          public static final RGBAComponent fromPersistentForm(String rgbaComponent)

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