public final class LanguagePath extends Object
lp
would return the following:lp.size() == 3 lp.language(0) == JspTokenId.language() lp.language(1) == JavaTokenId.language() lp.language(2) == JavadocTokenId.language()
The two language paths for the same languages in the same order represent a single object. Therefore language paths can be compared by using == operator.
Lifetime: Once a particular language path is created it is held by a soft reference from its "parent" language path.
This class may safely be used by multiple threads.
Modifier and Type | Method and Description |
---|---|
LanguagePath |
embedded(Language<?> language)
Get embedded path of this language path.
|
LanguagePath |
embedded(LanguagePath suffix)
Get language path corresponding to the suffix language path embedded
in this path.
|
boolean |
endsWith(LanguagePath languagePath)
Check whether this language path ends with the given language path.
|
static LanguagePath |
get(Language<?> language)
Get language path that contains a single language.
|
static LanguagePath |
get(LanguagePath prefix,
Language<?> language)
Get language path corresponding to the language embedded in the given context
language path.
|
Language<?> |
innerLanguage()
Return the most inner language of this path.
|
Language<?> |
language(int index)
Get language of this language path at the given index.
|
String |
mimePath()
Gets the mime path equivalent of this language path.
|
LanguagePath |
parent()
Returns language path consisting of
<0, size() - 1>
languages (i.e. |
int |
size()
Get total number of languages in this language path.
|
LanguagePath |
subPath(int startIndex)
Gets the path starting at the given index and ending after
the last language contained in this path.
|
LanguagePath |
subPath(int startIndex,
int endIndex)
Gets the path starting at the given index and ending after
the last language contained in this path.
|
Language<?> |
topLanguage()
Return the top-level language of this language path.
|
String |
toString() |
public static LanguagePath get(Language<?> language)
language
- non-null language.public static LanguagePath get(LanguagePath prefix, Language<?> language)
LanguagePath.embedded(Language)
.
prefix
- prefix language path determining the context in which
the language is embedded or null if there is no prefix.language
- non-null language.public int size()
public Language<?> language(int index)
index
- >=0 && < LanguagePath.size()
.IndexOutOfBoundsException
- in case the index is not within
required bounds.public LanguagePath embedded(Language<?> language)
LanguagePath.get(LanguagePath,Language)
but this one is usually preferred as it supports more readable code.
language
- non-null language.public LanguagePath embedded(LanguagePath suffix)
suffix
- non-null suffix to be added to this path.public LanguagePath parent()
<0, size() - 1>
languages (i.e. the inner language is cut out).
LanguagePath.size()
== 1 then null
is returned.public Language<?> topLanguage()
language(0)
.LanguagePath.language(int)
public Language<?> innerLanguage()
language(size() - 1)
.LanguagePath.language(int)
public boolean endsWith(LanguagePath languagePath)
languagePath
- non-null language path to be checked.this
as well).public LanguagePath subPath(int startIndex)
LanguagePath.subPath(int, int)
public LanguagePath subPath(int startIndex, int endIndex)
startIndex
- >=0 starting index of the requested path in this path.endIndex
- >startIndex index after the last item
of the requested path.public String mimePath()
For example the language path of the java language embedded in the JSP language will return 'text/x-jsp/text/x-java' when this method is called.
The returned string path can be used in MimeLookup's operation
to obtain a corresponding MimePath object by using
MimePath.parse(returned-mime-path-string)
.
LanguageHierarchy.mimeType()