aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java')
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java34
1 files changed, 14 insertions, 20 deletions
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java
index 5132021..3546cd7 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java
@@ -38,7 +38,7 @@ import at.gv.egiz.pdfas.impl.input.helper.DataSourceHelper;
/**
* This class provides encoding and decoding methods and other coding methods.
* All methods are static!
- *
+ *
* @author wlackner
*/
public class CodingHelper
@@ -52,7 +52,7 @@ public class CodingHelper
/**
* This method encodes a given Unicode (Java) String to UTF-8 bytes and then
* encodes these UTF-8 bytes to a Base64 US-ASCII (Java) String.
- *
+ *
* @param plain_string
* to be encoded
* @return the UTF-8 and Base64 encoded string
@@ -68,7 +68,6 @@ public class CodingHelper
}
catch (UnsupportedEncodingException e)
{
- e.printStackTrace();
throw new RuntimeException(e);
}
}
@@ -76,7 +75,7 @@ public class CodingHelper
/**
* This method decodes the UTF-8 bytes from a Base64 US-ASCII (Java) String
* and decodes the UTF-8 bytes to a unicode (Java) String.
- *
+ *
* @param encoded_string
* to be decoded
* @return the Base64 and UTF-8 decoded string
@@ -92,7 +91,6 @@ public class CodingHelper
}
catch (UnsupportedEncodingException e)
{
- e.printStackTrace();
throw new RuntimeException(e);
}
}
@@ -108,7 +106,6 @@ public class CodingHelper
// try {
// utf8 = theString.getBytes("UTF-8");
// } catch (UnsupportedEncodingException e) {
- // e.printStackTrace();
// }
// return utf8;
// }
@@ -139,20 +136,19 @@ public class CodingHelper
// try {
// the_string = new String(ba, "UTF-8");
// } catch (UnsupportedEncodingException e) {
- // e.printStackTrace();
// }
// return the_string;
// }
/**
* This method decodes a given Base64 string.
- *
+ *
* <p>
* Note that the given String must only contain Base64 characters. (The string
* will be converted to a byte array of "US-ASCII" (7 bit) bytes and then this
* byte array will be decoded using the Base64 algorithm.
* </p>
- *
+ *
* @param theString
* to be decoded
* @return a Base64 decoded byte array
@@ -166,14 +162,13 @@ public class CodingHelper
}
catch (UnsupportedEncodingException e)
{
- e.printStackTrace();
throw new RuntimeException("Very Strange: US-ASCII encoding not supported???", e);
}
}
/**
* This method decodes a given Base64 byte array
- *
+ *
* @param ba
* the byte array to be decoded
* @return a Base64 decoded byte array
@@ -185,7 +180,7 @@ public class CodingHelper
/**
* This method encodes a given byte array Base64
- *
+ *
* @param plainString
* the byte array to be encoded
* @return the Base64 encoded string
@@ -199,7 +194,6 @@ public class CodingHelper
}
catch (UnsupportedEncodingException e)
{
- e.printStackTrace();
throw new RuntimeException("Very Strange: US-ASCII encoding not supported???", e);
}
}
@@ -207,15 +201,15 @@ public class CodingHelper
// dferbas
/**
* This method builds an hash value of a given byte array.
- *
+ *
* @param data
* the byte array to build the hash value for
- * @param hashAlg hash algorithm for {@link MessageDigest} e.g. "SHA-1"
+ * @param hashAlg hash algorithm for {@link MessageDigest} e.g. "SHA-1"
* @return the calculated hash value as a byte array
* @see MessageDigest
*/
public static byte[] buildDigest(byte[] data, String hashAlg)
- {
+ {
MessageDigest digester = null;
try
{
@@ -243,10 +237,10 @@ public class CodingHelper
byte [] data = DataSourceHelper.convertDataSourceToByteArray(input);
return buildDigest(data, hashAlg);
}
-
+
/**
* This method escapes a given string with HTML entities.
- *
+ *
* @param rawString
* the string to escaped
* @return the HTML escaped string
@@ -263,7 +257,7 @@ public class CodingHelper
/**
* This method checks, if a byte array contains chars that are not base64
* conform.
- *
+ *
* @param byteArray
* the array to test
* @return boolean, if a byte array is base64 conform, false otherwise
@@ -282,7 +276,7 @@ public class CodingHelper
/**
* This method checks, if a string contains chars that are not base64 conform.
- *
+ *
* @param string
* the chars to test
* @return boolean, if the given string is base64 conform, false otherwise