|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nz.ac.waikato.jdsl.core.ref.ToString
public class ToString
Collection of static methods that generate a string representing a container or accessor. Since all the useful methods are static, it should never be necessary to create an instance of ToString.
Every stringfor(.) method that takes a container type comes in two flavors: a default and one parametrized for how to stringify an accessor. The former is used in the toString() method of the applicable containers. The latter may be used if you want more or less information about each accessor than the default gives.
Since it is not possible to guarantee a snapshot of a given container when many threads are running (unless the container is synchronized), the stringfor(.) methods cannot guarantee snapshot semantics for output.
Nested Class Summary | |
---|---|
static class |
ToString.LocatorCollectionsStyle
Stringifies a locator in the Java Collections style: (key)=(element). |
static interface |
ToString.LocatorToString
Way to parameterize the stringifying of a locator, within the stringifying of a container. |
static interface |
ToString.PositionToString
Way to parametrize the stringifying of a position, within the stringifying of a container. |
static class |
ToString.PositionWritesElementOnly
Stringifies a position by giving the string representation of the position's element. |
Field Summary | |
---|---|
static ToString.LocatorToString |
loc_to_collections_style_s
|
static ToString.PositionToString |
pos_to_element_s
|
Method Summary | |
---|---|
static java.lang.String |
stringfor(InspectableKeyBasedContainer k)
Default version of stringfor( InspKBC, LTS ). |
static java.lang.String |
stringfor(InspectableKeyBasedContainer k,
ToString.LocatorToString lts)
Gives string representation of a dictionary or priority queue, parameterized by how to represent each locator (i.e., constructs a string by iterating over all locators of the container, concatenating the specified string representation of each locator). |
static java.lang.String |
stringfor(InspectableSequence s)
Default version of stringfor( InspSeq, PTS ). |
static java.lang.String |
stringfor(InspectableSequence s,
ToString.PositionToString pts)
Gives string representation of a sequence, parameterized by how to represent each position (i.e., constructs a string by iterating over all positions of the sequence, concatenating the specified string representation of each position). |
static java.lang.String |
stringfor(InspectableTree t)
Default version of stringfor( InspTree, PTS ). |
static java.lang.String |
stringfor(InspectableTree t,
ToString.PositionToString pts)
Gives string representation of a tree, parametrized by how to represent each position. |
static java.lang.String |
stringfor(Locator loc)
|
static java.lang.String |
stringfor(Position pos)
|
static void |
writeNodeAndChildren(Position subtreeRoot,
ToString.PositionToString pts,
java.io.DataOutputStream ostream,
InspectableTree t,
int indentation,
int indentation_increment)
Recursively dumps a byte representation of a subtree onto a stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final ToString.PositionToString pos_to_element_s
public static final ToString.LocatorToString loc_to_collections_style_s
Method Detail |
---|
public static java.lang.String stringfor(InspectableSequence s, ToString.PositionToString pts)
s
- sequence to stringifypts
- how to stringify each position
public static java.lang.String stringfor(InspectableSequence s)
public static void writeNodeAndChildren(Position subtreeRoot, ToString.PositionToString pts, java.io.DataOutputStream ostream, InspectableTree t, int indentation, int indentation_increment)
subtreeRoot
- root of subtree to representpts
- way to stringify each positionostream
- stream on which to represent the subtreet
- tree, so children(.) can be calledindentation
- number of spaces to indent this levelindentation_increment
- amount by which indentation will
be increased before writing childrenpublic static java.lang.String stringfor(InspectableTree t, ToString.PositionToString pts)
t
- tree to stringifypts
- how to stringify each position
java.lang.IndexOutOfBoundsException
- if the tree is more then 100 levels deeppublic static java.lang.String stringfor(InspectableTree t)
public static java.lang.String stringfor(InspectableKeyBasedContainer k, ToString.LocatorToString lts)
k
- key-based container to stringifylts
- how to stringify each locator
public static java.lang.String stringfor(InspectableKeyBasedContainer k)
public static java.lang.String stringfor(Position pos)
pos
- Position for which string representation is desired
pos
public static java.lang.String stringfor(Locator loc)
loc
- Locator for which string representation is desired
loc
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |