uk.me.nxg.unity
Class FunctionDefinition

java.lang.Object
  extended by uk.me.nxg.unity.FunctionDefinition
All Implemented Interfaces:
Comparable

public class FunctionDefinition
extends Object
implements Comparable

Describes a function. Functions take a single unit as argument.

There are no syntax variations, beyond the set of functions which are recommended.


Method Summary
 int compareTo(Object o)
          Provides a sorting order for definitions.
 String description()
          A human-readable description of the function.
 boolean equals(Object o)
           
 String fallbackName()
          A fallback name for the function.
 int hashCode()
           
 String latexForm()
          A LaTeX form of the function name.
 String name()
          The name of this function, or null.
 String toString()
          Produces a representation of this function as a string.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

description

public String description()
A human-readable description of the function.


latexForm

public String latexForm()
A LaTeX form of the function name.


compareTo

public int compareTo(Object o)
Provides a sorting order for definitions. The order is well-defined but is not specified here.

Specified by:
compareTo in interface Comparable

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Produces a representation of this function as a string. This should not generally be used for formatting expressions: for that, use UnitExpr.toString().

Overrides:
toString in class Object

name

public String name()
The name of this function, or null. The response will be null if the function definition doesn't have enough syntax information to know what the function is called in a given syntax. The syntax in question is that associated with the function when it was parsed, which may not, of course, be the syntax associated with it when it is written.


fallbackName

public String fallbackName()
A fallback name for the function.

In fact, this is (a) only necessary for debugging purposes, because usually the overridden name() function will work, and (b) it is always (?) the same as the string eventually returned from name(), because (at present) all of the functions have the same short names in those syntaxes which know about them. This may be unnecessary generality (YAGNI, and all that), but it's essentially here for symmetry with the UnitDefinition lookup process, here and in ParseFunctions.java