public class CSSToken
extends org.antlr.v4.runtime.CommonToken
| Modifier and Type | Class and Description |
|---|---|
static class |
CSSToken.TypeMapper
Convert between type values defined in two classes.
|
| Modifier and Type | Field and Description |
|---|---|
protected URL |
base
Base URL for URIs
|
static int |
CLASSKEYWORD |
static int |
FUNCTION |
static int |
HASH |
protected CSSLexerState |
ls
Current lexer state
|
static int |
STRING |
static int |
UNCLOSED_STRING |
static int |
UNCLOSED_URI |
static int |
URI |
protected boolean |
valid |
| Constructor and Description |
|---|
CSSToken(int type,
CSSLexerState state,
CSSToken.TypeMapper typeMapper)
Creates CSSToken of given type with cloning lexer state
automatically
|
CSSToken(int type,
CSSLexerState state,
int start,
int stop,
CSSToken.TypeMapper typeMapper)
Creates CSSToken of given type with cloning lexer state
automatically, allows to set text boundaries in input stream
|
CSSToken(org.antlr.v4.runtime.misc.Pair<org.antlr.v4.runtime.TokenSource,org.antlr.v4.runtime.CharStream> input,
int type,
int channel,
int start,
int stop,
CSSToken.TypeMapper typeMapper)
Creates CSSToken, this is base
emit() constructor |
| Modifier and Type | Method and Description |
|---|---|
static CSSToken.TypeMapper |
createDefaultTypeMapper(Class<? extends org.antlr.v4.runtime.Lexer> lexerClass) |
static String |
extractCLASSKEYWORD(String className)
Considers text as content of CLASSKEYWORD token,
and models view at this text as an common string,
that is removed
'.' from the beginning of string |
static String |
extractFUNCTION(String function)
Considers text as content of FUNCTION token,
and models view at this text as an common string,
that is removed
'(' from the end of string |
static String |
extractHASH(String hash)
Considers text as content of HASH token,
and models view at this text as an common string,
that is removed
'#' from the beginning of string |
static String |
extractCHARSET(String charset)
extract charset value from CHARSET token
|
static String |
extractSTRING(String string)
Considers text as content of STRING token,
and models view at this text as an common string,
that is one character removed from the both beginning
and the end.
|
static String |
extractUNCLOSEDSTRING(String string) |
static String |
extractUNCLOSEDURI(String uri) |
static String |
extractURI(String uri)
Considers text as content of URI token,
and models view at this text as an common string,
that is removed
'url(' from the beginning
and ')' from the and. |
URL |
getBase()
Obtains the base URL used for the relative URIs
|
CSSLexerState |
getLexerState()
Gets lexer state at creation of token
|
String |
getText()
Returns common text stored in token.
|
boolean |
isValid() |
void |
setBase(URL base)
Sets the base URL used for the relative URIs
|
CSSToken |
setLexerState(CSSLexerState state)
Sets lexer state for current token
|
void |
setValid(boolean valid) |
String |
toString() |
protected CSSLexerState ls
protected URL base
protected boolean valid
public static final int FUNCTION
public static final int URI
public static final int STRING
public static final int CLASSKEYWORD
public static final int HASH
public static final int UNCLOSED_STRING
public static final int UNCLOSED_URI
public CSSToken(org.antlr.v4.runtime.misc.Pair<org.antlr.v4.runtime.TokenSource,org.antlr.v4.runtime.CharStream> input,
int type,
int channel,
int start,
int stop,
CSSToken.TypeMapper typeMapper)
emit() constructorinput - Input streamtype - Type of tokenchannel - Channel of tokenstart - Start position in streamstop - End position in streampublic CSSToken(int type,
CSSLexerState state,
CSSToken.TypeMapper typeMapper)
type - Type of tokenstate - State of lexer, which will be copiedpublic CSSToken(int type,
CSSLexerState state,
int start,
int stop,
CSSToken.TypeMapper typeMapper)
type - Type of tokenstate - State of lexer, which will be copiedstart - Start position in streamstop - End position in streampublic CSSToken setLexerState(CSSLexerState state)
state - Current lexer statepublic CSSLexerState getLexerState()
public URL getBase()
public void setBase(URL base)
base - the base URL to setpublic boolean isValid()
public void setValid(boolean valid)
public static String extractSTRING(String string)
string - Content of STRING tokenpublic static String extractURI(String uri)
'url(' from the beginning
and ')' from the and. If result of this operation
is STRING, remove even quotation marksuri - Content of URI tokenpublic static String extractFUNCTION(String function)
'(' from the end of stringfunction - Content of FUNCTION tokenpublic static String extractHASH(String hash)
'#' from the beginning of stringhash - Content of HASH tokenpublic static String extractCLASSKEYWORD(String className)
'.' from the beginning of stringclassName - Content of CLASSKEYWORD tokenpublic String getText()
getText in interface org.antlr.v4.runtime.TokengetText in class org.antlr.v4.runtime.CommonTokenpublic String toString()
toString in class org.antlr.v4.runtime.CommonTokenpublic static CSSToken.TypeMapper createDefaultTypeMapper(Class<? extends org.antlr.v4.runtime.Lexer> lexerClass)
Copyright © 2018. All rights reserved.