|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jsdai.lang.Binary
The Binary
class represents the EXPRESS data type BINARY.
Instances of Binary
are constant: their values cannot be
changed after they are created.
Constructor Summary | |
Binary(byte[] str,
int size)
Initializes a newly created Binary object so that it
represents the sequence of bits described by the argument of type
byte array.
|
|
Binary(java.lang.String str)
Initializes a newly created Binary object so that it
represents the sequence of bits described by the String argument.
|
Method Summary | |
static Binary |
BitsToBinary(java.lang.String str)
|
boolean |
equals(Binary bin)
Compares this Binary to the specified object of Binary type. |
int |
getSize()
Returns the length of the value of this Binary. |
int |
toByteArray(byte[] byte_array)
Stores the value of this Binary into submitted byte array.
|
java.lang.String |
toString()
Returns a String representing the value of this Binary.
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Binary(java.lang.String str) throws SdaiException
Binary
object so that it
represents the sequence of bits described by the String
argument.
A correspondence between a value of binary data type and its
String
representation is defined as follows.
For a sequence of p bits, the string consists of k+1 hexadecimal
digits, where k is the smallest integer larger or equal to p/4.
The first digit is the value of 4k-p. Other digits are obtained
by first left filling the binary with 4k-p zero bits and then
dividing the sequence into groups of four bits. Each of these groups
gives a separate digit in the string representation.
If the String
submitted cannot be mapped to a
bit sequence according to the above rules, then SdaiException VA_NVLD is thrown.
str
- a String
representing the binary value.
SdaiException
- VA_NVLD, value invalid.Binary(byte [] str, int size)
public Binary(byte[] str, int size) throws SdaiException
Binary
object so that it
represents the sequence of bits described by the argument of type
byte
array.
A correspondence between a value of binary data type and its
byte
array representation is defined as follows.
For a sequence of p bits, the byte
array consists
of k+1 hexadecimal digits, where k is the smallest integer larger
or equal to p/4. The first digit is the value of 4k-p. Other digits
are obtained by first left filling the binary with 4k-p zero bits
and then dividing the sequence into groups of four bits. Each of
these groups gives a separate digit stored as a member of byte array.
If the byte
array submitted cannot be mapped to a
bit sequence according to the above rules, then SdaiException
VA_NVLD is thrown.
str
- a byte
array representing the binary value.size
- the number of bytes representing the binary value.
SdaiException
- VA_NVLD, value invalid.Binary(String str)
Method Detail |
public static Binary BitsToBinary(java.lang.String str) throws SdaiException
SdaiException
public java.lang.String toString()
String
representing the value of this Binary.
For a sequence of p bits, this string consists of k+1 hexadecimal
digits, where k is the smallest integer larger or equal to p/4.
The first digit is the value of 4k-p. Other digits are obtained
by first left filling the binary with 4k-p zero bits and then
dividing the sequence into groups of four bits. Each of these groups
gives a separate digit in the string representation.
Example:
Binary bin = ...; // suppose that value is 0100101011
System.out.println("Binary value: " + bin);
The following string will be printed:
Binary value: 212B
toByteArray(byte[])
,
"ISO 10303-21::7.3.6 Binary"public int toByteArray(byte[] byte_array) throws SdaiException
byte
array.
For a sequence of p bits, this array consists of k+1 hexadecimal
digits, where k is the smallest integer larger or equal to p/4.
The first digit is the value of 4k-p. Other digits are obtained
by first left filling the binary with 4k-p zero bits and then
dividing the sequence into groups of four bits. Each of these groups
gives a separate digit stored as a member of byte array.
If the size of the array submitted as an argument to this method is too small, then SdaiException VA_NVLD is thrown.
Example:
Binary bin = ...; // suppose that value is 0100101011
byte [] bt_array = new byte [5];
int count = bin.toByteArray(bt_array);
for (int i = 0; i < count; i++) {
System.out.println(" i = " + i + " value = " + (char)bt_array[i]);
}
The following lines will be printed:
i = 0 value = 2
i = 1 value = 1
i = 2 value = 2
i = 3 value = B
byte_array
- a byte array submitted to store the value of this Binary.
SdaiException
- VA_NVLD, value invalid.toString()
,
"ISO 10303-21::7.3.6 Binary"public int getSize()
public boolean equals(Binary bin)
Binary
to the specified object of Binary
type.
bin
- the object to compare this Binary
against.
true
if and only if the argument is not null
and represents the same sequence of bits as this Binary
object;
false
otherwise.
|
Copyright © LKSoftWare GmbH, 1999-2008 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |