You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2009/02/06 07:44:12 UTC
svn commit: r741433 -
/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSString.java
Author: lehmi
Date: Fri Feb 6 06:44:12 2009
New Revision: 741433
URL: http://svn.apache.org/viewvc?rev=741433&view=rev
Log:
PDFBOX-173: minor bugfixing and improvements based on Brian Matthews suggestions (blmatthews at users.sourceforge.net)
Modified:
incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSString.java
Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSString.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSString.java?rev=741433&r1=741432&r2=741433&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSString.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSString.java Fri Feb 6 06:44:12 2009
@@ -76,6 +76,7 @@
public static final byte[] FF_ESCAPE = new byte[]{ 92, 102 }; //"\\f".getBytes( "ISO-8859-1" );
private ByteArrayOutputStream out = null;
+ private String str = null;
/**
* Forces the string to be serialized in literal form but not hexa form.
@@ -107,6 +108,7 @@
if( chars[i] > 255 )
{
unicode16 = true;
+ break;
}
}
if( unicode16 )
@@ -217,6 +219,10 @@
*/
public String getString()
{
+ if (this.str != null)
+ {
+ return this.str;
+ }
String retval;
String encoding = "ISO-8859-1";
byte[] data = getBytes();
@@ -244,6 +250,7 @@
e.printStackTrace();
retval = new String( getBytes() );
}
+ this.str = retval;
return retval;
}
@@ -257,6 +264,7 @@
public void append( byte[] data ) throws IOException
{
out.write( data );
+ this.str = null;
}
/**
@@ -269,6 +277,7 @@
public void append( int in ) throws IOException
{
out.write( in );
+ this.str = null;
}
/**
@@ -277,6 +286,7 @@
public void reset()
{
out.reset();
+ this.str = null;
}
/**
@@ -294,7 +304,7 @@
*/
public String toString()
{
- return "COSString{" + new String( getBytes() ) + "}";
+ return "COSString{" + this.getString() + "}";
}
/**
@@ -393,7 +403,13 @@
*/
public boolean equals(Object obj)
{
- return (obj instanceof COSString) && java.util.Arrays.equals(((COSString) obj).getBytes(), getBytes());
+ if (obj instanceof COSString)
+ {
+ obj = ((COSString) obj).getString();
+ return this.getString().equals(obj);
+ }
+ else
+ return false;
}
/**