|
|||||||||||||||||||
| This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover. | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| HexBinary.java | 100% | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
/* |
|
| 2 |
* JBind |
|
| 3 |
* |
|
| 4 |
* Copyright (c) by Stefan Wachter. All rights reserved. |
|
| 5 |
* |
|
| 6 |
* Usage, modification, and redistribution is subject to license terms that are |
|
| 7 |
* available at 'http://www.jbind.org'. The JBind license is like the |
|
| 8 |
* 'Apache Software License V 1.1'. |
|
| 9 |
*/ |
|
| 10 |
package org.jbind.xml.instance.data; |
|
| 11 |
|
|
| 12 |
import org.jbind.util.other.StrBuffer; |
|
| 13 |
import org.jbind.xml.core.data.IHexBinary; |
|
| 14 |
|
|
| 15 |
public class HexBinary extends Binary implements IHexBinary {
|
|
| 16 |
|
|
| 17 | 1 |
public HexBinary(byte[] aBytes) {
|
| 18 | 1 |
super(aBytes); |
| 19 |
} |
|
| 20 |
|
|
| 21 | 2 |
public String toString() {
|
| 22 | 2 |
StrBuffer res = new StrBuffer(myValue.length * 2); |
| 23 | 2 |
for (int i = 0; i < myValue.length; i++) {
|
| 24 | 44 |
byte b = myValue[i]; |
| 25 | 44 |
byte l = (byte)(b & 0x0F);// the lower bits |
| 26 | 44 |
byte h = (byte)((b >>> 4) & 0x0F);// the higher bits |
| 27 | 44 |
char lAscii = (char)((l < 10) ? '0' + l : 'A' + l - 10); |
| 28 | 44 |
char hAscii = (char)((h < 10) ? '0' + h : 'A' + h - 10); |
| 29 | 44 |
res.append(hAscii).append(lAscii); |
| 30 |
} |
|
| 31 | 2 |
return res.toString(); |
| 32 |
} |
|
| 33 |
|
|
| 34 |
} |
|
| 35 |
|
|
||||||||||