|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gzz.Cell
A class to represent a ZigZag cell.
This class contains convenience methods for accessing and editing cells, but more complicated operations should be used through the specialized dimensions.
There is not necessarily a unique cell to Java object mapping, so there may be several equivalent Java objects representing the same cell. Use the equals method for comparisons.
The cell is identified by the Space space
and the
String id
objects. (Ids are interned-- see
String.intern()
-- to make comparisons fast; internally, id==id
is used.)
There hashCode
is also cached.
The intention is that Space.getCell(id) always results in exactly equivalent cells.
It is also meant that all Cell objects of a single space are of the same type.
Space
,
Dim
Field Summary | |
static int |
cellFormat
|
static int |
ID_AND_TEXT
|
static int |
ID_ONLY
|
static java.lang.String |
rcsid
|
Space |
space
|
static int |
TEXT_ONLY
|
Constructor Summary | |
protected |
Cell(Space space,
int hashcode)
Create a Cell with a null (lazy) id, with given hashcode. |
|
Cell(Space space,
java.lang.String id)
Create a Cell with the given id. |
Method Summary | |
void |
connect(Dim dim,
Cell to)
Connect this cell to another along a dimension. |
void |
connect(Dim dim,
int dir,
Cell to)
Connect this cell to another along a dimension in a specified direction. |
void |
copyText(int ind,
Cell from,
int begin,
int end)
Copy some text from another cell to this cell. |
void |
delete()
Delete this cell. |
void |
deleteText(int begin,
int end)
Delete a piece of text from the cell. |
void |
disconnect(Dim dim,
int dir)
Disconnect another cell from this cell. |
boolean |
equals(java.lang.Object c)
Tests whether this cell is the same as another cell. |
void |
excise(Dim dim)
Delete this cell from a rank along a dimension. |
Cell |
getHomeCell()
|
java.lang.String |
getId()
Get the id of this cell. |
java.lang.Object |
getJavaObject()
|
java.lang.Object |
getJavaObject(Obs o)
Get the Java object associated with this cell, if any. |
Cell |
getOrNew(Dim dim)
|
Cell |
getOrNew(Dim dim,
int dir)
|
Cell |
getOrNew(Dim dim,
int dir,
Obs o)
Get or create a new cell connected to this cell. |
Cell |
getRootclone()
|
Cell |
getRootclone(Obs o)
Get the root clone of this cell: the headcell of the clone dimension. |
Cell |
h(Dim dim)
Find the headcell of a rank. |
Cell |
h(Dim dim,
int dir)
|
Cell |
h(Dim dim,
int dir,
boolean ensuremove)
|
Cell |
h(Dim dim,
int dir,
boolean ensuremove,
Obs o)
Find the headcell of a rank. |
int |
hashCode()
|
void |
hop(Dim dim,
int steps)
Hops the cell along the dimension. |
void |
insert(Dim dim,
int dir,
Cell what)
Insert a cell next to this one in the rank. |
void |
insertText(int ind,
java.lang.String s)
Insert some text to this cell. |
void |
moveText(int ind,
Cell from,
int begin,
int end)
Move some text from another cell to this cell. |
Cell |
N()
Get a new cell associated with this cell (i.e., same slice) |
Cell |
N(Dim dim)
|
Cell |
N(Dim dim,
int dir)
Create a new cell connected to this cell. |
Cell |
N(Dim dim,
int dir,
Obs o)
Create a new cell connected to this cell and attach an observer to it atomically. |
Cell |
s(Dim dim)
|
Cell |
s(Dim dim,
int dir)
Find the neighbour of this cell along a dimension atomically. |
Cell |
s(Dim dim,
int steps,
Obs o)
Find the neighbour of this cell along a dimension and attach an observer to this relation atomically. |
Cell |
s(Dim dim,
Obs o)
Find the next cell along a dimension. |
void |
setText(java.lang.String text)
Set the content of this cell as text. |
java.lang.String |
t()
Returns the text contained in the cell. |
java.lang.String |
t(Obs o)
|
java.lang.String |
toString()
Return a stringized form of this cell. |
Cell |
zzclone()
|
Cell |
zzclone(Cell inSlice)
Clone this cell in the same slice as a given cell. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String rcsid
public final Space space
public static final int TEXT_ONLY
public static final int ID_AND_TEXT
public static final int ID_ONLY
public static int cellFormat
Constructor Detail |
public Cell(Space space, java.lang.String id)
Cell
with the given id.
protected Cell(Space space, int hashcode)
Cell
with a null (lazy) id, with given hashcode.
Method Detail |
public java.lang.String getId()
public final Cell N(Dim dim, int dir)
dim
- Dimension to create the cell alongdir
- The direction, either positive or negativepublic final Cell N(Dim dim)
public final Cell N()
public final Cell getOrNew(Dim dim, int dir, Obs o)
dim
- Dimension to create the cell alongdir
- The direction, either positive or negativepublic final Cell getOrNew(Dim dim, int dir)
public final Cell getOrNew(Dim dim)
public final Cell N(Dim dim, int dir, Obs o)
dim
- Dimension to create the cell alongdir
- The direction, either positive or negativepublic final void delete()
public final void excise(Dim dim)
public final void connect(Dim dim, Cell to) throws gzz.errors.ZZAlreadyConnectedException
dim
- Dimension to connect alongto
- Cell to connect to. This cell will
end up poswards from us.
gzz.errors.ZZAlreadyConnectedException
public final void connect(Dim dim, int dir, Cell to) throws gzz.errors.ZZAlreadyConnectedException
dim
- Dimension to connect alongdir
- The direction, either positive or negativeto
- Cell to connect to.
gzz.errors.ZZAlreadyConnectedException
public final void insert(Dim dim, int dir, Cell what) throws gzz.errors.ZZAlreadyConnectedException
dim
- Dimension to connect alongdir
- The direction, either positive or negativewhat
- Cell to insert
gzz.errors.ZZAlreadyConnectedException
public final void disconnect(Dim dim, int dir)
dim
- Dimension to disconnect alongdir
- The direction, either positive or negativepublic final void setText(java.lang.String text)
text
- The new textpublic final void insertText(int ind, java.lang.String s)
public final void copyText(int ind, Cell from, int begin, int end)
public final void moveText(int ind, Cell from, int begin, int end)
public final void deleteText(int begin, int end)
public final Cell s(Dim dim, int steps, Obs o)
dim
- Dimension to go alongsteps
- The direction, either positive or negative
public final Cell s(Dim dim, int dir)
dim
- Dimension to go alongdir
- The direction, either positive or negative
public final Cell s(Dim dim)
public final Cell s(Dim dim, Obs o)
dim
- Dimension to go along
public final Cell h(Dim dim)
public final Cell h(Dim dim, int dir)
public final Cell h(Dim dim, int dir, boolean ensuremove)
public final Cell h(Dim dim, int dir, boolean ensuremove, Obs o)
dim
- Dimension to go alongdir
- The direction, either positive or negativeensuremove
- If true, this function returns null if
the given cell already is the headcell.
public final java.lang.String t()
public final java.lang.String t(Obs o)
public boolean equals(java.lang.Object c)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public final void hop(Dim dim, int steps)
dim
- The dimension to hop alongsteps
- The number of places to hop. May be negative,
in which case the cell will hop negwards.public final Cell getHomeCell()
public final Cell zzclone()
public final Cell zzclone(Cell inSlice)
public final Cell getRootclone()
public final Cell getRootclone(Obs o)
o
- The observer to call if the return value of this function would
have changed as a result of a structural or other change.public java.lang.String toString()
Currently the format is: The cell ID in single quotes
and the text content after that, in parentheses,
for example '53' (Text in cell)
.
(Changed now to exclude id - still thinking about it...) (Benja: changed it back because it's a pain in the neck for tests and Tuomas isn't there to ask. We can change it again later (when IDs get longer), but at this point in time this is better-- too many test cells do not have content and thus render as a simple and misleading "(null)".)
Ok, here's a solution: nothing should depend on it. we'll read the format from a property.
toString
in class java.lang.Object
public final java.lang.Object getJavaObject()
public final java.lang.Object getJavaObject(Obs o)
o
- The observer to call if the return value of this function would
have changed as a result of a structural or other change.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |