aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StringInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/pdf/StringInfo.java')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/StringInfo.java93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StringInfo.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StringInfo.java
new file mode 100644
index 0000000..5933e4b
--- /dev/null
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StringInfo.java
@@ -0,0 +1,93 @@
+/**
+ * <copyright> Copyright (c) 2006 by Know-Center, Graz, Austria </copyright>
+ *
+ * This software is the confidential and proprietary information of Know-Center,
+ * Graz, Austria. You shall not disclose such Confidential Information and shall
+ * use it only in accordance with the terms of the license agreement you entered
+ * into with Know-Center.
+ *
+ * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ * NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
+ * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES.
+ *
+ * $Id: StringInfo.java,v 1.2 2006/10/11 07:57:58 wprinz Exp $
+ */
+package at.knowcenter.wag.egov.egiz.pdf;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Specifies a certain data area within the pdf.
+ *
+ * <p>
+ * Actually this is a byte range, which is used to hold the placeholder ranges
+ * for later replacement.
+ * </p>
+ *
+ * @author wprinz
+ */
+public class StringInfo implements Serializable
+{
+ /**
+ * SVUID.
+ */
+ private static final long serialVersionUID = 5834801907046737048L;
+
+ /**
+ * The PDF document this range belongs to.
+ */
+ protected byte[] pdf = null;
+
+ /**
+ * The start offset of the range.
+ */
+ public int string_start = -1;
+
+ /**
+ * The length of the range.
+ */
+ public int string_length = -1;
+
+ /**
+ * Copies the bytes of this range to a new byte array.
+ *
+ * @return Returns the new byte array.
+ */
+ public byte[] copyStringBytes()
+ {
+ byte[] bytes = new byte[this.string_length];
+ System.arraycopy(this.pdf, this.string_start, bytes, 0, this.string_length);
+ return bytes;
+ }
+
+ /**
+ * Converts the range into a String.
+ *
+ * @return Returns the String.
+ * @throws UnsupportedEncodingException
+ * Forwarded exception.
+ */
+ public String getString(String encoding) throws UnsupportedEncodingException
+ {
+ byte[] bytes = copyStringBytes();
+ return new String(bytes, encoding);
+ }
+
+ public String toString()
+ {
+ try
+ {
+ return "(" + this.string_start + "," + this.string_length + ")" + getString("ISO-8859-1");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ e.printStackTrace();
+ return "(" + this.string_start + "," + this.string_length + ")";
+ }
+ }
+
+}