## org.hornetq.api.core
Class SimpleString

    java.lang.Object
      org.hornetq.api.core.SimpleString

All Implemented Interfaces:
  Serializable, CharSequence, Comparable<SimpleString>

    public class SimpleString

extends Object
implements CharSequence, Serializable, Comparable<SimpleString>

A simple String class that can store all characters, and stores as simple byte[], this minimises expensive copying between String objects. This object is used heavily throughout HornetQ for performance reasons.

Author:
  Tim Fox
See Also:
  Serialized Form

Constructor Summary
`SimpleString(byte[] data)` creates a SimpleString from a byte array
`SimpleString(String string)` creates a SimpleString from a conventional String

Method Summary
`char` `charAt(int pos)`
`int` `compareTo(SimpleString o)`
`SimpleString` `concat(char c)` Concatenates a SimpleString and a char
`SimpleString` `concat(SimpleString toAdd)` Concatenates 2 SimpleString's
`SimpleString` `concat(String toAdd)` Concatenates a SimpleString and a String
`boolean` `contains(char c)` checks to see if this SimpleString contains the char parameter passed in
`boolean` `equals(Object other)`
`void` `getChars(int srcBegin, int srcEnd, char[] dst, int dstPos)` This method performs a similar function to `String.getChars(int, int, char[], int)`.
`byte[]` `getData()` returns the underlying byte array of this SimpleString
`int` `hashCode()`
`int` `length()`
`int` `sizeof()` returns the size of this SimpleString
`static int` `sizeofNullableString(SimpleString str)` returns the size of a SimpleString which could be null
`static int` `sizeofString(SimpleString str)` returns the size of a SimpleString
`SimpleString[]` `split(char delim)` Splits this SimpleString into an array of SimpleString using the char param as the delimiter.
`boolean` `startsWith(SimpleString other)` returns true if the SimpleString parameter starts with the same data as this one.
`CharSequence` `subSequence(int start, int end)`
`static SimpleString` `toSimpleString(String string)` Returns a SimpleString constructed from the `string` parameter.
`String` `toString()`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### SimpleString

    public SimpleString(String string)

  creates a SimpleString from a conventional String

  Parameters:
    `string` - the string to transform

### SimpleString

    public SimpleString(byte[] data)

  creates a SimpleString from a byte array

  Parameters:
    `data` - the byte array to use

Method Detail

### toSimpleString

    public static SimpleString toSimpleString(String string)

  Returns a SimpleString constructed from the `string` parameter. If `string` is `null`, the return value will be `null` too.

### length

    public int length()

  Specified by:
    `length` in interface `CharSequence`

### charAt

    public char charAt(int pos)

  Specified by:
    `charAt` in interface `CharSequence`

### subSequence

    public CharSequence subSequence(int start,
                                    int end)

  Specified by:
    `subSequence` in interface `CharSequence`

### compareTo

    public int compareTo(SimpleString o)

  Specified by:
    `compareTo` in interface `Comparable<SimpleString>`

### getData

    public byte[] getData()

  returns the underlying byte array of this SimpleString

  Returns:
    the byte array

### startsWith

    public boolean startsWith(SimpleString other)

  returns true if the SimpleString parameter starts with the same data as this one. false if not.

  Parameters:
    `other` - the SimpelString to look for
  Returns:
    true if this SimpleString starts with the same data

### toString

    public String toString()

  Specified by:
    `toString` in interface `CharSequence`
  Overrides:
    `toString` in class `Object`

### equals

    public boolean equals(Object other)

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### split

    public SimpleString[] split(char delim)

  Splits this SimpleString into an array of SimpleString using the char param as the delimiter. i.e. "a.b" would return "a" and "b" if . was the delimiter

  Parameters:
    `delim` -

### contains

    public boolean contains(char c)

  checks to see if this SimpleString contains the char parameter passed in

  Parameters:
    `c` - the char to check for
  Returns:
    true if the char is found, false otherwise.

### concat

    public SimpleString concat(String toAdd)

  Concatenates a SimpleString and a String

  Parameters:
    `toAdd` - the String to concatenate with.
  Returns:
    the concatenated SimpleString

### concat

    public SimpleString concat(SimpleString toAdd)

  Concatenates 2 SimpleString's

  Parameters:
    `toAdd` - the SimpleString to concatenate with.
  Returns:
    the concatenated SimpleString

### concat

    public SimpleString concat(char c)

  Concatenates a SimpleString and a char

  Parameters:
    `c` - the char to concate with.
  Returns:
    the concatenated SimpleString

### sizeof

    public int sizeof()

  returns the size of this SimpleString

  Returns:
    the size

### sizeofString

    public static int sizeofString(SimpleString str)

  returns the size of a SimpleString

  Parameters:
    `str` - the SimpleString to check
  Returns:
    the size

### sizeofNullableString

    public static int sizeofNullableString(SimpleString str)

  returns the size of a SimpleString which could be null

  Parameters:
    `str` - the SimpleString to check
  Returns:
    the size

### getChars

    public void getChars(int srcBegin,
                         int srcEnd,
                         char[] dst,
                         int dstPos)

  This method performs a similar function to `String.getChars(int, int, char[], int)`. This is mainly used by the Parsers on Filters

  Parameters:
    `srcBegin` -
    `srcEnd` -
    `dst` - dd
    `dstPos` -

Copyright © 2009 Red Hat Inc. All Rights Reserved.