added support for in-lined test data

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352619 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2002-05-14 18:13:33 +00:00
parent 2e5c84d389
commit 776bf1c737
1 changed files with 21 additions and 3 deletions

View File

@ -54,12 +54,13 @@
package org.apache.poi.generator;
import java.util.StringTokenizer;
/**
* Helper functions for the record transformations. TODO: Change this to
* javascript in the style sheet.
* Helper functions for the record transformations.
*
* @author Glen Stampoultzis (glens at apache.org)
* @author Andrew C. Oliver (acoliver at apache dot org)
*/
public class RecordUtil
{
@ -177,5 +178,22 @@ public class RecordUtil
pad(fieldName, padTo);
return fieldName.toString();
}
/**
* @return a byte array formatted string from a HexDump formatted string
* for example (byte)0x00,(byte)0x01 instead of 00 01
*/
public static String getByteArrayString(String data) {
StringTokenizer tokenizer = new StringTokenizer(data);
StringBuffer retval = new StringBuffer();
while (tokenizer.hasMoreTokens()) {
retval.append("(byte)0x").append(tokenizer.nextToken());
if (tokenizer.hasMoreTokens()) {
retval.append(",");
}
}
return retval.toString();
}
}