Class FormatNumber


public class FormatNumber extends Function
  • Constructor Details

    • FormatNumber

      public FormatNumber()
  • Method Details

    • getName

      public String getName()
      Description copied from class: Function
      Get the name of the function. This method must be implemented in all subclasses.
      Specified by:
      getName in class Function
      Returns:
      the name of the function, as used in XSL expressions, but excluding its namespace prefix
    • getDataType

      public int getDataType()
      Determine the data type of the exprEssion
      Specified by:
      getDataType in class Expression
      Returns:
      Value.STRING
    • simplify

      public Expression simplify() throws XPathException
      Simplify and validate
      Overrides:
      simplify in class Expression
      Returns:
      the simplified expression
      Throws:
      XPathException
    • evaluateAsString

      public String evaluateAsString(Context context) throws XPathException
      Evaluate in a context where a string is wanted
      Overrides:
      evaluateAsString in class Expression
      Parameters:
      context - The context in which the expression is to be evaluated
      Returns:
      the value of the expression, evaluated in the current context
      Throws:
      XPathException
    • evaluate

      public Value evaluate(Context c) throws XPathException
      Evaluate in a general context
      Specified by:
      evaluate in class Expression
      Parameters:
      c - The context in which the expression is to be evaluated
      Returns:
      the value of the expression, evaluated in the current context
      Throws:
      XPathException
    • formatNumber

      public String formatNumber(double n, String format, DecimalFormatSymbols dfs) throws XPathException
      Here is the method that does the work. It needs to be synchronized because it remembers information from one invocation to the next; it doesn't matter if these are in different threads but it can't be interrupted. The reason for remembering information is that getting a new DecimalFormatSymbols each time is incredibly expensive, especially with the Microsoft Java VM. Actually the synchronization is unnecessary if there is a bound Controller.
      Throws:
      XPathException
    • getDependencies

      public int getDependencies()
      Determine the dependencies
      Specified by:
      getDependencies in class Expression
    • reduce

      public Expression reduce(int dep, Context c) throws XPathException
      Reduce the dependencies
      Specified by:
      reduce in class Expression
      Parameters:
      dep - The dependencies to be removed, e.g. Context.VARIABLES
      c - The context to be used for the partial evaluation
      Returns:
      a new expression (or Value) that does not have any of the specified dependencies
      Throws:
      XPathException