org.apache.commons.imaging.formats.jpeg.segments

## Class GenericSegment

- java.lang.Object
- - org.apache.commons.imaging.common.BinaryFileParser
  - - org.apache.commons.imaging.formats.jpeg.segments.Segment
    - - org.apache.commons.imaging.formats.jpeg.segments.GenericSegment

- Direct Known Subclasses:
    AppnSegment, ComSegment, UnknownSegment

      public abstract class GenericSegment
      extends Segment

- - ### Field Summary

    - ### Fields inherited from class org.apache.commons.imaging.formats.jpeg.segments.Segment

      `length, marker`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GenericSegment(int marker, byte[] bytes)`
    `GenericSegment(int marker, int markerLength, InputStream is)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `dump(PrintWriter pw)`
    `void` | `dump(PrintWriter pw, int start)`
    `byte[]` | `getSegmentData()` Returns a copy of the segment's contents, excluding the marker and length bytes at the beginning.
    `protected byte` | `getSegmentData(int offset)` Returns a specific byte of the segment's contents, excluding the marker and length bytes at the beginning.
    `String` | `getSegmentDataAsString(String encoding)` Convert the bytes to a String

    - ### Methods inherited from class org.apache.commons.imaging.formats.jpeg.segments.Segment

      `getDescription, getSegmentType, toString`

    - ### Methods inherited from class org.apache.commons.imaging.common.BinaryFileParser

      `debugNumber, debugNumber, getByteOrder, setByteOrder`

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

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

- - ### Constructor Detail

    - #### GenericSegment

          public GenericSegment(int marker,
                                int markerLength,
                                InputStream is)
                         throws IOException

      Throws:
        `IOException`

    - #### GenericSegment

          public GenericSegment(int marker,
                                byte[] bytes)

  - ### Method Detail

    - #### dump

          public void dump(PrintWriter pw)

      Overrides:
        `dump` in class `Segment`

    - #### dump

          public void dump(PrintWriter pw,
                           int start)

    - #### getSegmentData

          public byte[] getSegmentData()

      Returns a copy of the segment's contents, excluding the marker and length bytes at the beginning.
      Returns:
        the segment's contents

    - #### getSegmentData

          protected byte getSegmentData(int offset)

      Returns a specific byte of the segment's contents, excluding the marker and length bytes at the beginning.
      Parameters:
        `offset` - segment offset
      Returns:
        the bye in the segment's contents
      See Also:
        `getSegmentData()`

    - #### getSegmentDataAsString

          public String getSegmentDataAsString(String encoding)
                                        throws UnsupportedEncodingException

      Convert the bytes to a String
      Parameters:
        `encoding` - segment encoding
      Returns:
        the encoded bytes
      Throws:
        `UnsupportedEncodingException` - if the encoding provided is not supported

Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.