|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.cache.Fqn<E>
@Immutable public class Fqn<E>
A Fully Qualified Name (Fqn) is a list of names (typically Strings but can be any Object),
which represent a path to a particular Node
or sometimes a Region
in a Cache
.
ROOT
), or relative to any node in the cache. Reading the
documentation on each API call that makes use of Fqn
s will tell you whether the API expects a
relative or absolute Fqn.
For instance, using this class to fetch a particular node might look like
this. (Here data on "Joe" is kept under the "Smith" surname node, under
the "people" tree.)
FqnAlternatively, the same Fqn could be constructed using an array:abc = Fqn.fromString("/people/Smith/Joe/"); Node joesmith = Cache.getRoot().getChild(abc);
FqnThis is a bit more efficient to construct. Note thatabc = new Fqn (new String[] { "people", "Smith", "Joe" });
Fqn f = new Fqn("/a/b/c");
is not the same as
Fqn f = Fqn.fromString("/a/b/c");
The former will result in a single Fqn, called "/a/b/c" which hangs directly under Fqn.ROOT.
The latter will result in 3 Fqns, called "a", "b" and "c", where "c" is a child of "b", "b" is a child of "a", and "a" hangs off Fqn.ROOT.
Another way to look at it is that the "/" separarator is only parsed when it forms
part of a String passed in to Fqn.fromString() and not otherwise.
NOTE that support for custom object elements of Fqns will be dropped from JBoss Cache 3.0.0 onwards. Consider
it's use in 2.x as a deprecated feature.. From 3.0.0 onwards, Fqns will only be able to contain Strings or
Java primitives (byte, short, int, long, float, double, char and boolean).
Field Summary | |
---|---|
static Fqn |
ROOT
Immutable root FQN. |
static String |
SEPARATOR
Separator between FQN elements. |
Constructor Summary | |
---|---|
Fqn()
Constructs a root Fqn |
|
Fqn(E... names)
Constructs a Fqn from an array of names. |
|
Fqn(Fqn<E> base,
E... childNames)
Constructs a Fqn from a base and two relative names. |
|
Fqn(Fqn<E> base,
Fqn<E> relative)
Constructs a Fqn from a base and relative Fqn. |
|
Fqn(Fqn<E> base,
List<E> relative)
Constructs a Fqn from a base and a list of relative names. |
|
Fqn(List<E> names)
Constructs a FQN from a list of names. |
|
Fqn(List<E> names,
boolean safe)
If safe is false, Collections.unmodifiableList() is used to wrap the list passed in. |
Method Summary | ||
---|---|---|
Fqn<E> |
clone()
Clones the Fqn. |
|
int |
compareTo(Fqn<?> Fqn)
Compares this Fqn to another using FqnComparator . |
|
boolean |
equals(Object obj)
Returns true if obj is a Fqn with the same elements. |
|
static Fqn<String> |
fromString(String stringRepresentation)
Returns a new Fqn from a string, where the elements are deliminated by one or more separator ( SEPARATOR ) characters. |
|
E |
get(int n)
|
|
Fqn<E> |
getAncestor(int generation)
Obtains an ancestor of the current Fqn. |
|
E |
getLastElement()
|
|
String |
getLastElementAsString()
If this is the root, returns SEPARATOR . |
|
Fqn<E> |
getParent()
Returns the parent of this Fqn. |
|
Fqn<E> |
getSubFqn(int startIndex,
int endIndex)
Obtains a sub-Fqn from the given Fqn. |
|
boolean |
hasElement(E element)
|
|
int |
hashCode()
Returns a hash code with Fqn elements. |
|
boolean |
isChildOf(Fqn<E> parentFqn)
Returns true if this Fqn is child of parentFqn. |
|
boolean |
isChildOrEquals(Fqn<E> parentFqn)
Returns true if this Fqn is equals or the child of parentFqn. |
|
boolean |
isRoot()
Returns true if this is a root Fqn. |
|
List<E> |
peekElements()
Peeks into the elements that build up this Fqn. |
|
void |
readExternal(ObjectInput in)
|
|
static
|
root()
|
|
int |
size()
|
|
String |
toString()
Returns this Fqn as a string, prefixing the first element with a SEPARATOR and
joining each subsequent element with a SEPARATOR . |
|
void |
writeExternal(ObjectOutput out)
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String SEPARATOR
public static final Fqn ROOT
Constructor Detail |
---|
public Fqn()
public Fqn(List<E> names)
names
- List of namespublic Fqn(List<E> names, boolean safe)
names
- List of namessafe
- whether this list is referenced externally (safe = false) or not (safe = true).public Fqn(E... names)
names
- Names that comprose this Fqnpublic Fqn(Fqn<E> base, Fqn<E> relative)
base
- parent Fqnrelative
- Sub-Fqn relative to the parentpublic Fqn(Fqn<E> base, List<E> relative)
base
- parent Fqnrelative
- List of elements that identify the child Fqn, relative to the parentpublic Fqn(Fqn<E> base, E... childNames)
base
- parent FqnchildNames
- elements that denote the path to the Fqn, under the parentMethod Detail |
---|
public static Fqn<String> fromString(String stringRepresentation)
SEPARATOR
) characters.Fqn.fromString("/a/b/c/");
new Fqn("a", "b", "c");
new Fqn("/a/b/c");
stringRepresentation
- String representation of the Fqn
Fqn(Object[])
public Fqn<E> getAncestor(int generation)
elements.subList(0, generation)
such that if
generation == Fqn.size()
then the return value is the Fqn itself (current generation), and if
generation == Fqn.size() - 1
then the return value is the same as
Fqn.getParent()
i.e., just one generation behind the current generation.
generation == 0
would return Fqn.ROOT.
generation
- the generation of the ancestor to retrieve
public Fqn<E> getSubFqn(int startIndex, int endIndex)
elements.subList(startIndex, endIndex)
public int size()
public E get(int n)
n
- index of the element to return
public E getLastElement()
getLastElementAsString()
public boolean hasElement(E element)
element
- element to find
public Fqn<E> clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
SEPARATOR
and
joining each subsequent element with a SEPARATOR
.
If this is the root Fqn, returns SEPARATOR
.
Example:
new Fqn(new Object[] { "a", "b", "c" }).toString(); // "/a/b/c" Fqn.ROOT.toString(); // "/"
toString
in class Object
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public boolean isChildOf(Fqn<E> parentFqn)
Fqnf1 = Fqn.fromString("/a/b"); Fqn f2 = Fqn.fromString("/a/b/c"); assertTrue(f1.isChildOf(f2)); assertFalse(f1.isChildOf(f1)); assertFalse(f2.isChildOf(f1));
parentFqn
- candidate parent to test against
public boolean isChildOrEquals(Fqn<E> parentFqn)
Fqnf1 = Fqn.fromString("/a/b"); Fqn f2 = Fqn.fromString("/a/b/c"); assertTrue(f1.isChildOrEquals(f2)); assertTrue(f1.isChildOrEquals(f1)); assertFalse(f2.isChildOrEquals(f1));
parentFqn
- candidate parent to test against
public Fqn<E> getParent()
ROOT
.
Examples:
Fqnf1 = Fqn.fromString("/a"); Fqn f2 = Fqn.fromString("/a/b"); assertEquals(f1, f2.getParent()); assertEquals(Fqn.ROOT, f1.getParent().getParent()); assertEquals(Fqn.ROOT, Fqn.ROOT.getParent());
public static <T> Fqn<T> root()
public boolean isRoot()
public String getLastElementAsString()
SEPARATOR
.
public List<E> peekElements()
public int compareTo(Fqn<?> Fqn)
FqnComparator
.
compareTo
in interface Comparable<Fqn<?>>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |