Kbase 22023: OPEN CLIENT: Convert Rowid Object to String (Java)
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/14/2002 |
|
SUMMARY:
In Java, the Rowid object that Progress provides does not currently have the toString() method implemented. This means that when you want to get the string representation of a Rowid object, you get the default Java implementation of the toString() method (which has limited value since it simply prints the address of the object in memory).
The Java method given below will return the string representation of a Rowid object in the same format as the Progress 4GL code:
STRING(ROWID(SomeTable))
SOLUTION:
public static String convertRowidToString(Rowid rowid)
{
StringBuffer x = new StringBuffer("0x");
String y = null;
byte[] tempBytes = rowid.getBytes();
int byteVal;
for (int i=0; i < tempBytes.length; i++)
{
byteVal = tempBytes[i];
if (byteVal < 0)
// byte is negative so subtract from 256
byteVal = 256 + tempBytes[i];
y = Integer.toHexString(byteVal);
if (y.length() == 1)
x.append("0");
x.append(y);
}
return x.toString();
}