|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.internal.xtend.util.QualifiedNameWithDelimiter
public final class QualifiedNameWithDelimiter
A memory efficient structure to store qualified names composed of string segments separated by '/'. A QualifiedName must be constructed through one its create methods. The structure uses string pooling to store the single segments. Further it maintains a pool of QualifiedName instances itself, so that each QualifiedName exists only once.
Nested Class Summary | |
---|---|
protected static class |
QualifiedNameWithDelimiter.QualifiedNameCache
A cached pool of weakly referenced qualified names. |
protected static class |
QualifiedNameWithDelimiter.StringCache
A cached pool of weakly referenced strings. |
Field Summary | |
---|---|
protected static QualifiedNameWithDelimiter.QualifiedNameCache |
CACHE
The cached pool for the qualified name instances. |
protected static QualifiedNameWithDelimiter |
EMPTY
The qualified name instance corresponding to "/". |
protected static java.lang.String[] |
EMPTY_ARRAY
The instance used to represent no segments. |
protected static QualifiedNameWithDelimiter |
EMPTY_WITHOUT_LEADING_SLASH
The qualified name instance corresponding to the empty string. |
protected int |
hashCode
The cached hash code for this instance. |
protected java.lang.String[] |
segments
The segments for this instance. |
protected static char |
SLASH
The segment separator character. |
protected static QualifiedNameWithDelimiter.StringCache |
STRING_CACHE
A cached for pool for strings. |
protected java.lang.ref.WeakReference<java.lang.String> |
toString
The cached value for toString() . |
Constructor Summary | |
---|---|
protected |
QualifiedNameWithDelimiter(java.lang.String[] segments,
int hashCode)
Creates an instance with the given segments and hash code. |
Method Summary | |
---|---|
QualifiedNameWithDelimiter |
append(QualifiedNameWithDelimiter qualifiedName)
Returns an instance with the given additional segments. |
QualifiedNameWithDelimiter |
append(java.lang.String segment)
Returns an instance with the additional segment or segments, if the given segment contains '/'. |
static QualifiedNameWithDelimiter |
create(java.lang.String... segments)
Returns the qualified name for the given segments, splitting individual segments as appropriate. |
static QualifiedNameWithDelimiter |
create(java.lang.String qualifiedName)
Returns the qualified name for the argument, splitting into segments as appropriate. |
static QualifiedNameWithDelimiter |
createWithoutLeadingSlash(java.lang.String... segments)
Returns the qualified name for the given segments, splitting individual segments as appropriate. |
java.lang.String |
getFirstSegment()
Returns the first segment of the qualified name. |
java.lang.String |
getLastSegment()
Returns the last segment of the qualified name. |
java.lang.String |
getSegment(int index)
Returns the specified segment of the qualified name. |
int |
getSegmentCount()
Returns the number of segments in the qualified name. |
int |
hashCode()
Although there is an override of hash code, there is no override of Object.equals(Object) because the static methods for creation ensure
there is at most one instance created for each unique qualified name. |
boolean |
hasLeadingSlash()
Returns whether the qualified name's string representation starts with a '/'. |
static java.lang.String |
intern(char[] characters,
int offset,
int count)
Returns the cached string with the given range of characters. |
static java.lang.String |
intern(java.lang.String string)
Returns the cached string equal to the given string. |
static void |
main(java.lang.String[] args)
|
boolean |
matches(java.lang.String qualifiedName)
Returns true if the string representation of this qualified name is equal to the given string. |
protected static int |
setLeadingSlash(boolean hasLeadingSlash,
int hashCode)
Returns the hash code with the appropriately swizzled high bit. |
protected static java.lang.String[] |
split(java.lang.String[] segments)
Splits any segment that contains a "/" and returns the composed result. |
java.lang.String |
toString()
Returns a canonical string representation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final char SLASH
protected static final java.lang.String[] EMPTY_ARRAY
protected static final QualifiedNameWithDelimiter.QualifiedNameCache CACHE
protected static final QualifiedNameWithDelimiter.StringCache STRING_CACHE
protected static final QualifiedNameWithDelimiter EMPTY_WITHOUT_LEADING_SLASH
protected static final QualifiedNameWithDelimiter EMPTY
protected final int hashCode
protected java.lang.String[] segments
protected java.lang.ref.WeakReference<java.lang.String> toString
toString()
.
Constructor Detail |
---|
protected QualifiedNameWithDelimiter(java.lang.String[] segments, int hashCode)
Method Detail |
---|
public QualifiedNameWithDelimiter append(QualifiedNameWithDelimiter qualifiedName)
public QualifiedNameWithDelimiter append(java.lang.String segment)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean hasLeadingSlash()
protected static int setLeadingSlash(boolean hasLeadingSlash, int hashCode)
public int getSegmentCount()
public java.lang.String getSegment(int index)
public java.lang.String getLastSegment()
public java.lang.String getFirstSegment()
public int hashCode()
Object.equals(Object)
because the static methods for creation ensure
there is at most one instance created for each unique qualified name.
hashCode
in class java.lang.Object
public boolean matches(java.lang.String qualifiedName)
string representation
of this qualified name is equal to the given string.
public static java.lang.String intern(java.lang.String string)
copy
of it, so it's safe to call this for a string that's a substring of a much larger string.
public static java.lang.String intern(char[] characters, int offset, int count)
public static QualifiedNameWithDelimiter create(java.lang.String qualifiedName)
public static QualifiedNameWithDelimiter create(java.lang.String... segments)
leading slash
.
public static QualifiedNameWithDelimiter createWithoutLeadingSlash(java.lang.String... segments)
leading slash
, unless there is a leading empty string in the segments in which case that leading segment is removed
and the result has a leading slash.
protected static java.lang.String[] split(java.lang.String[] segments)
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |