org.basex.query.util.format
Class Formatter

java.lang.Object
  extended by org.basex.query.util.format.Formatter

public abstract class Formatter
extends java.lang.Object

Abstract class for formatting data in different languages.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Nested Class Summary
protected static class FormatUtil.Case
          Cases.
 
Constructor Summary
Formatter()
           
 
Method Summary
protected abstract  byte[] ampm(boolean am)
          Returns the am/pm marker.
protected abstract  byte[] calendar()
          Returns the calendar.
protected abstract  byte[] day(int n, int min, int max)
          Returns the specified day of the week (0-6, Sunday-Saturday).
protected abstract  byte[] era(long year)
          Returns the era.
 byte[] formatDate(ADate date, byte[] lng, byte[] pic, byte[] cal, byte[] plc, InputInfo ii)
          Formats the specified date.
 byte[] formatInt(long num, FormatParser fp)
          Returns a formatted integer.
 byte[] formatZone(int num, FormatParser fp, byte[] marker)
          Returns a formatted timezone.
static Formatter get(byte[] ln)
          Returns a formatter for the specified language.
protected abstract  byte[] month(int n, int min, int max)
          Returns the specified month (0-11).
protected abstract  byte[] ordinal(long n, byte[] ord)
          Returns an ordinal representation for the specified number.
protected abstract  byte[] word(long n, byte[] ord)
          Returns a word representation for the specified number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Formatter

public Formatter()
Method Detail

get

public static Formatter get(byte[] ln)
Returns a formatter for the specified language.

Parameters:
ln - language
Returns:
formatter instance

word

protected abstract byte[] word(long n,
                               byte[] ord)
Returns a word representation for the specified number.

Parameters:
n - number to be formatted
ord - ordinal suffix
Returns:
token

ordinal

protected abstract byte[] ordinal(long n,
                                  byte[] ord)
Returns an ordinal representation for the specified number.

Parameters:
n - number to be formatted
ord - ordinal suffix
Returns:
ordinal

month

protected abstract byte[] month(int n,
                                int min,
                                int max)
Returns the specified month (0-11).

Parameters:
n - number to be formatted
min - minimum length
max - maximum length
Returns:
month

day

protected abstract byte[] day(int n,
                              int min,
                              int max)
Returns the specified day of the week (0-6, Sunday-Saturday).

Parameters:
n - number to be formatted
min - minimum length
max - maximum length
Returns:
day of week

ampm

protected abstract byte[] ampm(boolean am)
Returns the am/pm marker.

Parameters:
am - am flag
Returns:
am/pm marker

calendar

protected abstract byte[] calendar()
Returns the calendar.

Returns:
calendar

era

protected abstract byte[] era(long year)
Returns the era.

Parameters:
year - year
Returns:
era

formatDate

public final byte[] formatDate(ADate date,
                               byte[] lng,
                               byte[] pic,
                               byte[] cal,
                               byte[] plc,
                               InputInfo ii)
                        throws QueryException
Formats the specified date.

Parameters:
date - date to be formatted
lng - language
pic - picture
cal - calendar
plc - place
ii - input info
Returns:
formatted string
Throws:
QueryException - query exception

formatInt

public final byte[] formatInt(long num,
                              FormatParser fp)
Returns a formatted integer.

Parameters:
num - integer to be formatted
fp - format parser
Returns:
string representation

formatZone

public final byte[] formatZone(int num,
                               FormatParser fp,
                               byte[] marker)
                        throws QueryException
Returns a formatted timezone.

Parameters:
num - integer to be formatted
fp - format parser
marker - marker
Returns:
string representation
Throws:
QueryException - query exception