|
org.netbeans.modules.lexer/2 1.39.1 1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.api.lexer.LanguagePath
public final class LanguagePath
Language path describes a complete embedding
of the languages starting from the root (top-level) language
till the most embedded language.
Language path consists of one root language
and zero or more embedded languages.
E.g. for javadoc embedded in java that is embedded in jsp
then the language path 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.
Method Summary | |
---|---|
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()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static LanguagePath get(Language<?> language)
language
- non-null language.
public static LanguagePath get(LanguagePath prefix, Language<?> language)
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 && < size()
.
IndexOutOfBoundsException
- in case the index is not within
required bounds.public LanguagePath embedded(Language<?> language)
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).
If size()
== 1 then null
is returned.
public Language<?> topLanguage()
language(0)
.
language(int)
public Language<?> innerLanguage()
language(size() - 1)
.
language(int)
public boolean endsWith(LanguagePath languagePath)
languagePath
- non-null language path to be checked.
this
as well).public LanguagePath subPath(int startIndex)
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()
public String toString()
toString
in class Object
|
org.netbeans.modules.lexer/2 1.39.1 1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |