org.icepdf.core.pobjects
Class LiteralStringObject

java.lang.Object
  extended by org.icepdf.core.pobjects.LiteralStringObject
All Implemented Interfaces:
StringObject

public class LiteralStringObject
extends java.lang.Object
implements StringObject

This class represents a PDF Literal String Object. Literal String objects are written as a sequence of literal characters enclosed in parentheses ().

Since:
2.0

Constructor Summary
LiteralStringObject(byte[] bytes)
          Creates a new literal string object so that it represents the same sequence of bytes as in the bytes argument.
LiteralStringObject(java.lang.String string)
          Creates a new literal string object so that it represents the same sequence of character data specifed by the argument.
LiteralStringObject(java.lang.StringBuilder stringBuffer)
          Creates a new literal string object so that it represents the same sequence of character data specifed by the argument.
LiteralStringObject(java.lang.StringBuilder chars, boolean dif)
           
LiteralStringObject(java.lang.String string, Reference reference, SecurityManager securityManager)
          Creates a new literal string object so that it represents the same sequence of character data specifed by the arguments.
 
Method Summary
 java.lang.String encryption(java.lang.String string, boolean decrypt, SecurityManager securityManager)
          Decryptes or encrtypes a string.
 java.lang.String getDecryptedLiteralString(SecurityManager securityManager)
          Gets the decrypted literal string value of the data using the key provided by the security manager.
 java.lang.String getHexString()
          Gets a hexadecimal String representation of this object's data, which is converted to hexadecimal form.
 java.lang.StringBuilder getHexStringBuffer()
          Gets a hexadecimal StringBuffer representation of this object's data, which is converted to hexadecimal form.
 int getLength()
          The length of the the underlying object's data.
 java.lang.String getLiteralString()
          Gets a literal String representation of this object's data, which is in fact, the raw data contained in this object.
 java.lang.StringBuilder getLiteralStringBuffer()
          Gets a literal StringBuffer representation of this object's data which is in fact, the raw data contained in this object.
 java.lang.StringBuilder getLiteralStringBuffer(int fontFormat, FontFile font)
          Gets a literal String representation of this object's data using the specifed font and format.
 Reference getReference()
          Sets the parent PDF object's reference.
 int getUnsignedInt(int start, int offset)
          Gets the integer value of the hexidecimal data specified by the start and offset parameters.
 void setReference(Reference reference)
          Sets the parent PDF object's reference.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LiteralStringObject

public LiteralStringObject(byte[] bytes)

Creates a new literal string object so that it represents the same sequence of bytes as in the bytes argument. In other words, the initial content of the literal string is the characters represented by the byte data.

Parameters:
bytes - array of bytes which will be interpreted as literal character data.

LiteralStringObject

public LiteralStringObject(java.lang.StringBuilder chars,
                           boolean dif)

LiteralStringObject

public LiteralStringObject(java.lang.String string)

Creates a new literal string object so that it represents the same sequence of character data specifed by the argument.

Parameters:
string - the initial contents of the literal string object

LiteralStringObject

public LiteralStringObject(java.lang.String string,
                           Reference reference,
                           SecurityManager securityManager)

Creates a new literal string object so that it represents the same sequence of character data specifed by the arguments. The string value is assumed to be unencrypted and will be encrytped. The method #LiteralStringObject(String string) should be used if the string is all ready encrypted. This method is used for creating new LiteralStringObject's that are created post document parse.

Parameters:
string - the initial contents of the literal string object, unencrypted.
reference - of parent PObject
securityManager - security manager used ot encrypt the string.

LiteralStringObject

public LiteralStringObject(java.lang.StringBuilder stringBuffer)

Creates a new literal string object so that it represents the same sequence of character data specifed by the argument. The first and last characters of the StringBuffer are removed. This constructor should only be used in the context of the parser which has leading and ending parentheses which are removed by this method.

Parameters:
stringBuffer - the initial contents of the literal string object
Method Detail

getUnsignedInt

public int getUnsignedInt(int start,
                          int offset)
Gets the integer value of the hexidecimal data specified by the start and offset parameters.

Specified by:
getUnsignedInt in interface StringObject
Parameters:
start - the begining index, inclusive
offset - the length of bytes to process
Returns:
unsigned integer value of the specifed data range

toString

public java.lang.String toString()

Returns a string representation of the object.

Specified by:
toString in interface StringObject
Overrides:
toString in class java.lang.Object
Returns:
a string representing the object.

getHexString

public java.lang.String getHexString()

Gets a hexadecimal String representation of this object's data, which is converted to hexadecimal form.

Specified by:
getHexString in interface StringObject
Returns:
a String representation of the objects data.

getHexStringBuffer

public java.lang.StringBuilder getHexStringBuffer()

Gets a hexadecimal StringBuffer representation of this object's data, which is converted to hexadecimal form.

Specified by:
getHexStringBuffer in interface StringObject
Returns:
a StringBufffer representation of the object's data in hexadecimal notation.

getLiteralStringBuffer

public java.lang.StringBuilder getLiteralStringBuffer()

Gets a literal StringBuffer representation of this object's data which is in fact, the raw data contained in this object.

Specified by:
getLiteralStringBuffer in interface StringObject
Returns:
a StringBuffer representation of the object's data.

getLiteralString

public java.lang.String getLiteralString()

Gets a literal String representation of this object's data, which is in fact, the raw data contained in this object.

Specified by:
getLiteralString in interface StringObject
Returns:
a String representation of the object's data.

getLiteralStringBuffer

public java.lang.StringBuilder getLiteralStringBuffer(int fontFormat,
                                                      FontFile font)

Gets a literal String representation of this object's data using the specifed font and format. The font is used to verify that the specific character codes can be rendered; if they cannot they may be removed or combined with the next character code to get a displayable character code.

Specified by:
getLiteralStringBuffer in interface StringObject
Parameters:
fontFormat - the type of pdf font which will be used to display the text. Valid values are CID_FORMAT and SIMPLE_FORMAT for Adobe Composite and Simple font types respectively
font - font used to render the the literal string data.
Returns:
StringBuffer which contains all renderaable characters for the given font.

getLength

public int getLength()
The length of the the underlying object's data.

Specified by:
getLength in interface StringObject
Returns:
length of objcts data.

setReference

public void setReference(Reference reference)
Sets the parent PDF object's reference.

Specified by:
setReference in interface StringObject
Parameters:
reference - parent object reference.

getReference

public Reference getReference()
Sets the parent PDF object's reference.

Specified by:
getReference in interface StringObject
Returns:
returns the reference used for encryption.

getDecryptedLiteralString

public java.lang.String getDecryptedLiteralString(SecurityManager securityManager)
Gets the decrypted literal string value of the data using the key provided by the security manager.

Specified by:
getDecryptedLiteralString in interface StringObject
Parameters:
securityManager - security manager associated with parent document.
Returns:
decrypted stream.

encryption

public java.lang.String encryption(java.lang.String string,
                                   boolean decrypt,
                                   SecurityManager securityManager)
Decryptes or encrtypes a string.

Parameters:
string - string to encrypt or decrypt
decrypt - true to decrypt string, false otherwise;
securityManager - security manager for document.
Returns:
encrypted or decrypted string, depends on value of decrypt param.