|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgoodsjpi.Persistent
goodslib.AnyArray
goodslib.ArrayOfChar
ArrayOfChar
is just that, an array of chars. It is fully
persistent, as it it's derived from Persistent. All reads cause a fetch of the
data, all writes mark it dirty and to be saved.
Field Summary | |
protected char[] |
array
array holds the chars in an [] |
Fields inherited from class goodslib.AnyArray |
used |
Fields inherited from class goodsjpi.Persistent |
defaultMetaobject, metaobject |
Constructor Summary | |
ArrayOfChar(char[] src)
Creates a new ArrayOfChar instance, as a copy of the given
char[] |
|
ArrayOfChar(int size)
Creates a new ArrayOfChar instance. |
|
ArrayOfChar(int size,
int allocatedSize)
Creates a new ArrayOfChar instance. |
|
ArrayOfChar(java.lang.String str)
Creates a new ArrayOfChar instance. |
Method Summary | |
void |
append(char[] tail)
append add the given values to the end of the array |
void |
append(java.lang.String tail)
append the given String at the end |
void |
changeSize(int newSize)
Resize the amount of space taken by the array. |
int |
compare(ArrayOfChar a)
compare compares two object. |
int |
compare(java.lang.String s)
compare works like the compare(ArrayOfChar) |
int |
compareTo(java.lang.Object o)
compareTo calls the other compare functions, depending on the
given object |
void |
copy(int dstIndex,
char[] src,
int srcIndex,
int count)
copy into this array from a destination, a given amount of values.
|
boolean |
equals(java.lang.Object obj)
equals checks whether the given object is equivalent to this.
|
char |
getAt(int index)
Get a char at the specified index |
int |
hashCode()
Return a hashCode |
int |
indexOf(char ch)
indexOf returns the first occurrence of val |
void |
insert(int index,
int count,
char value)
insert a "count" amount of values at a given index. |
int |
lastIndexOf(char ch)
Find the lastIndexOf a given value |
char |
pop()
Use the array as a stack and pop a value. |
void |
push(char value)
Use the array as a stack with the push method. |
void |
putAt(int index,
char value)
Put a char value at a given index |
void |
remove(int index,
int count)
remove a number of values. |
char[] |
toArray()
toArray converts the internal representation to a char[] , of
correct size. |
char |
top()
Check the top boolean with the top method. |
java.lang.String |
toString()
toString makes a String out of the bytes |
Methods inherited from class goodslib.AnyArray |
length |
Methods inherited from class goodsjpi.Persistent |
attachToStorage, clone, clusterWith, finalize, getDatabase, getOid, getStorageId, onLoad |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected char[] array
array
holds the chars in an []
Constructor Detail |
public ArrayOfChar(int size)
ArrayOfChar
instance.
size
- is the initial size, (length)public ArrayOfChar(int size, int allocatedSize)
ArrayOfChar
instance. (Full of false)
size
- , or length of the arrayallocatedSize
- is the size it can grow to without re-sizingpublic ArrayOfChar(char[] src)
ArrayOfChar
instance, as a copy of the given
char[]
src
- a char[]
that will be copiedpublic ArrayOfChar(java.lang.String str)
ArrayOfChar
instance.
str
- a String
valueMethod Detail |
public void putAt(int index, char value)
index
- an int
value, where the value should be setvalue
- the char
value to be setpublic char getAt(int index)
index
- of the char you want
char
value, at index "index"public void changeSize(int newSize)
newSize
- an int
denoting the new size.public void insert(int index, int count, char value)
insert
a "count" amount of values at a given index. Throws an
IndexOutOfBoundsException for too small (<0) or too big (>length) count or index.
index
- , where to start inserting value(s)count
- , how many values to insertvalue
- a char
value to insertpublic void remove(int index, int count)
remove
a number of values. The array shrinks in it's length, but no
resizing is done. Get an IndexOutOfBoundsException for inappropriate index or
count values.
index
- , where to start removingcount
- , how many values to removepublic void push(char value)
push
method.
value
- , a char
to push to the stackpublic char pop()
pop
a value. (Value is removed)
IndexOutOfBoundsExceptions comes when array has hit 0 length.
char
valuepublic char top()
top
method. This returns what
pop
returns, just it doesn't remove the value. In other stack
implementations it may be called peek()
char
valuepublic void append(char[] tail)
append
add the given values to the end of the array
tail
- a char[]
that will be appendedpublic void append(java.lang.String tail)
append
the given String at the end
tail
- a String
valuepublic char[] toArray()
toArray
converts the internal representation to a char[] , of
correct size. Ie: the .length of the return == this.size()
char[]
valuepublic java.lang.String toString()
toString
makes a String out of the bytes
String
representation of the bytespublic void copy(int dstIndex, char[] src, int srcIndex, int count)
copy
into this array from a destination, a given amount of values.
Get a IndexOutOfBounds if the src or count don't fit
dstIndex
- , the index (of this array) where to copy tosrc
- a char[]
, where to copy fromsrcIndex
- an int
, where to start copying fromcount
- an int
, how many values to copypublic int compareTo(java.lang.Object o)
compareTo
calls the other compare functions, depending on the
given object
compareTo
in interface java.lang.Comparable
o
- an Object
to compare against
int
, the resultpublic int compare(java.lang.String s)
compare
works like the compare(ArrayOfChar)
s
- a String
value to compare against
int
, the resultpublic int compare(ArrayOfChar a)
compare
compares two object. In that it works like the
equals method. But compare returns more than just a boolean yes/no,
it also introduces an ordering between the objects.
a
- ArrayOfChar
to compare against
int
, 0 if equal, negative if the object is smaller and
positive if it is bigger.public int hashCode()
hashCode
hashCode
in class Persistent
int
value, the hashpublic boolean equals(java.lang.Object obj)
equals
checks whether the given object is equivalent to this.
Ie. If it has the same data representation. It does not have to be the same,
which is checked by == operator.
obj
- an Object
to check
boolean
indicating whether obj is equivalentpublic int indexOf(char ch)
indexOf
returns the first occurrence of val
ch
- a char
to be looked for
int
, where the value was found, or -1public int lastIndexOf(char ch)
lastIndexOf
a given value
ch
- a char
value to be found (from the back)
int
, where the value was found, or -1
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |