Package org.basex.query.util.format
Class Formatter
java.lang.Object
org.basex.query.util.format.Formatter
Abstract class for formatting data in different languages.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.final byte[]formatDate(ADate date, byte[] language, byte[] picture, byte[] calendar, byte[] place, StaticContext sc, InputInfo ii) Formats the specified date.final byte[]formatInt(long num, FormatParser fp) Returns a formatted integer.static Formatterget(byte[] language) 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.
-
Field Details
-
EN
public static final byte[] ENDefault language: English.
-
-
Constructor Details
-
Formatter
public Formatter()
-
-
Method Details
-
get
Returns a formatter for the specified language.- Parameters:
language- 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 formattedord- 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 formattedord- 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 formattedmin- minimum lengthmax- 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 formattedmin- minimum lengthmax- 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[] language, byte[] picture, byte[] calendar, byte[] place, StaticContext sc, InputInfo ii) throws QueryException Formats the specified date.- Parameters:
date- date to be formattedlanguage- languagepicture- picturecalendar- calendar (can benull)place- placesc- static contextii- input info- Returns:
- formatted string
- Throws:
QueryException- query exception
-
formatInt
Returns a formatted integer.- Parameters:
num- integer to be formattedfp- format parser- Returns:
- string representation
-