Top Description Fields Constructors Methods
uk.ac.ed.ph.snuggletex

public Class DecimalFormatNumberMatcher

extends Object
implements NumberMatcher
Class Inheritance
All Implemented Interfaces
uk.ac.ed.ph.snuggletex.NumberMatcher
Imports
java.math.BigDecimal, java.text.DecimalFormat, .DecimalFormatSymbols, .ParsePosition, java.util.Locale

Implementation of NumberMatcher that uses a standard Java DecimalFormat to match numbers.

By default, this uses the default DecimalFormat with the platform default Locale.

You will probably want your DecimalFormat to have grouping turned off, otherwise something like 1,2 (in UK locale) would be parsed as a number 12.

Author
David McKain
Since
1.3.0
Version
$Revision$

Field Summary

Modifier and TypeField and Description
private DecimalFormat
private static final int

Constructor Summary

AccessConstructor and Description
public
public
public

Method Summary

Modifier and TypeMethod and Description
public DecimalFormat
public int
getNumberEnd(InputContext input, int startIndex)

Implements uk.ac.ed.ph.snuggletex.NumberMatcher.getNumberEnd.

Implementations should analyse the given InputContext starting at the given index to see if it looks like an (unsigned) number.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

decimalFormatback to summary
private DecimalFormat decimalFormat
READAHEAD_INCREMENTback to summary
private static final int READAHEAD_INCREMENT

Constructor Detail

DecimalFormatNumberMatcherback to summary
public DecimalFormatNumberMatcher()
DecimalFormatNumberMatcherback to summary
public DecimalFormatNumberMatcher(Locale locale)
DecimalFormatNumberMatcherback to summary
public DecimalFormatNumberMatcher(DecimalFormat decimalFormat)

Method Detail

getDecimalFormatback to summary
public DecimalFormat getDecimalFormat()
getNumberEndback to summary
public int getNumberEnd(InputContext input, int startIndex)

Implements uk.ac.ed.ph.snuggletex.NumberMatcher.getNumberEnd.

Doc from uk.ac.ed.ph.snuggletex.NumberMatcher.getNumberEnd.

Implementations should analyse the given InputContext starting at the given index to see if it looks like an (unsigned) number. If it is a number, return the index of the next non-number character. Otherwise, return -1.

setDecimalFormatback to summary
public void setDecimalFormat(DecimalFormat decimalFormat)