com.beaglebuddy.id3.v23

## Class ID3v23TagExtendedHeader

- java.lang.Object
- - com.beaglebuddy.id3.v23.ID3v23TagExtendedHeader

-     public class ID3v23TagExtendedHeader
      extends java.lang.Object

  This class provides methods for reading and writing the optional ID3v2.3 tag extended header. It contains fields that are not vital to the processing of the ID3v2.3 tag and hence are optional. The ID3v2.3 tag extended header, if present, is at least 10 bytes long and directly follows the standard tag header.

  The structure of an .mp3 file containing an ID3v2.3 tag is shown below.

  An ID3v2.3 extended header contains the following fields:

  ID3v2.3 Tag Extended Header Fields
  | Field | Description
  --- | --- | ---
  1. | size | specifies the size, in bytes, of the extended header.
  2. | CRCDataPresent | flag indicating whether a CRC (Cyclical Redundancy Check) for the .mp3 file has been calculated and the result stored in in the CRCData field.
  3. | paddingSize | specifies the number of bytes of padding stored after the ID3v2.3 tag and before the audio data in the .mp3 file.
  4. | CRCData | an optional field which is valid only if the CRCDataPresent flag is set, this field contains the actual CRC (Cyclical Redundancy Check) data.

  See Also:
    ID3v2.3 tag, wikipedia history of ID3 tags

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ID3v23TagExtendedHeader()` The default constructor is called when creating a new ID3v2.3 tag extended header.
    `ID3v23TagExtendedHeader(java.io.InputStream inputStream)` This constructor is called when reading in an existing ID3v2.3 tag extended header from an .mp3 file.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `getCRCData()` gets the CRC data.
    `int` | `getPaddingSize()` gets the size of the padding, which is an area filled with 0's and is found after the end of the ID3v2.3 tag and before the actual audio portion of the .mp3 file.
    `int` | `getSize()` gets the total number of bytes in the ID3v2.3 tag extended header.
    `boolean` | `isCRCDataPresent()` gets whether the ID3v2.3 tag extended header contains a Cyclic Redundancy Check (CRC).
    `boolean` | `isDirty()` indicates whether or not the tag's extended header's fields have been modified.
    `void` | `save(java.io.OutputStream outputStream)` save the ID3v2.3 tag extended header to the .mp3 file.
    `void` | `save(java.io.RandomAccessFile file)` save the ID3v2.3 tag extended header to the .mp3 file.
    `void` | `setBuffer()` if the tag's extended header's values have been modified, then resize the raw binary buffer and store the new values there.
    `void` | `setCRCData(byte[] CRCData)` sets the CRC data and the CRCDataPresent flag.
    `void` | `setPaddingSize(int paddingSize)` sets the size of the padding, which is an area filled with 0's and found after the end of the ID3v2.3 tag and before the actual audio portion of the .mp3 file.
    `java.lang.String` | `toString()` gets a string representation of the ID3v2.3 tag extended header showing the values of its fields.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ID3v23TagExtendedHeader

          public ID3v23TagExtendedHeader()

      The default constructor is called when creating a new ID3v2.3 tag extended header. The default values used are:
      - extended header size is 0
      - padding size is 0
      - no CRC

    - #### ID3v23TagExtendedHeader

          public ID3v23TagExtendedHeader(java.io.InputStream inputStream)
                                  throws java.io.IOException

      This constructor is called when reading in an existing ID3v2.3 tag extended header from an .mp3 file.
      Parameters:
        `inputStream` - input stream pointing to the end of the beginning of the ID3v2.3 tag extended header in the .mp3 file.
      Throws:
        `java.io.IOException` - if the ID3v2.3 tag extended header can not be loaded from the .mp3 file.

  - ### Method Detail

    - #### isDirty

          public boolean isDirty()

      indicates whether or not the tag's extended header's fields have been modified.
      Returns:
        whether or not the extended header has been modified.
      See Also:
        `setBuffer()`

    - #### setBuffer

          public void setBuffer()

      if the tag's extended header's values have been modified, then resize the raw binary buffer and store the new values there. When finished, reset the dirty flag to indicate that the buffer is up to date, and the extended header is now ready to be saved to the .mp3 file.

    - #### getSize

          public int getSize()

      gets the total number of bytes in the ID3v2.3 tag extended header.
      Returns:
        the total number of bytes in the ID3v2.3 tag extended header.

    - #### getPaddingSize

          public int getPaddingSize()

      gets the size of the padding, which is an area filled with 0's and is found after the end of the ID3v2.3 tag and before the actual audio portion of the .mp3 file.
      Returns:
        the size of the padding which is found at the end of the ID3v2.3 tag.
      See Also:
        `setPaddingSize(int)`

    - #### setPaddingSize

          public void setPaddingSize(int paddingSize)

      sets the size of the padding, which is an area filled with 0's and found after the end of the ID3v2.3 tag and before the actual audio portion of the .mp3 file.
      Parameters:
        `paddingSize` - the size of the padding.
      See Also:
        `getPaddingSize()`

    - #### isCRCDataPresent

          public boolean isCRCDataPresent()

      gets whether the ID3v2.3 tag extended header contains a Cyclic Redundancy Check (CRC).
      Returns:
        true if the ID3v2.3 tag extended header contains an optional Cyclic Redundancy Check (CRC) and false otherwise.
      See Also:
        `setPaddingSize(int)`

    - #### getCRCData

          public byte[] getCRCData()
                            throws java.lang.IllegalStateException

      gets the CRC data.
      Returns:
        the CRC data.
      Throws:
        `java.lang.IllegalStateException` - if the CRCDataPresent flag is not set.
      See Also:
        `isCRCDataPresent()`, `setCRCData(byte[])`

    - #### setCRCData

          public void setCRCData(byte[] CRCData)

      sets the CRC data and the CRCDataPresent flag.
      Parameters:
        `CRCData` - the data for the Cyclic Redundancy Check. The CRC data will be cleared if the CRCdata is null or an empty byte array of length 0, ie new byte[0]. Otherwise, it must be a valid CRC and be 4 bytes in length.
      See Also:
        `getCRCData()`

    - #### save

          public void save(java.io.OutputStream outputStream)
                    throws java.io.IOException

      save the ID3v2.3 tag extended header to the .mp3 file.
      Parameters:
        `outputStream` - output stream pointing to the starting location of the ID3v2.3 tag extended header within the .mp3 file.
      Throws:
        `java.io.IOException` - if there was an error writing the ID3v2.3 tag extended header to the .mp3 file.

    - #### save

          public void save(java.io.RandomAccessFile file)
                    throws java.io.IOException

      save the ID3v2.3 tag extended header to the .mp3 file.
      Parameters:
        `file` - random access file pointing to the starting location of the ID3v2.3 tag extended header within the .mp3 file.
      Throws:
        `java.io.IOException` - if there was an error writing the ID3v2.3 tag extended header to the .mp3 file.

    - #### toString

          public java.lang.String toString()

      gets a string representation of the ID3v2.3 tag extended header showing the values of its fields.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a string representation of the ID3v2.3 tag extended header.