net.sf.mmm.util.scanner.base
Class AbstractCharScannerSyntax

java.lang.Object
  extended by net.sf.mmm.util.scanner.base.AbstractCharScannerSyntax
All Implemented Interfaces:
CharScannerSyntax
Direct Known Subclasses:
SimpleCharScannerSyntax

public abstract class AbstractCharScannerSyntax
extends Object
implements CharScannerSyntax

This is the abstract base implementation of the CharScannerSyntax interface.
The actual chars like escape are realized as simple bean-properties and initialized with '\0' so they are disabled by default.

Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
See Also:
CharStreamScanner.readUntil(char, boolean, CharScannerSyntax)

Field Summary
private  char altQuoteEnd
           
private  char altQuoteEscape
           
private  boolean altQuoteEscapeLazy
           
private  char altQuoteStart
           
private  char entityEnd
           
private  char entityStart
           
private  char escape
           
private  char quoteEnd
           
private  char quoteEscape
           
private  boolean quoteEscapeLazy
           
private  char quoteStart
           
 
Constructor Summary
AbstractCharScannerSyntax()
          The constructor.
 
Method Summary
 char getAltQuoteEnd()
          This method gets the alternative character used to end a quotation.
 char getAltQuoteEscape()
          This method gets the character used to escape the alt-quote-end character within an quotation opened by alt-quote-start.
 char getAltQuoteStart()
          This method gets the alternative character used to start a quotation that should be terminated by a alt-quote-end character.
 char getEntityEnd()
          This method gets the character used to end an entity.
 char getEntityStart()
          This method gets the character used to start an entity.
 char getEscape()
          This method gets the character used as escape.
 char getQuoteEnd()
          This method gets the character used to end a quotation.
 char getQuoteEscape()
          This method gets the character used to escape the quote-end character within a quotation.
 char getQuoteStart()
          This method gets the character used to start a quotation that should be terminated by a quote-end character.
 boolean isAltQuoteEscapeLazy()
          If alt-quote-start, alt-quote-end and alt-quote-escape all point to the same character (which is NOT '\0'), then this method determines if alt-quotation escaping is lazy.
 boolean isQuoteEscapeLazy()
          If quote-start, quote-end and quote-escape all point to the same character (which is NOT '\0'), then this method determines if quotation escaping is lazy.
 String resolveEntity(String entity)
          This method resolves the given entity.
 void setAltQuote(char altQuote)
          This method sets both the alt-quote-start and alt-quote-end character.
 void setAltQuoteEnd(char alternativeQuoteEnd)
          This method sets the alt-quote-end character.
 void setAltQuoteEscape(char altQuoteEscape)
           
 void setAltQuoteEscapeLazy(boolean altQuoteEscapeLazy)
           
 void setAltQuoteStart(char alternativeQuoteStart)
           
 void setEntityEnd(char entityEnd)
           
 void setEntityStart(char entityStart)
           
 void setEscape(char escape)
           
 void setQuote(char quote)
          This method sets both the quote-start and quote-end character.
 void setQuoteEnd(char quoteEnd)
           
 void setQuoteEscape(char quoteEscape)
           
 void setQuoteEscapeLazy(boolean quoteEscapeLazy)
           
 void setQuoteStart(char quoteStart)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

escape

private char escape
See Also:
getEscape()

quoteStart

private char quoteStart
See Also:
getQuoteStart()

quoteEnd

private char quoteEnd
See Also:
getQuoteEnd()

quoteEscape

private char quoteEscape
See Also:
getQuoteEscape()

quoteEscapeLazy

private boolean quoteEscapeLazy
See Also:
isQuoteEscapeLazy()

altQuoteStart

private char altQuoteStart
See Also:
getAltQuoteStart()

altQuoteEnd

private char altQuoteEnd
See Also:
getAltQuoteEnd()

altQuoteEscape

private char altQuoteEscape
See Also:
getAltQuoteEscape()

altQuoteEscapeLazy

private boolean altQuoteEscapeLazy
See Also:
isAltQuoteEscapeLazy()

entityStart

private char entityStart
See Also:
getEntityStart()

entityEnd

private char entityEnd
See Also:
getEntityEnd()
Constructor Detail

AbstractCharScannerSyntax

public AbstractCharScannerSyntax()
The constructor.

Method Detail

getEscape

public char getEscape()
This method gets the character used as escape. The escape itself is omitted in the decoded output while the next character is taken as is without any special interpretation. This allows to encode special characters like a stop-character, quote-start, alt-quote-start, as well as the escape itself.
A very common example for an escape character is the backslash ( \).
Here are some examples:
escape input output
\ a\b\\c ab\c
~ a~b~~~c ab~c

ATTENTION:
The escape is disabled within quotations.

Specified by:
getEscape in interface CharScannerSyntax
Returns:
the escape character or 0 ('\0') for no escaping.
See Also:
CharScannerSyntax.getEntityStart()

setEscape

public void setEscape(char escape)
Parameters:
escape - is the escape character to set.

getQuoteStart

public char getQuoteStart()
This method gets the character used to start a quotation that should be terminated by a quote-end character. The text inside the quote is taken as is (without the quote characters).
Common examples for quote characters are the single quotes (') and double quotes (").

Specified by:
getQuoteStart in interface CharScannerSyntax
Returns:
the character used to start a quotation or 0 ( '\0') to disable.

setQuoteStart

public void setQuoteStart(char quoteStart)
Parameters:
quoteStart - is the quote-start character to set.

getQuoteEnd

public char getQuoteEnd()
This method gets the character used to end a quotation.

Specified by:
getQuoteEnd in interface CharScannerSyntax
Returns:
the character used to end a quotation.
See Also:
CharScannerSyntax.getQuoteStart()

setQuoteEnd

public void setQuoteEnd(char quoteEnd)
Parameters:
quoteEnd - is the quote-end character to set.

setQuote

public void setQuote(char quote)
This method sets both the quote-start and quote-end character.

Parameters:
quote - the quote character to set.

getQuoteEscape

public char getQuoteEscape()
This method gets the character used to escape the quote-end character within a quotation. This may be the quote-end itself so a duplicate quote-end represents a single occurrence of that character within a quotation. Otherwise the escape may be any other character.
Please note that this escaping is only active within a quotation opened by quote-start and only escapes the quote-end character and nothing else so in any other case the quote-escape is treated as a regular character.
quote-start quote-end quote-escape input output
' ' ' a'bc'd abcd
' ' ' a'b''c'd ab'cd
' ' \ a'b\c\'d\\'e'f ab\c'd\'ef

Specified by:
getQuoteEscape in interface CharScannerSyntax
Returns:
the character used to escape the quote-end character or 0 ('\0') to disable.

setQuoteEscape

public void setQuoteEscape(char quoteEscape)
Parameters:
quoteEscape - is the quote-escape to set.

isQuoteEscapeLazy

public boolean isQuoteEscapeLazy()
If quote-start, quote-end and quote-escape all point to the same character (which is NOT '\0'), then this method determines if quotation escaping is lazy. This means that outside a quotation a double occurrence of the quote character is NOT treated as quotation but as escaped quote character. Otherwise if NOT lazy, the double quote character is treated as quotation representing the empty sequence.
Here are some examples:
quote-start quote-end quote-escape quote-escape-lazy input output
' ' ' true '' '
' ' ' false ''  
' ' ' true '''' ''
' ' ' false '''' '
' ' ' true '''a' 'a
' ' ' false '''a' 'a

Please note that for '''a' the complete sequence is treated as quote if quote-escape-lazy is false and otherwise just the trailing 'a'.

Specified by:
isQuoteEscapeLazy in interface CharScannerSyntax
Returns:
true if quote-escaping is lazy, false otherwise.

setQuoteEscapeLazy

public void setQuoteEscapeLazy(boolean quoteEscapeLazy)
Parameters:
quoteEscapeLazy - the quote-escape-lazy flag to set

getAltQuoteStart

public char getAltQuoteStart()
This method gets the alternative character used to start a quotation that should be terminated by a alt-quote-end character. The text inside the quote is taken as is (without the quote characters).

Specified by:
getAltQuoteStart in interface CharScannerSyntax
Returns:
the alternative character used to start a quotation or 0 ('\0') for no quotation.
See Also:
getQuoteStart()

setAltQuoteStart

public void setAltQuoteStart(char alternativeQuoteStart)
Parameters:
alternativeQuoteStart - is the alt-quote-start character to set.

getAltQuoteEnd

public char getAltQuoteEnd()
This method gets the alternative character used to end a quotation.

Specified by:
getAltQuoteEnd in interface CharScannerSyntax
Returns:
the alternative character used to end a quotation.
See Also:
getAltQuoteStart()

setAltQuoteEnd

public void setAltQuoteEnd(char alternativeQuoteEnd)
This method sets the alt-quote-end character.

Parameters:
alternativeQuoteEnd - is the alt-quote-end character.

setAltQuote

public void setAltQuote(char altQuote)
This method sets both the alt-quote-start and alt-quote-end character.

Parameters:
altQuote - the alt-quote character to set.

getAltQuoteEscape

public char getAltQuoteEscape()
This method gets the character used to escape the alt-quote-end character within an quotation opened by alt-quote-start.

Specified by:
getAltQuoteEscape in interface CharScannerSyntax
Returns:
the character used to escape the quote-end character or 0 ('\0') to disable.
See Also:
CharScannerSyntax.getQuoteEscape()

setAltQuoteEscape

public void setAltQuoteEscape(char altQuoteEscape)
Parameters:
altQuoteEscape - is the alt-quote-escape to set.

isAltQuoteEscapeLazy

public boolean isAltQuoteEscapeLazy()
If alt-quote-start, alt-quote-end and alt-quote-escape all point to the same character (which is NOT '\0'), then this method determines if alt-quotation escaping is lazy.

Specified by:
isAltQuoteEscapeLazy in interface CharScannerSyntax
Returns:
true if alt-quote-escaping is lazy, false otherwise.
See Also:
CharScannerSyntax.isQuoteEscapeLazy()

setAltQuoteEscapeLazy

public void setAltQuoteEscapeLazy(boolean altQuoteEscapeLazy)
Parameters:
altQuoteEscapeLazy - the alt-quote-lazy flag to set

getEntityStart

public char getEntityStart()
This method gets the character used to start an entity. An entity is a specific encoded string surrounded with entity-start and entity-end. It will be decoded by CharScannerSyntax.resolveEntity(String).

Specified by:
getEntityStart in interface CharScannerSyntax
Returns:
the character used to start an entity or 0 ( '\0') to disable.

setEntityStart

public void setEntityStart(char entityStart)
Parameters:
entityStart - the entity-start to set.

getEntityEnd

public char getEntityEnd()
This method gets the character used to end an entity.

Specified by:
getEntityEnd in interface CharScannerSyntax
Returns:
the character used to end an entity.
See Also:
CharScannerSyntax.getEntityStart()

setEntityEnd

public void setEntityEnd(char entityEnd)
Parameters:
entityEnd - the entity-end to set.

resolveEntity

public String resolveEntity(String entity)
This method resolves the given entity.
E.g. if entity-start is '&' and CharScannerSyntax.getEntityEnd() is ';' then if the string "<" is scanned, this method is called with "lt" as entity argument and may return "<". ATTENTION:
You need to override this method if you want to use entities.

Specified by:
resolveEntity in interface CharScannerSyntax
Parameters:
entity - is the entity string that was found surrounded by entity-start and entity-end excluding these characters.
Returns:
the decoded entity.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.