Class TermAtomic

This class can also be used to wrap strings, numbers and references. The constructor takes an unwrapped atomic and gives a wrapped atomic. There are two advantages of wrapped atomics. Firstly they fit into the Term class hierarchy. Secondly wrapped strings can carry call-site information and the polymorphic cache.

This class also provides access, guard, normalization and widening for the Prolog number data type. The Java to Prolog API does not provide specific data types for the number data type. Instead directly the various types in the hierarchy of the Java Number class are used.

The Prolog integer data type is represented either as a Java Integer class or as a Java BigInteger class. The methods normBigInteger() allow normalizing into a Prolog integer data type. The method widenBigInteger() allows widening into the Java BigInteger class.

The Prolog float data type is represented either as a Java Float class or as a Java Double class. The methods guardFloat() and guardDouble() checks whether the argument is positive or negative zero, and sanitizes the argument. The methods makeFloat() and makeDouble() additional allocate a new Float respectively Double object for Prolog use.

The Prolog decimal data type is represented either as a Java Long class or as a Java BigDecimal class. The methods scale() and unscaledValue() allow accessing the components of a Prolog decimal data type. The methods normBigDecimal() allow normalizing into a Prolog decimal data type. The method widenBigDecimal() allows widening into the Java BigDecimal class.

package jekpro.tools.term;

public final class TermAtomic extends AbstractTerm {
public TermAtom(Object s);
public Object getValue();

public int hashCode();
public boolean equals(Object o);

public static Number normBigInteger(long val);
public static Number normBigInteger(BigInteger i);
public static BigInteger widenBigInteger(Number m);

public static Float makeFloat(Float f)
throws ArithmeticException;
public static boolean guardFloat(float f)
throws ArithmeticException;
public static Double makeDouble(Double d)
throws
ArithmeticException;
public static boolean guardDouble(double d)
throws ArithmeticException;

public static int scale(Number n);
public static BigInteger unscaledValue(Number n);
public static Number normBigDecimal(BigDecimal d);
public static Number normBigDecimal(long m, int s);
public static Number normBigDecimal(BigInteger m, int s);
public static BigDecimal widenBigDecimal(Number m);
}

Kommentare