Class Formatter

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

public abstract class Formatter extends Object
Abstract class for formatting data in different languages.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte[]
    Default language: English.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract byte[]
    ampm(boolean am)
    Returns the am/pm marker.
    protected abstract byte[]
    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 Formatter
    get(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EN

      public static final byte[] EN
      Default language: English.
  • Constructor Details

    • Formatter

      public Formatter()
  • Method Details

    • get

      public static Formatter get(byte[] language)
      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 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[] language, byte[] picture, byte[] calendar, byte[] place, StaticContext sc, InputInfo ii) throws QueryException
      Formats the specified date.
      Parameters:
      date - date to be formatted
      language - language
      picture - picture
      calendar - calendar (can be null)
      place - place
      sc - static context
      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