org.iids.aos.util
Class RawString

java.lang.Object
  extended by org.iids.aos.util.RawString

public class RawString
extends java.lang.Object


Constructor Summary
RawString()
           
 
Method Summary
static java.lang.String byteArray2String(byte[] input)
          Create string from byte[] but strip null-bytes from input.
static byte[] string2ByteArrayOf(java.lang.String contents, int arraysize)
          Convert String to byte[] of fixed max size.
static int strlen(byte[] input)
          'Classic' strlen function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RawString

public RawString()
Method Detail

strlen

public static int strlen(byte[] input)
'Classic' strlen function. Obtain length of String from a given array of characters.


string2ByteArrayOf

public static byte[] string2ByteArrayOf(java.lang.String contents,
                                        int arraysize)
Convert String to byte[] of fixed max size.

Useful for interaction with AOS kernel, which uses fixed size Strings in its TOC entries.

There will always be a terminating null character, if the String does not fit then the result will be truncated. No more than contents.length() bytes will be copied, the result is padded with zero bytes (just like a C string).

Parameters:
contents - String contents to fill byte array
arraysize - Exact size of the resulting array.
Returns:
An array with at most the first arraysize-1 bytes from contents copied into it. The rest of the array is padded with zero bytes. The last byte of the array is always zero (C string style)

byteArray2String

public static java.lang.String byteArray2String(byte[] input)
Create string from byte[] but strip null-bytes from input.

Convert byte[] to String. If it has any trailing zero bytes then these are not part of the resulting String. This is different to what the String(byte[]) constructor does, because this constructor includes these zero bytes in the resulting String.

Parameters:
input - byte[] to convert to a String.
Returns:
new String with the contents of input represented as String.


Copyright © 2003, 2004 IIDS Group. All Rights Reserved.