com.etymon.pj.object
Class PjString

java.lang.Object
  extended by com.etymon.pj.object.BaseObject
      extended by com.etymon.pj.object.PjObject
          extended by com.etymon.pj.object.PjString
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
PjDate

public class PjString
extends PjObject

A representation of the PDF string type.


Field Summary
private  java.lang.String _s
           
 
Constructor Summary
PjString(java.lang.String s)
          Creates a string object.
 
Method Summary
 java.lang.Object clone()
          Returns a deep copy of this object.
private static java.lang.String decodeEscapedString(java.lang.String pdfString)
          Decodes a PDF string enclosed in parentheses.
private static java.lang.String decodeHexString(java.lang.String pdfString)
          Decodes a PDF hexadecimal string enclosed in angle brackets.
static java.lang.String decodePdf(java.lang.String pdfString)
          Converts a PDF-encoded string to a java String, which may be then be used to initialize a PjString object.
 boolean equals(java.lang.Object obj)
          Compares two PjString objects for equality.
 java.lang.String getString()
          Returns the string value of this object.
 long writePdf(java.io.OutputStream os)
          Writes this string to a stream in PDF format.
 
Methods inherited from class com.etymon.pj.object.PjObject
renumber
 
Methods inherited from class com.etymon.pj.object.BaseObject
toString, write, write, write, writeln
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_s

private java.lang.String _s
Constructor Detail

PjString

public PjString(java.lang.String s)
Creates a string object.

Parameters:
s - the string value to initialize this object to.
Method Detail

getString

public java.lang.String getString()
Returns the string value of this object.

Returns:
the string value of this object.

writePdf

public long writePdf(java.io.OutputStream os)
              throws java.io.IOException
Writes this string to a stream in PDF format.

Specified by:
writePdf in class BaseObject
Parameters:
os - the stream to write to.
Returns:
the number of bytes written.
Throws:
java.io.IOException - if an I/O error occurs.

clone

public java.lang.Object clone()
Returns a deep copy of this object.

Specified by:
clone in class BaseObject
Returns:
a deep copy of this object.

decodePdf

public static java.lang.String decodePdf(java.lang.String pdfString)
                                  throws PdfFormatException
Converts a PDF-encoded string to a java String, which may be then be used to initialize a PjString object.

Parameters:
pdfString - the PDF-encoded string to be decoded.
Returns:
the sequence of characters decoded from pdfString, represented as a java String.
Throws:
PdfFormatException - if pdfString is invalid PDF.

decodeEscapedString

private static java.lang.String decodeEscapedString(java.lang.String pdfString)
                                             throws PdfFormatException
Decodes a PDF string enclosed in parentheses. This method ignores the first and last characters of pdfString because they are assumed to be matching parentheses.

Parameters:
pdfString - the PDF-encoded string to be decoded.
Returns:
the sequence of characters decoded from pdfString, represented as a java String.
Throws:
PdfFormatException - if invalid PDF encoding is encountered in pdfString.

decodeHexString

private static java.lang.String decodeHexString(java.lang.String pdfString)
                                         throws PdfFormatException
Decodes a PDF hexadecimal string enclosed in angle brackets. This method ignores the first and last characters of pdfString because they are assumed to be matching angle brackets.

Parameters:
pdfString - the PDF-encoded string to be decoded.
Returns:
the sequence of characters decoded from pdfString, represented as a java String.
Throws:
PdfFormatException - if invalid PDF encoding is encountered in pdfString.

equals

public boolean equals(java.lang.Object obj)
Compares two PjString objects for equality.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the reference object to compare to.
Returns:
true if this object is the same as obj, false otherwise.