asia.redact.bracket.properties
Class PropertiesLexer

java.lang.Object
  extended by asia.redact.bracket.properties.PropertiesLexer

public class PropertiesLexer
extends Object

 
 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.
 
 

Author:
Dave
See Also:
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

input

final String input

index

int index

list

final List<PropertiesToken> list

lock

private final Lock lock
Constructor Detail

PropertiesLexer

public PropertiesLexer(String input)
Convenience method, swallows the input whole This method filters for unicode escapes if the mode is Compatibility

Parameters:
in -

PropertiesLexer

public PropertiesLexer(Reader in)
Convenience method, swallows the input whole This method filters for unicode escapes if the mode is Compatibility

Parameters:
in -

PropertiesLexer

public 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

Parameters:
in -

PropertiesLexer

public PropertiesLexer(InputStream in)
Convenience method, swallows the input whole This method filters for unicode escapes if the mode is Compatibility

Parameters:
in -
Method Detail

lex

public void lex()

analyzeLine

private void analyzeLine(String buf,
                         PropertiesToken tok,
                         long count)

scanKeyValue

private void scanKeyValue(String buf,
                          PropertiesToken eol)

comment

private void comment(String buf)

scanLineBreak

private PropertiesToken scanLineBreak()

hasNext

private boolean hasNext()

next

private char next()

la

private Character la(int count)

getList

public List<PropertiesToken> getList()


Copyright © 2011-2013 David R. Smith. All Rights Reserved.