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

# Class AbstractGenericSegment

java.lang.Object
org.apache.commons.imaging.common.BinaryFileParser
org.apache.commons.imaging.formats.jpeg.segments.AbstractSegment
org.apache.commons.imaging.formats.jpeg.segments.AbstractGenericSegment

Direct Known Subclasses:
  `AppnSegment`, `ComSegment`, `UnknownSegment`

public abstract class AbstractGenericSegment extends AbstractSegment

- ## Field Summary

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

  `length, marker`

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  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(Charset encoding)`
  Convert the bytes to a String

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

  `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 Details

  - ### AbstractGenericSegment

    public AbstractGenericSegment(int marker, byte[] bytes)

  - ### AbstractGenericSegment

    public AbstractGenericSegment(int marker, int markerLength, InputStream is) throws IOException
    Throws:
      `IOException`

- ## Method Details

  - ### dump

    public void dump(PrintWriter pw)
    Overrides:
      `dump` in class `AbstractSegment`

  - ### 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(Charset encoding)
    Convert the bytes to a String
    Parameters:
      `encoding` - segment encoding
    Returns:
      the encoded bytes