|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectasia.redact.bracket.properties.PropertiesLexer
public class PropertiesLexer
Parse a properties file generally conformant to the description at http://download.oracle.com/javase/6/docs/api/java/util/Properties.html#load(java.io.Reader) into tokens. The lexer will be slightly more true to the data than java.util. For example, it will preserve whitespace as valid data, which java.util.Properties would silently strip off. The lexer will also happily consume UTF-8 (no need for unicode-style escapes). Use Mode.Compatibility for better compatibility to the java.util package and the "spec" above. There is one additional extension in the lexer: a comment line which starts with #;; is treated as transient (not read in as a comment or saved as a comment in the properties results). This can be used to generate a transient header and footer. As of version 1.3.2-SNAPSHOT and above, these lines are parsed as META_DATA tokens and are available in the parse phase. This class is an "off-line" (non-streaming) lexer, it is backed by a String as input, which implies it is limited by memory resources. That's not a problem for all but unusually large properties files on contemporary hardware.
PropertiesToken,
PropertiesTokenType,
InputAdapter| Field Summary | |
|---|---|
(package private) int |
index
|
(package private) String |
input
|
(package private) List<PropertiesToken> |
list
|
private Lock |
lock
|
| Constructor Summary | |
|---|---|
PropertiesLexer(File in,
Charset charset)
Convenience method, swallows the input whole This method filters for unicode escapes if the mode is Compatibility This method requires we specify the explicit charset of the file |
|
PropertiesLexer(InputStream in)
Convenience method, swallows the input whole This method filters for unicode escapes if the mode is Compatibility |
|
PropertiesLexer(Reader in)
Convenience method, swallows the input whole This method filters for unicode escapes if the mode is Compatibility |
|
PropertiesLexer(String input)
Convenience method, swallows the input whole This method filters for unicode escapes if the mode is Compatibility |
|
| Method Summary | |
|---|---|
private void |
analyzeLine(String buf,
PropertiesToken tok,
long count)
|
private void |
comment(String buf)
|
List<PropertiesToken> |
getList()
|
private boolean |
hasNext()
|
private Character |
la(int count)
|
void |
lex()
|
private char |
next()
|
private void |
scanKeyValue(String buf,
PropertiesToken eol)
|
private PropertiesToken |
scanLineBreak()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
final String input
int index
final List<PropertiesToken> list
private final Lock lock
| Constructor Detail |
|---|
public PropertiesLexer(String input)
in - public PropertiesLexer(Reader in)
in -
public PropertiesLexer(File in,
Charset charset)
in - public PropertiesLexer(InputStream in)
in - | Method Detail |
|---|
public void lex()
private void analyzeLine(String buf,
PropertiesToken tok,
long count)
private void scanKeyValue(String buf,
PropertiesToken eol)
private void comment(String buf)
private PropertiesToken scanLineBreak()
private boolean hasNext()
private char next()
private Character la(int count)
public List<PropertiesToken> getList()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||