Class ASString
- java.lang.Object
-
- com.adobe.internal.pdftoolkit.core.types.ASObject
-
- com.adobe.internal.pdftoolkit.core.types.ASString
-
- All Implemented Interfaces:
java.lang.Comparable
- Direct Known Subclasses:
ASHexString
public class ASString extends ASObject implements java.lang.Comparable
Represents a pdf string object. That is, a series of bytes that do NOT have an associated encoding.
-
-
Constructor Summary
Constructors Constructor Description ASString(byte[] bytes)
ASString(int[] numbers, int bytesToUse, int bytesToPad)
Construct anASString
from an array of integers.ASString(int[] numbers, int startIndex, int endIndex, int bytesToUse, int bytesToPad)
ASString(java.lang.String javaString)
Creates an ASString that contains UTF-8.ASString(java.lang.String javaString, java.nio.charset.CharsetEncoder cse)
Creates an ASString that contains the bytes received by encoding the javaString with the provided cse.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
asString()
Try to get a chars associated with a byte in this ASString.int
compareTo(java.lang.Object anotherString)
ASString
concat(ASString addStr)
boolean
equals(ASString anotherString)
boolean
equals(java.lang.Object anotherString)
byte[]
getBytes()
Get the raw bytes associated with this ASString.char
getChar(int index)
Try to get a chars associated with a byte in this ASString.char[]
getChars()
Try to get an array of chars associated with this ASString.int
hashCode()
int
indexOf(byte[] key)
int
lastIndexOf(int target)
ASString
substring(int begin)
ASString
substring(int begin, int end)
java.lang.String
toString()
Attempts to get a unicode representation for this unencoded string.void
write(OutputByteStream outputByteStream)
Writes the ASString in to the given OutputStream in the format expected by the PDF Spec.
-
-
-
Constructor Detail
-
ASString
public ASString(byte[] bytes)
-
ASString
public ASString(java.lang.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(java.lang.String javaString, java.nio.charset.CharsetEncoder cse) throws PDFInvalidParameterException
Creates an ASString that contains the bytes received by encoding the javaString with the provided cse. Note that the encoding is promptly forgotten by the instance.- Throws:
PDFInvalidParameterException
-
ASString
public ASString(int[] numbers, int bytesToUse, int bytesToPad) throws PDFInvalidParameterException
Construct anASString
from an array of integers.- Parameters:
numbers
- numbers to use in constructing the ASStringbytesToUse
- 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
-
ASString
public ASString(int[] numbers, int startIndex, int endIndex, int bytesToUse, int bytesToPad) throws PDFInvalidParameterException
- Throws:
PDFInvalidParameterException
-
-
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 java.lang.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 java.lang.String toString()
Attempts to get a unicode representation for this unencoded string. No guarantees are made about what is returned.- Overrides:
toString
in classjava.lang.Object
-
compareTo
public int compareTo(java.lang.Object anotherString)
- Specified by:
compareTo
in interfacejava.lang.Comparable
-
equals
public boolean equals(ASString anotherString)
-
equals
public boolean equals(java.lang.Object anotherString)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.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)
-
write
public void write(OutputByteStream outputByteStream) throws PDFIOException
Writes the ASString in to the given OutputStream in the format expected by the PDF Spec.- Specified by:
write
in classASObject
- Parameters:
outputByteStream
- OutputByteStream to write to.- Throws:
PDFIOException
- See Also:
ASHexString
-
-