Public Methods | |
| IORStream (String ior) | |
| void | setEndian (boolean swap) |
| int | lastStart () |
| int | lastLength () |
| boolean | readBoolean () |
| byte | readOctet () |
| short | readShort () |
| int | readLong () |
| String | readString () |
| IORStream | subStream (int len) |
|
|
00018 {
00019 _pos = 0;
00020 _length = 0;
00021 _swap = false; // false means big endian
00022 _buffer = asciiToOctets(ior.substring("IOR:".length()));
00023 }
|
|
|
00026 {
00027 _swap = swap;
00028 }
|
|
|
00031 {
00032 int pos = (_pos - _length) * 2; // Two ASCII characters for each octet
00033 return pos+("IOR:".length());
00034 }
|
|
|
00037 {
00038 return _length * 2; // Two ASCII characters for each octet
00039 }
|
|
|
00042 {
00043 _length = 1;
00044 return _buffer[_pos++] != (byte)0;
00045 }
|
|
|
00048 {
00049 _length = 1;
00050 return _buffer[_pos++];
00051 }
|
|
|
00054 {
00055 //align to short
00056 _pos += (_pos & 0x1);
00057
00058 _length = 2;
00059 if(_swap)
00060 return (short)((_buffer[_pos++] & 0xff) |
00061 (_buffer[_pos++] << 8));
00062 else
00063 return (short)((_buffer[_pos++] << 8) |
00064 (_buffer[_pos++] & 0xff));
00065 }
|
|
|
00068 {
00069 // align to long
00070 int pmod4 = _pos & 0x3;
00071 if(pmod4 != 0)
00072 _pos += 4 - pmod4;
00073
00074 _length = 4;
00075 if(_swap)
00076 return (_buffer[_pos++] & 0x000000ff) |
00077 ((_buffer[_pos++] << 8) & 0x0000ff00) |
00078 ((_buffer[_pos++] << 16) & 0x00ff0000) |
00079 (_buffer[_pos++] << 24);
00080 else
00081 return (_buffer[_pos++] << 24) |
00082 ((_buffer[_pos++] << 16) & 0x00ff0000) |
00083 ((_buffer[_pos++] << 8) & 0x0000ff00) |
00084 (_buffer[_pos++] & 0x000000ff);
00085 }
|
|
|
00089 {
00090 int len = readLong();
00091 char[] result = new char[len-1]; //Don't store ending NULL char
00092 for(int i=0; i<len-1; i++)
00093 result[i] = (char)(_buffer[_pos++] & 0xff);
00094
00095 _length = 4+len;
00096 _pos++; //skip NULL char
00097
00098 return new String(result);
00099 }
|
|
|
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001