|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.scopemvc.core.Selector
An identifier for model properties. Selectors are created by the factory
methods fromString(java.lang.String)
and fromInt(int)
. Properties can be
identified by a String name (eg the "address" property of a Customer) or an
integer index (eg element 1 of a List).
Selectors can be assembled in a list to identify a property in a model
contained within another model. For example, the name
of the
pet
of a Person
. This Selector would be created by
Selector.fromString("pet.name")
and applied to a Person model
object. Similarly, the name of a Person's first pet could be identified using
Selector.fromString("pets.0.name")
assuming that Person contains
a List or array of Pets that contain a name property.
Field Summary | |
static java.lang.String |
DELIMITER
Separator character between Selectors expressed as a String. |
Method Summary | |
static java.lang.String |
asString(Selector inSelector)
Flatten the Selector list to a String that could be passed into fromString(java.lang.String) to recreate it. |
void |
chain(Selector inSelector)
Add a Selector on the end of this list. |
Selector |
deepClone()
Return a clone of the entire list of Selectors from this . |
boolean |
equals(java.lang.Object inObject)
A deep compare, following down the list of selectors. |
static IntIndexSelector |
fromInt(int inIndex)
Make a simple Selector to identify a property at an int index. |
static Selector |
fromString(java.lang.String inSelectorDescription)
Make a Selector to identify a property by its String name, or to create a Selector list that identifies a property by navigating a hierarchy of submodels. |
Selector |
getLast()
Get the last Selector in the list. |
abstract java.lang.String |
getName()
Used to serialise Selectors asString(org.scopemvc.core.Selector) and for debug by toString() . |
Selector |
getNext()
Get the next Selector in the list, if any. |
protected abstract Selector |
getShallowCopy()
Return a shallow copy of the head of this . |
void |
removeLast()
Remove the terminal Selector. |
void |
removeLast(Selector terminalSelector)
Remove the terminal Selector. |
protected void |
setNext(Selector inSelector)
Set the next Selector in the list. |
protected abstract boolean |
shallowEquals(Selector inSelector)
Compare the head Selector of this against the head of
another Selector list -- ie a shallow compare operation (not including
the chained selectors). |
boolean |
startsWith(Selector inSelector)
Does this Selector list start with the list passed in? |
java.lang.String |
toString()
For debug. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String DELIMITER
fromString(java.lang.String)
,
asString(org.scopemvc.core.Selector)
,
Constant Field ValuesMethod Detail |
public static IntIndexSelector fromInt(int inIndex)
return Selector.fromInt(0);
inIndex
- The index of the property in a List
public static Selector fromString(java.lang.String inSelectorDescription)
Selector.fromString("name");
will identify the name
property of a Person when applied to a Person model object. Selector.fromString("pet.0.name");
will identify the name
property of the first Pet of a Person when applied to a Person model
object.
inSelectorDescription
- The string representation of a Selector
public static java.lang.String asString(Selector inSelector)
fromString(java.lang.String)
to recreate it.
inSelector
- flatten this Selector to a String representation.
fromString(java.lang.String)
to recreate the Selector list. Return
"" for null Selector.public final Selector getNext()
Selector petNameSelector = Selector.fromString("pet.name"); return petNameSelector.getNext();returns a Selector that is
equals()
the following
Selector: Selector.fromString("name");
public final Selector getLast()
Selector petNameSelector = Selector.fromString("pets.1.name"); return petNameSelector.getLast();returns a Selector that is
equals()
the following
Selector: Selector.fromString("name");
public abstract java.lang.String getName()
asString(org.scopemvc.core.Selector)
and for debug by toString()
.
public final void chain(Selector inSelector)
Add a Selector on the end of this list.
For example:
Selector petSelector = Selector.fromString("pet"); Selector nameSelector = Selector.fromString("name"); petSelector.chain(nameSelector); return petSelector;returns a Selector that is
equals()
this one: Selector.fromString("pet.name");
inSelector
- The Selector to chain at the end of the current
Selectorpublic final void removeLast()
public final void removeLast(Selector terminalSelector)
terminalSelector
- TODO: Describe the Parameterpublic final boolean startsWith(Selector inSelector)
Does this Selector list start with the list passed in?
For example, this returns true
:
Selector petSelector = Selector.fromString("pet"); Selector petNameSelector = Selector.fromString("pet.name"); return (petNameSelector.startsWith(petSelector));but this returns
false
: Selector nameSelector = Selector.fromString("name"); Selector petNameSelector = Selector.fromString("pet.name"); return (petNameSelector.startsWith(nameSelector));
inSelector
- A Selector
public final boolean equals(java.lang.Object inObject)
A deep compare, following down the list of selectors.
For example, this returns true
:
Selector petSelector = Selector.fromString("pet"); Selector nameSelector = Selector.fromString("name"); Selector petNameSelector = Selector.fromString("pet.name"); petSelector.chain(nameSelector); return (petSelector.equals(petNameSelector));but this returns
false
: Selector petSelector = Selector.fromString("pet"); Selector petNameSelector = Selector.fromString("pet.name"); return (petSelector.equals(petNameSelector));
equals
in class java.lang.Object
inObject
- An Object to test for equality, mostly another Selector
public final Selector deepClone()
this
.
public final java.lang.String toString()
toString
in class java.lang.Object
protected abstract Selector getShallowCopy()
this
.
protected final void setNext(Selector inSelector)
inSelector
- Selector to set as the next in the list after this
chain(org.scopemvc.core.Selector)
protected abstract boolean shallowEquals(Selector inSelector)
this
against the head of
another Selector list -- ie a shallow compare operation (not including
the chained selectors).
inSelector
- The Selector to test
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |