Small bug fixes with respect to hex decoding.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353012 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rainer Klute 2003-02-22 13:39:24 +00:00
parent fef2fc7f96
commit 75d0858b6f
3 changed files with 21 additions and 5 deletions

View File

@ -142,6 +142,22 @@ public class Codec
/**
* <p>Converts a short value (16-bit) into its hexadecimal
* notation.</p>
*/
public static String hexEncode(final short s)
{
StringBuffer sb = new StringBuffer(4);
sb.append((char) hexval[(s & 0xF000) >> 12]);
sb.append((char) hexval[(s & 0x0F00) >> 8]);
sb.append((char) hexval[(s & 0x00F0) >> 4]);
sb.append((char) hexval[(s & 0x000F) >> 0]);
return sb.toString();
}
/** /**
* <p>Converts an int value (32-bit) into its hexadecimal * <p>Converts an int value (32-bit) into its hexadecimal
* notation.</p> * notation.</p>
@ -169,8 +185,8 @@ public class Codec
public static String hexEncode(final long l) public static String hexEncode(final long l)
{ {
StringBuffer sb = new StringBuffer(16); StringBuffer sb = new StringBuffer(16);
sb.append((l & 0xFFFFFFFF00000000L) >> 32); sb.append(hexEncode((int) (l & 0xFFFFFFFF00000000L) >> 32));
sb.append((l & 0x00000000FFFFFFFFL) >> 0); sb.append(hexEncode((int) (l & 0x00000000FFFFFFFFL) >> 0));
return sb.toString(); return sb.toString();
} }

View File

@ -159,7 +159,7 @@ public class POIBrowser extends JFrame
new PropertySetDescriptorRenderer()); new PropertySetDescriptorRenderer());
treeUI.setCellRenderer(etcr); treeUI.setCellRenderer(etcr);
setSize(600, 450); setSize(600, 450);
setTitle("POI Browser 0.07"); setTitle("POI Browser 0.08");
setVisible(true); setVisible(true);
} }

View File

@ -94,9 +94,9 @@ public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
text.setFont(new Font("Monospaced", Font.PLAIN, 10)); text.setFont(new Font("Monospaced", Font.PLAIN, 10));
text.append(renderAsString(d)); text.append(renderAsString(d));
text.append("\nByte order: " + text.append("\nByte order: " +
Codec.hexEncode(ps.getByteOrder())); Codec.hexEncode((short) ps.getByteOrder()));
text.append("\nFormat: " + text.append("\nFormat: " +
Codec.hexEncode(ps.getFormat())); Codec.hexEncode((short) ps.getFormat()));
text.append("\nOS version: " + text.append("\nOS version: " +
Codec.hexEncode(ps.getOSVersion())); Codec.hexEncode(ps.getOSVersion()));
text.append("\nClass ID: " + text.append("\nClass ID: " +