Package org.eclipse.xtext.naming
Class QualifiedName
- java.lang.Object
-
- org.eclipse.xtext.naming.QualifiedName
-
- All Implemented Interfaces:
java.lang.Comparable<QualifiedName>
public class QualifiedName extends java.lang.Object implements java.lang.Comparable<QualifiedName>
A datatype for dealing with qualified names. Instances are usually provided by aIQualifiedNameProvider
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
QualifiedName.Builder
The Builder allows to create instances of QualifiedName in a slightly more efficient way by pre-allocating the underlying data for a known length.
-
Field Summary
Fields Modifier and Type Field Description static QualifiedName
EMPTY
The single existing empty QualifiedName.
-
Constructor Summary
Constructors Modifier Constructor Description protected
QualifiedName(java.lang.String... segments)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description QualifiedName
append(java.lang.String segment)
QualifiedName
append(QualifiedName relativeQualifiedName)
int
compareTo(QualifiedName qualifiedName)
protected int
compareTo(QualifiedName qualifiedName, boolean ignoreCase)
int
compareToIgnoreCase(QualifiedName qualifiedName)
static QualifiedName
create(java.lang.String singleSegment)
Low-level factory method.static QualifiedName
create(java.lang.String... segments)
Low-level factory method.static QualifiedName
create(java.util.List<java.lang.String> segments)
Low-level factory method.static QualifiedName
createFromStream(org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.EObjectInputStream eObjectInputStream)
Internal low level factory method.boolean
equals(java.lang.Object obj)
boolean
equalsIgnoreCase(java.lang.Object obj)
java.lang.String
getFirstSegment()
java.lang.String
getLastSegment()
java.lang.String
getSegment(int index)
int
getSegmentCount()
java.util.List<java.lang.String>
getSegments()
int
hashCode()
boolean
isEmpty()
QualifiedName
skipFirst(int skipCount)
QualifiedName
skipLast(int skipCount)
boolean
startsWith(QualifiedName prefix)
protected boolean
startsWith(QualifiedName prefix, boolean ignoreCase)
boolean
startsWithIgnoreCase(QualifiedName prefix)
QualifiedName
toLowerCase()
java.lang.String
toString()
Returns a canonical String representation of this using '.' as namespace delimiter.java.lang.String
toString(java.lang.String delimiter)
Returns a String representation of this usingdelimiter
as namespace delimiter.QualifiedName
toUpperCase()
static <F> com.google.common.base.Function<F,QualifiedName>
wrapper(com.google.common.base.Function<F,java.lang.String> nameFunction)
Wraps a name function to return a qualified name.void
writeToStream(org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.EObjectOutputStream eObjectOutputStream)
Internal low level serialization of QualifiedNames.
-
-
-
Field Detail
-
EMPTY
public static final QualifiedName EMPTY
The single existing empty QualifiedName.
-
-
Method Detail
-
create
public static QualifiedName create(java.lang.String... segments)
Low-level factory method. Consider using aIQualifiedNameConverter
instead.- Parameters:
segments
- the segments of the to-be-created qualified name. May benull
, but may not containnull
entries.- Returns:
- a
QualifiedName
. Nevernull
. - Throws:
java.lang.IllegalArgumentException
- if any of the segments is null
-
createFromStream
public static QualifiedName createFromStream(org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.EObjectInputStream eObjectInputStream) throws java.io.IOException
Internal low level factory method.- Throws:
java.io.IOException
- Since:
- 2.4
- Noreference:
- This method is not intended to be referenced by clients.
-
writeToStream
public void writeToStream(org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.EObjectOutputStream eObjectOutputStream) throws java.io.IOException
Internal low level serialization of QualifiedNames.- Throws:
java.io.IOException
- Since:
- 2.4
-
create
public static QualifiedName create(java.util.List<java.lang.String> segments)
Low-level factory method. Consider using aIQualifiedNameConverter
instead.- Parameters:
segments
- the segments of the to-be-created qualified name. May benull
, but may not containnull
entries.- Returns:
- a
QualifiedName
. Nevernull
. - Throws:
java.lang.IllegalArgumentException
- if any of the segments is null- Since:
- 2.3
-
create
public static QualifiedName create(java.lang.String singleSegment)
Low-level factory method. Consider using aIQualifiedNameConverter
instead.- Parameters:
singleSegment
- the single segment of the newly created qualified name- Throws:
java.lang.IllegalArgumentException
- if the singleSegment is null- Since:
- 2.3
-
wrapper
public static <F> com.google.common.base.Function<F,QualifiedName> wrapper(com.google.common.base.Function<F,java.lang.String> nameFunction)
Wraps a name function to return a qualified name. Returns null if the name function returns null.
-
isEmpty
public boolean isEmpty()
-
getSegments
public java.util.List<java.lang.String> getSegments()
-
getSegmentCount
public int getSegmentCount()
-
getSegment
public java.lang.String getSegment(int index)
-
getLastSegment
public java.lang.String getLastSegment()
-
getFirstSegment
public java.lang.String getFirstSegment()
-
append
public QualifiedName append(java.lang.String segment)
-
append
public QualifiedName append(QualifiedName relativeQualifiedName)
-
skipFirst
public QualifiedName skipFirst(int skipCount)
-
skipLast
public QualifiedName skipLast(int skipCount)
-
toLowerCase
public QualifiedName toLowerCase()
-
toUpperCase
public QualifiedName toUpperCase()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
equalsIgnoreCase
public boolean equalsIgnoreCase(java.lang.Object obj)
-
compareTo
public int compareTo(QualifiedName qualifiedName)
- Specified by:
compareTo
in interfacejava.lang.Comparable<QualifiedName>
-
compareToIgnoreCase
public int compareToIgnoreCase(QualifiedName qualifiedName)
-
compareTo
protected int compareTo(QualifiedName qualifiedName, boolean ignoreCase)
-
startsWith
public boolean startsWith(QualifiedName prefix)
-
startsWithIgnoreCase
public boolean startsWithIgnoreCase(QualifiedName prefix)
-
startsWith
protected boolean startsWith(QualifiedName prefix, boolean ignoreCase)
-
toString
public java.lang.String toString()
Returns a canonical String representation of this using '.' as namespace delimiter. For language specific conversion taking the concrete syntax into account seeIQualifiedNameConverter.toString(QualifiedName)
.- Overrides:
toString
in classjava.lang.Object
-
toString
public java.lang.String toString(java.lang.String delimiter)
Returns a String representation of this usingdelimiter
as namespace delimiter.- Parameters:
delimiter
- the delimiter to use.null
will be represented as the String "null
".- Returns:
- the concatenated segments joined with the given
delimiter
- Since:
- 2.3
-
-