Class ASString

  • All Implemented Interfaces:
    Comparable
    Direct Known Subclasses:
    ASHexString

    public class ASString
    extends ASObject
    implements Comparable
    Represents a pdf string object. That is, a series of bytes that do NOT have an associated encoding.
    • Constructor Detail

      • ASString

        public ASString​(byte[] bytes)
      • ASString

        public ASString​(String javaString)
        Creates an ASString that contains UTF-8. Note that the fact that this is UTF-8 is promptly forgotten by the instance.
      • ASString

        public ASString​(int[] numbers,
                        int bytesToUse,
                        int bytesToPad)
                 throws PDFInvalidParameterException
        Construct an ASString from an array of integers.
        Parameters:
        numbers - numbers to use in constructing the ASString
        bytesToUse - number of bytes to use from each number starting with the LSB. Must be from 1 to 4.
        bytesToPad - number of bytes to pad in front of each number beyond the number of bytes taken from each number
        Throws:
        PDFInvalidParameterException - if the bytesToUse is not between 1 and 4
    • Method Detail

      • getBytes

        public byte[] getBytes()
        Get the raw bytes associated with this ASString. The client must NOT alter the returned array.
      • getChars

        public char[] getChars()
        Try to get an array of chars associated with this ASString. Note that, because ASString has no encoding, this just uses a series of heuristics to get the chars. No guarantees are made regarding the returned value other than "we tried our best". It may change over time.
      • getChar

        public char getChar​(int index)
        Try to get a chars associated with a byte in this ASString. Note that, because ASString has no encoding, this just uses a series of heuristics to get the chars. No guarantees are made regarding the returned value other than "we tried our best". It may change over time.
      • asString

        public String asString()
        Try to get a chars associated with a byte in this ASString. Note that, because ASString has no encoding, this just uses a series of heuristics to get the chars. No guarantees are made regarding the returned value other than "we tried our best". It may change over time.
      • toString

        public String toString()
        Attempts to get a unicode representation for this unencoded string. No guarantees are made about what is returned.
        Overrides:
        toString in class Object
      • equals

        public boolean equals​(ASString anotherString)
      • equals

        public boolean equals​(Object anotherString)
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • indexOf

        public int indexOf​(byte[] key)
      • lastIndexOf

        public int lastIndexOf​(int target)
      • substring

        public ASString substring​(int begin)
      • substring

        public ASString substring​(int begin,
                                  int end)