Package org.prolog4j.swi.impl
Class SWIPrologConversionPolicy
- java.lang.Object
-
- org.prolog4j.ConversionPolicy
-
- org.prolog4j.swi.impl.SWIPrologConversionPolicy
-
public class SWIPrologConversionPolicy extends ConversionPolicy
SWI-Prolog implementation of the conversion policy.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.prolog4j.ConversionPolicy
ConversionPolicy.TermPattern
-
-
Constructor Summary
Constructors Constructor Description SWIPrologConversionPolicy()Constructs a conversion policy for SWI-Prolog.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubledoubleValue(Object term)Converts a floating point term to a double value.ObjectgetArg(Object compound, int index)Returns an argument of a compound term.intgetArity(Object compound)Returns the arity of a compound term or atom.protected StringgetName(Object compound)Returns the functor of a compound term or the name of an atom.intintValue(Object term)Converts an integer term to an int value.booleanisAtom(Object term)Determines whether the Prolog term is an atom.booleanisCompound(Object term)Determines whether the Prolog term is compound.booleanisDouble(Object term)Determines whether the Prolog term is a double value.booleanisInteger(Object term)Determines whether the Prolog term is an integer value.booleanmatch(Object term1, Object term2)Decides whether two terms match or not.Objectterm(double value)Creates a real term according to the actual implementation.Objectterm(int value)Creates a integer term according to the actual implementation.Objectterm(String name)Creates an atom according to the actual implementation.Objectterm(String name, Object... args)Creates a compound term according to the actual implementation.-
Methods inherited from class org.prolog4j.ConversionPolicy
addListConverter, addObjectConverter, addTermConverter, addTermConverter, convertObject, convertTerm, convertTerm, tp
-
-
-
-
Method Detail
-
match
public boolean match(Object term1, Object term2)
Description copied from class:ConversionPolicyDecides whether two terms match or not. The comparison is similar toObject.equals(Object)apart of thatnullmatches any object.- Specified by:
matchin classConversionPolicy- Parameters:
term1- the first termterm2- the second object- Returns:
trueif the terms match, otherwisefalse
-
term
public Object term(int value)
Description copied from class:ConversionPolicyCreates a integer term according to the actual implementation.- Specified by:
termin classConversionPolicy- Parameters:
value- the integer value- Returns:
- the created Prolog integer term
-
term
public Object term(double value)
Description copied from class:ConversionPolicyCreates a real term according to the actual implementation.- Specified by:
termin classConversionPolicy- Parameters:
value- the double value- Returns:
- the created Prolog real term
-
term
public Object term(String name)
Description copied from class:ConversionPolicyCreates an atom according to the actual implementation.- Specified by:
termin classConversionPolicy- Parameters:
name- the name of the atom- Returns:
- the created atom
-
term
public Object term(String name, Object... args)
Description copied from class:ConversionPolicyCreates a compound term according to the actual implementation.- Specified by:
termin classConversionPolicy- Parameters:
name- the patternargs- the arguments of the pattern- Returns:
- the created term
-
intValue
public int intValue(Object term)
Description copied from class:ConversionPolicyConverts an integer term to an int value.- Specified by:
intValuein classConversionPolicy- Parameters:
term- a term representing an integer value- Returns:
- the int value of the term
-
doubleValue
public double doubleValue(Object term)
Description copied from class:ConversionPolicyConverts a floating point term to a double value.- Specified by:
doubleValuein classConversionPolicy- Parameters:
term- a term representing a floating point value- Returns:
- the double value of the term
-
getName
protected String getName(Object compound)
Description copied from class:ConversionPolicyReturns the functor of a compound term or the name of an atom.- Specified by:
getNamein classConversionPolicy- Parameters:
compound- the compound term or atom- Returns:
- the functor of the term
-
getArity
public int getArity(Object compound)
Description copied from class:ConversionPolicyReturns the arity of a compound term or atom. For atoms it returns zero.- Specified by:
getArityin classConversionPolicy- Parameters:
compound- the compound term or atom- Returns:
- the arity of the term
-
getArg
public Object getArg(Object compound, int index)
Description copied from class:ConversionPolicyReturns an argument of a compound term. The numbering starts from zero.- Specified by:
getArgin classConversionPolicy- Parameters:
compound- the compoundindex- the index of the argument (>= 0)- Returns:
- the argth argument of the compound
-
isAtom
public boolean isAtom(Object term)
Description copied from class:ConversionPolicyDetermines whether the Prolog term is an atom.- Specified by:
isAtomin classConversionPolicy- Parameters:
term- the term- Returns:
trueif the value is integer, otherwisefalse
-
isCompound
public boolean isCompound(Object term)
Description copied from class:ConversionPolicyDetermines whether the Prolog term is compound. Atoms are regarded as compound values with 0 arity.- Specified by:
isCompoundin classConversionPolicy- Parameters:
term- the term- Returns:
trueif the value is compound, otherwisefalse
-
isDouble
public boolean isDouble(Object term)
Description copied from class:ConversionPolicyDetermines whether the Prolog term is a double value.- Specified by:
isDoublein classConversionPolicy- Parameters:
term- the term- Returns:
trueif the value is double, otherwisefalse
-
isInteger
public boolean isInteger(Object term)
Description copied from class:ConversionPolicyDetermines whether the Prolog term is an integer value.- Specified by:
isIntegerin classConversionPolicy- Parameters:
term- the term- Returns:
trueif the value is integer, otherwisefalse
-
-