java.lang.Object
io.github.mmm.scanner.CharScannerSyntaxBean
- All Implemented Interfaces:
CharScannerSyntax
This is the implementation of
The actual
CharScannerSyntax as Java bean. The actual
chars like escape are realized as simple bean-properties and initialized with
'\0' so they are disabled by default.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintThis method gets the alternative character used to end a quotation.intThis method gets the character used to escape thealt-quote-endcharacter within an quotation opened byalt-quote-start.intThis method gets the alternative character used to start a quotation that should be terminated by aalt-quote-endcharacter.intThis method gets the character used to end an entity.intThis method gets the character used to start an entity.intThis method gets the character used as escape.intThis method gets the character used to end a quotation.intThis method gets the character used to escape thequote-endcharacter within a quotation.intThis method gets the character used to start a quotation that should be terminated by aquote-endcharacter.booleanIfalt-quote-start,alt-quote-endandalt-quote-escapeall point to the same character (which is NOT'\0'), then this method determines ifalt-quotation escapingis lazy.booleanIfquote-start,quote-endandquote-escapeall point to the same character (which is NOT'\0'), then this method determines ifquotation escapingis lazy.resolveEntity(String entity) This method resolves the givenentity.voidsetAltQuote(int altQuote) This method sets both thealt-quote-startandalt-quote-endcharacter.voidsetAltQuoteEnd(int alternativeQuoteEnd) This method sets thealt-quote-endcharacter.voidsetAltQuoteEscape(int altQuoteEscape) voidsetAltQuoteEscapeLazy(boolean altQuoteEscapeLazy) voidsetAltQuoteStart(int alternativeQuoteStart) voidsetEntityEnd(int entityEnd) voidsetEntityStart(int entityStart) voidsetEscape(int escape) voidsetQuote(int quote) This method sets both thequote-startandquote-endcharacter.voidsetQuoteEnd(int quoteEnd) voidsetQuoteEscape(int quoteEscape) voidsetQuoteEscapeLazy(boolean quoteEscapeLazy) voidsetQuoteStart(int quoteStart)
-
Constructor Details
-
CharScannerSyntaxBean
public CharScannerSyntaxBean()The constructor.
-
-
Method Details
-
getEscape
public int getEscape()Description copied from interface:CharScannerSyntaxThis method gets the character used as escape. It is used to mark special characters likeCharScannerSyntax.getQuoteStart()to allow these characters also in the payload. The escape itself is removed on decoding while the next character is taken as is without any special interpretation.
The most common escape character is the backslash (\).
Here are some examples for decoding:
This allows to encode special characters like aescapeinput output \ a\b\\c ab\c ~ a~b~~~c ab~c stop-character,quote-start,alt-quote-start, as well as theescapeitself.
ATTENTION:
Theescapeis disabled withinquotations.- Specified by:
getEscapein interfaceCharScannerSyntax- Returns:
- the escape character or
'\0'for no escaping. - See Also:
-
setEscape
public void setEscape(int escape) - Parameters:
escape- is theescapeto set.
-
getQuoteStart
public int getQuoteStart()Description copied from interface:CharScannerSyntaxThis method gets the character used to start a quotation that should be terminated by aquote-endcharacter. 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:
getQuoteStartin interfaceCharScannerSyntax- Returns:
- the character used to start a quotation or
'\0'to disable.
-
setQuoteStart
public void setQuoteStart(int quoteStart) - Parameters:
quoteStart- is thequoteStartto set.
-
getQuoteEnd
public int getQuoteEnd()Description copied from interface:CharScannerSyntaxThis method gets the character used to end a quotation.- Specified by:
getQuoteEndin interfaceCharScannerSyntax- Returns:
- the character used to end a quotation or
'\0'to disable. - See Also:
-
setQuoteEnd
public void setQuoteEnd(int quoteEnd) - Parameters:
quoteEnd- is thequoteEndto set.
-
setQuote
public void setQuote(int quote) This method sets both thequote-startandquote-endcharacter.- Parameters:
quote- the quote character to set.
-
getQuoteEscape
public int getQuoteEscape()Description copied from interface:CharScannerSyntaxThis method gets the character used to escape thequote-endcharacter within a quotation. This may be thequote-enditself so a duplicatequote-endrepresents 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 byquote-startand only escapes thequote-endcharacter and nothing else so in any other case thequote-escapeis treated as a regular character.
quote-startquote-endquote-escapeinput output ' ' ' a'bc'd abcd ' ' ' a'b''c'd ab'cd ' ' \ a'b\c\'d\\'e'f ab\c'd\'ef - Specified by:
getQuoteEscapein interfaceCharScannerSyntax- Returns:
- the character used to escape the
quote-endcharacter or'\0'to disable.
-
setQuoteEscape
public void setQuoteEscape(int quoteEscape) - Parameters:
quoteEscape- is thequote-escapeto set.
-
isQuoteEscapeLazy
public boolean isQuoteEscapeLazy()Description copied from interface:CharScannerSyntaxIfquote-start,quote-endandquote-escapeall point to the same character (which is NOT'\0'), then this method determines ifquotation escapingis 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-startquote-endquote-escapequote-escape-lazyinput output ' ' ' true '' ' ' ' ' false '' ' ' ' true '''' '' ' ' ' false '''' ' ' ' ' true '''a' 'a ' ' ' false '''a' 'a
Please note that for'''a'the complete sequence is treated as quote ifquote-escape-lazyisfalseand otherwise just the trailing'a'.- Specified by:
isQuoteEscapeLazyin interfaceCharScannerSyntax- Returns:
trueif quote-escaping is lazy,falseotherwise.
-
setQuoteEscapeLazy
public void setQuoteEscapeLazy(boolean quoteEscapeLazy) - Parameters:
quoteEscapeLazy- thequote-escape-lazyflag to set
-
getAltQuoteStart
public int getAltQuoteStart()Description copied from interface:CharScannerSyntaxThis method gets the alternative character used to start a quotation that should be terminated by aalt-quote-endcharacter. The text inside the quote is taken as is (without the quote characters).- Specified by:
getAltQuoteStartin interfaceCharScannerSyntax- Returns:
- the alternative character used to start a quotation or
'\0'to disable. - See Also:
-
setAltQuoteStart
public void setAltQuoteStart(int alternativeQuoteStart) - Parameters:
alternativeQuoteStart- is thealt-quote-startcharacter to set.
-
getAltQuoteEnd
public int getAltQuoteEnd()Description copied from interface:CharScannerSyntaxThis method gets the alternative character used to end a quotation.- Specified by:
getAltQuoteEndin interfaceCharScannerSyntax- Returns:
- the alternative character used to end a quotation.
- See Also:
-
setAltQuoteEnd
public void setAltQuoteEnd(int alternativeQuoteEnd) This method sets thealt-quote-endcharacter.- Parameters:
alternativeQuoteEnd- is thealt-quote-endcharacter.
-
setAltQuote
public void setAltQuote(int altQuote) This method sets both thealt-quote-startandalt-quote-endcharacter.- Parameters:
altQuote- the alt-quote character to set.
-
getAltQuoteEscape
public int getAltQuoteEscape()Description copied from interface:CharScannerSyntaxThis method gets the character used to escape thealt-quote-endcharacter within an quotation opened byalt-quote-start.- Specified by:
getAltQuoteEscapein interfaceCharScannerSyntax- Returns:
- the character used to escape the
quote-endcharacter or'\0'to disable. - See Also:
-
setAltQuoteEscape
public void setAltQuoteEscape(int altQuoteEscape) - Parameters:
altQuoteEscape- is thealt-quote-escapeto set.
-
isAltQuoteEscapeLazy
public boolean isAltQuoteEscapeLazy()Description copied from interface:CharScannerSyntaxIfalt-quote-start,alt-quote-endandalt-quote-escapeall point to the same character (which is NOT'\0'), then this method determines ifalt-quotation escapingis lazy.- Specified by:
isAltQuoteEscapeLazyin interfaceCharScannerSyntax- Returns:
trueif alt-quote-escaping is lazy,falseotherwise.- See Also:
-
setAltQuoteEscapeLazy
public void setAltQuoteEscapeLazy(boolean altQuoteEscapeLazy) - Parameters:
altQuoteEscapeLazy- thealt-quote-lazyflag to set
-
getEntityStart
public int getEntityStart()Description copied from interface:CharScannerSyntaxThis method gets the character used to start an entity. An entity is a specific encoded string surrounded withentity-startandentity-end. It will be decoded byCharScannerSyntax.resolveEntity(String).- Specified by:
getEntityStartin interfaceCharScannerSyntax- Returns:
- the character used to start an entity or
'\0'to disable.
-
setEntityStart
public void setEntityStart(int entityStart) - Parameters:
entityStart- theentity-startto set.
-
getEntityEnd
public int getEntityEnd()Description copied from interface:CharScannerSyntaxThis method gets the character used to end an entity.- Specified by:
getEntityEndin interfaceCharScannerSyntax- Returns:
- the character used to end an entity.
- See Also:
-
setEntityEnd
public void setEntityEnd(int entityEnd) - Parameters:
entityEnd- theentity-endto set.
-
resolveEntity
This method resolves the givenentity.
E.g. ifentity-startis'&'andCharScannerSyntax.getEntityEnd()is';'then if the string"<"is scanned, this method is called with"lt"asentityargument and may return"<".
ATTENTION:
You need to override this method if you want touseentities.- Specified by:
resolveEntityin interfaceCharScannerSyntax- Parameters:
entity- is the entity string that was found surrounded byentity-startandentity-endexcluding these characters.- Returns:
- the decoded entity.
-