net.sf.xslthl.highlighters
Class NumberHighlighter

java.lang.Object
  extended by net.sf.xslthl.Highlighter
      extended by net.sf.xslthl.highlighters.NumberHighlighter
Direct Known Subclasses:
HexaDecimalHighlighter

public class NumberHighlighter
extends Highlighter

Recognizes numbers. Accepted parameters:

point
character used for the decimal point. If not declared no decimal points are accepted.
thousands
thousand separator
exponent
the string used for recognizing the exponent part of a floating point
pointStarts
a switch, when set the value defined as point can also be used to start a number. For example ".1234" would also be accepted as a number.
prefix
required start of a number, can be useful in the hexnumber highlighter to define how a hexadecimal number is started
suffix
an optional string that can be found after a number, can be define multiple times. This is often used to set the "size" of a integer or floating point.
ignoreCase
all strings parameters are case insensitive
letterNoFollow
If set, numbers may not contain a letter at the end. For example: 123kg will not be seen as a number. This was the default before version 2.1


Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.xslthl.Highlighter
Highlighter.IgnoreCaseComparator
 
Field Summary
protected  String decimalPoint
          The decimal point
protected  String exponent
          The character to use to start the exponent
protected  boolean ignoreCase
          Ignore case when looking for exponent and flags
protected  boolean letterNoFollow
           
protected  boolean pointStarts
          If true a number can start with the decimal point
protected  String prefix
          Required prefix
protected  List<String> suffix
          Opional suffixes
protected  String thousandSep
          Thousand seperator
 
Fields inherited from class net.sf.xslthl.Highlighter
styleName, XMLname
 
Constructor Summary
NumberHighlighter()
           
 
Method Summary
 String getDefaultStyle()
          The default style name
 boolean highlight(CharIter in, List<Block> out)
          Perform highlighting on the current token stream.
 void init(Params params)
          Initializer
protected  boolean isDigit(char ch)
          Return true if it is an ascii digit
 boolean startsWith(CharIter in)
          return true if the current character is a possible match for this highlighter
 
Methods inherited from class net.sf.xslthl.Highlighter
isNewLine, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

decimalPoint

protected String decimalPoint
The decimal point


thousandSep

protected String thousandSep
Thousand seperator


exponent

protected String exponent
The character to use to start the exponent


suffix

protected List<String> suffix
Opional suffixes


prefix

protected String prefix
Required prefix


ignoreCase

protected boolean ignoreCase
Ignore case when looking for exponent and flags


pointStarts

protected boolean pointStarts
If true a number can start with the decimal point


letterNoFollow

protected boolean letterNoFollow
Constructor Detail

NumberHighlighter

public NumberHighlighter()
Method Detail

init

public void init(Params params)
          throws HighlighterConfigurationException
Description copied from class: Highlighter
Initializer

Overrides:
init in class Highlighter
Throws:
HighlighterConfigurationException

isDigit

protected boolean isDigit(char ch)
Return true if it is an ascii digit

Parameters:
ch -
Returns:

getDefaultStyle

public String getDefaultStyle()
Description copied from class: Highlighter
The default style name

Specified by:
getDefaultStyle in class Highlighter
Returns:

startsWith

public boolean startsWith(CharIter in)
Description copied from class: Highlighter
return true if the current character is a possible match for this highlighter

Overrides:
startsWith in class Highlighter
Returns:

highlight

public boolean highlight(CharIter in,
                         List<Block> out)
Description copied from class: Highlighter
Perform highlighting on the current token stream. Return true when highlighting was performed, or false in case of a false positive.

Specified by:
highlight in class Highlighter
Returns:


Copyright © 2005-2014. All Rights Reserved.