Class SameObjectTermFactory
java.lang.Object
fr.inria.rules.integraal.model.logicalElements.factory.impl.SameObjectTermFactory
- All Implemented Interfaces:
TermFactory
This factory creates terms. For each call at the same method with the same
parameters, the same java object will be returned. Therefore, the equality
test between those objects can be restricted to java object reference
comparison (==). Please make sure the term implementations used are
immutable otherwise there could be unwanted side effects.
- Author:
- Florent Tornil
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a term factory with identity-based caching semantics. -
Method Summary
Modifier and TypeMethodDescriptionTwo objects created by a call to this function must never be equals according to the definition given by theVariableimplementation used An anonymous Variable must not be equals to an existing Variable created byTermFactory.createOrGetVariable(String).createOrGetConstant(String label) //////////////////////////////////////////////createOrGetFloatLiteral(T value) Creates or reuses a floating-point literal from a numeric value.Two objects created by a call to this function must never be equals according to the definition given by theConstantimplementation used A Fresh Constant must not be equals to an existing Constant created byTermFactory.createOrGetConstant(String).Two objects created by a call to this function must never be equals according to the definition given by theVariableimplementation used A Fresh Variable must not be equals to an existing Variable created byTermFactory.createOrGetVariable(String).createOrGetIntegerLiteral(T value) Creates or reuses an integer literal from a numeric value.<T> Literal<T> createOrGetLiteral(T value) Two object created by a call to this function with the same typed value argument must be equals according to the definition given by theLiteralimplementation used /!createOrGetLogicalFunctionalTerm(String name, List<Term> terms) Two objects created by a call to this function with the same label argument must be equals according to the definition given by theLogicalFunctionalTermimplementation usedcreateOrGetVariable(String label) Two objects created by a call to this function with the same label argument must be equals according to the definition given by theVariableimplementation usedLiteral<?> createOrGetXsdLiteral(String lexicalForm, XsdDataType dataType) Builds a literal from a lexical string and anXsdDataType.Literal<?> createOrGetXsdLiteral(String lexicalForm, String xsdType) Builds a literal from a lexical string and an XSD type reference (e.g.booleanforgetConstant(String label) Forgets a previously created constant.Literal<?> Gets the null literal value.static SameObjectTermFactoryinstance()Returns the default instance of this factory.
-
Constructor Details
-
SameObjectTermFactory
public SameObjectTermFactory()Creates a term factory with identity-based caching semantics.
-
-
Method Details
-
instance
Returns the default instance of this factory.- Returns:
- the default instance of this factory
-
createOrGetConstant
//////////////////////////////////////////////- Specified by:
createOrGetConstantin interfaceTermFactory- Parameters:
label- the label- Returns:
- a constant with the given label
-
createOrGetLiteral
Description copied from interface:TermFactoryTwo object created by a call to this function with the same typed value argument must be equals according to the definition given by theLiteralimplementation used /!\ This method must not be used to create a number literal- Specified by:
createOrGetLiteralin interfaceTermFactory- Type Parameters:
T- the native type of the literal- Parameters:
value- the value- Returns:
- a literal with the given value
-
createOrGetIntegerLiteral
Description copied from interface:TermFactoryCreates or reuses an integer literal from a numeric value.- Specified by:
createOrGetIntegerLiteralin interfaceTermFactory- Type Parameters:
T- the numeric type of the input value- Parameters:
value- the numeric value to convert- Returns:
- a literal holding the integer value
-
createOrGetFloatLiteral
Description copied from interface:TermFactoryCreates or reuses a floating-point literal from a numeric value.- Specified by:
createOrGetFloatLiteralin interfaceTermFactory- Type Parameters:
T- the numeric type of the input value- Parameters:
value- the numeric value to convert- Returns:
- a literal holding the floating-point value
-
createOrGetVariable
Description copied from interface:TermFactoryTwo objects created by a call to this function with the same label argument must be equals according to the definition given by theVariableimplementation used- Specified by:
createOrGetVariablein interfaceTermFactory- Parameters:
label- the label- Returns:
- a variable with the given label
-
createOrGetAnonymousVariable
Description copied from interface:TermFactoryTwo objects created by a call to this function must never be equals according to the definition given by theVariableimplementation used An anonymous Variable must not be equals to an existing Variable created byTermFactory.createOrGetVariable(String).- Specified by:
createOrGetAnonymousVariablein interfaceTermFactory- Returns:
- a variable with a new label
-
createOrGetLogicalFunctionalTerm
Description copied from interface:TermFactoryTwo objects created by a call to this function with the same label argument must be equals according to the definition given by theLogicalFunctionalTermimplementation used- Specified by:
createOrGetLogicalFunctionalTermin interfaceTermFactory- Parameters:
name- the name of the functionterms- the ordered arguments of the function- Returns:
- a logical functional term with the given name and terms
-
createOrGetFreshVariable
Description copied from interface:TermFactoryTwo objects created by a call to this function must never be equals according to the definition given by theVariableimplementation used A Fresh Variable must not be equals to an existing Variable created byTermFactory.createOrGetVariable(String).- Specified by:
createOrGetFreshVariablein interfaceTermFactory- Returns:
- a variable with a new label
-
createOrGetFreshConstant
Description copied from interface:TermFactoryTwo objects created by a call to this function must never be equals according to the definition given by theConstantimplementation used A Fresh Constant must not be equals to an existing Constant created byTermFactory.createOrGetConstant(String).- Specified by:
createOrGetFreshConstantin interfaceTermFactory- Returns:
- a constant with a new label
-
forgetConstant
Description copied from interface:TermFactoryForgets a previously created constant.
This constant will no longer be considered as already existing in the factory.- Specified by:
forgetConstantin interfaceTermFactory- Parameters:
label- the label of the previously created constant- Returns:
- true iff such a constant already exists in the factory, and thus forgets it.
-
createOrGetXsdLiteral
Description copied from interface:TermFactoryBuilds a literal from a lexical string and an XSD type reference (e.g. "xsd:integer" or "http://www.w3.org/2001/XMLSchema#dateTime").The lexical string is parsed into a Java Object based on the XSD type, then stored in a Literal.
- Specified by:
createOrGetXsdLiteralin interfaceTermFactory- Parameters:
lexicalForm- the lexical form to parsexsdType- the XSD type identifier- Returns:
- the parsed literal
-
createOrGetXsdLiteral
Description copied from interface:TermFactoryBuilds a literal from a lexical string and anXsdDataType.- Specified by:
createOrGetXsdLiteralin interfaceTermFactory- Parameters:
lexicalForm- the lexical form to parsedataType- the target datatype- Returns:
- the parsed literal
-
getNullLiteral
Description copied from interface:TermFactoryGets the null literal value.- Specified by:
getNullLiteralin interfaceTermFactory- Returns:
- the null literal
-