SSE4E GPError GPSystem ByteString ByteBuffer TLV TLVList Card Atr Key Crypto Application GPApplication GPSecDomain ASN1 CardFile IsoSecureChannel ApplFactory GPXML JsScript CardSim X509 CRL KeyStore CMSSignedData CMSGenerator XMLSignature OCSPQuery LDAP SOAP URLConnection PKCS11Provider PKCS11Session PKCS11Object OutlineNode OpenSCDP |
ByteBuffer - Reference DocumentationImplementation of a mutuable byte buffer. Index of MethodsProperties
ConstructorPrototypeByteBuffer() ByteBuffer(String stringValue, Number encoding) ByteBuffer(ByteString byteString) DescriptionCreate a empty ByteBuffer object or a ByteBuffer object containing the data from stringValue decoded according to format defined in argument encoding or a ByteBuffer object containing the ByteString object passed as argument The following encoding formats can be used for the stringValue argument: HEX - A string containing hexadecimal characters and arbitrary delimiters. ASCII - A string containing ASCII characters and characters from Latin-1. UTF8 - A string containing Unicode characters. BASE64 - A string containing BASE-64 encoded data. OID - A string containing an object identifier in dotted notation or separated by blanks (This is a proprietary extension to Global Platform Scripting). Arguments
Exceptions
Examplex = new ByteBuffer(); assert(x != null); assert(x instanceof ByteBuffer); x = new ByteBuffer("1234", HEX); assert(x.length == 2); assert(x.toString() == "12 34"); x = new ByteBuffer("0x1234 56.78.90+AB#cd'EF", HEX); assert(x.length == 8); assert(x.toString() == "12 34 56 78 90 AB CD EF"); x = new ByteBuffer("1234ABCDÄÖÜß", ASCII); assert(x.length == 12); assert(x.toString() == "31 32 33 34 41 42 43 44 C4 D6 DC DF"); x = new ByteBuffer("1234ABCDÄÖÜß", UTF8); assert(x.length == 16); assert(x.toString() == "31 32 33 34 41 42 43 44 C3 84 C3 96 C3 9C C3 9F"); x = new ByteBuffer("SGVsbG8gV29ybGQ=", BASE64); assert(x.length == 11); assert(x.toString(ASCII) == "Hello World"); x = new ByteBuffer(new ByteString("1234", HEX)); assert(x.length == 2); assert(x.toString() == "12 34"); x = new ByteBuffer("1.2.840.113549.1.1.2", OID); assert(x.length == 9); assert(x.toString(OID) == "1.2.840.113549.1.1.2"); assert(x.toString(HEX) == "2A864886F70D010102"); x = new ByteBuffer("1 2 840 113549 1 1 2", OID); assert(x.toString(HEX) == "2A864886F70D010102"); toString()PrototypeString toString(Number encoding) DescriptionReturn string containing binary data in given encodingArguments
Return
Exceptions
Examplex = new ByteBuffer("41 42 43", HEX); assert(x.toString(HEX) == "414243"); x = new ByteBuffer("41 42 43 C4 D6 DC DF", HEX); assert(x.toString(ASCII) == "ABCÄÖÜß"); x = new ByteBuffer("C3 84 C3 96 C3 9C C3 9F", HEX); assert(x.toString(UTF8) == "ÄÖÜß"); x = new ByteBuffer("Hello World", ASCII); assert(x.toString(BASE64) == "SGVsbG8gV29ybGQ="); append()PrototypeByteBuffer append(ByteBuffer byteBuffer) ByteBuffer append(ByteString byteString) ByteBuffer append(Number byteValue) ByteBuffer append(String stringValue) DescriptionAppend to the ByteBuffer at the end the content of the ByteBuffer or ByteString object, the ASCII encoded string or the byte given as argument.Arguments
Return
Exceptions
Examplex = new ByteBuffer(); x.append(new ByteBuffer("ABC", ASCII)); assert(x.toString() == "41 42 43"); x.append("123"); assert(x.toString() == "41 42 43 31 32 33"); x.append(new ByteString("ABC", ASCII)); assert(x.toString() == "41 42 43 31 32 33 41 42 43"); str = 0x20; x.append(str); assert(x.toString() == "41 42 43 31 32 33 41 42 43 20"); byteAt()PrototypeNumber byteAt(Number offset) DescriptionReturn the byte at the zero based offset in the ByteBufferArguments
Return
Exceptions
Examplex = new ByteBuffer("123ABCÄÖÜ", ASCII); assert(typeof(x.byteAt(0) == "number")); assert(x.byteAt(0) == 0x31); assert(x.byteAt(3) == 0x41); assert(x.byteAt(6) == 0xC4); clear()PrototypeByteBuffer clear() ByteBuffer clear(Number offset) ByteBuffer clear(Number offset, Number length) DescriptionClears the area specified by offset and length in the ByteBuffer. Bytes behind the cleared area are moved to offset. If length is missing, then the remaining length from offset to the end of the ByteBuffer is cleared. If offset and length are missing from the argument list, then the whole ByteBuffer is cleared.Arguments
Return
Exceptions
Examplex = new ByteBuffer("123456", ASCII); x.clear(2, 2); assert(x.toString(ASCII) == "1256"); x.clear(2); assert(x.toString(ASCII) == "12"); x.clear(); assert(x.length == 0); copy()PrototypeByteBuffer copy(Number offset, ByteBuffer byteBuffer) ByteBuffer copy(Number offset, ByteString byteString) ByteBuffer copy(Number offset, Number byteValue) ByteBuffer copy(Number offset, String stringValue) DescriptionCopy the bytes from the argument into the ByteBuffer at offset and replace the bytes contained. The length of the ByteBuffer is not changed.Arguments
Return
Exceptions
Examplex = new ByteBuffer("123456", ASCII); x.copy(0, "AB"); assert(x.toString(ASCII) == "AB3456"); y = new ByteBuffer("CD", ASCII); x.copy(2, y); assert(x.toString(ASCII) == "ABCD56"); y = new ByteString("EF", ASCII); x.copy(4, y); assert(x.toString(ASCII) == "ABCDEF"); find()PrototypeNumber find(ByteString value) Number find(ByteString value, Number offset) DescriptionFind the first occurence of the value starting at offset.Arguments
Return
Exceptions
Examplex = new ByteBuffer("ABCDABCD", ASCII); y = new ByteString("BC", ASCII); assert(x.find(y) == 1); assert(x.find(y, 2) == 5); assert(x.find(y, -2) == 1); y = new ByteString("CD", ASCII); assert(x.find(y, 4) == 6); y = new ByteString("CD", ASCII); assert(x.find(y, 6) == 6); y = new ByteString("CB", ASCII); assert(x.find(y) == -1); y = new ByteString("BCDE", ASCII); assert(x.find(y) == -1); y = new ByteString("", ASCII); assert(x.find(y) == 0); x = new ByteBuffer("", ASCII); y = new ByteString("", ASCII); assert(x.find(y) == 0); assert(x.find(y, 0) == 0); insert()PrototypeByteBuffer insert(Number offset, ByteBuffer byteBuffer) ByteBuffer insert(Number offset, ByteString byteString) ByteBuffer insert(Number offset, Number byteValue) ByteBuffer insert(Number offset, String stringValue) DescriptionInsert the bytes from the argument at offset.Arguments
Return
Exceptions
Examplex = new ByteBuffer("123456", ASCII); x.insert(0, "AB"); assert(x.toString(ASCII) == "AB123456"); y = new ByteBuffer("CD", ASCII); x.insert(2, y); assert(x.toString(ASCII) == "ABCD123456"); y = new ByteString("EF", ASCII); x.insert(10, y); assert(x.toString(ASCII) == "ABCD123456EF"); x.insert(1, 0x31); assert(x.toString(ASCII) == "A1BCD123456EF"); toByteString()PrototypeByteString toByteString() ByteString toByteString(Number offset) ByteString toByteString(Number offset, Number count) DescriptionReturn all or a fraction of the ByteBuffer as ByteString.Arguments
Return
Exceptions
Examplex = new ByteBuffer("123456", ASCII); y = x.toByteString(); assert(y.toString(ASCII) == "123456"); y = x.toByteString(3); assert(y.toString(ASCII) == "456"); y = x.toByteString(2, 2); assert(y.toString(ASCII) == "34"); y = x.toByteString(6, 0); assert(y.toString(ASCII) == ""); © Copyright 2003 - 2010 CardContact Software & System Consulting, Minden, Germany |