public class SL extends Object
Modifier and Type | Class and Description |
---|---|
static class |
SL.LoopingInstantiationException |
static class |
SL.WrongTypeException
This exception is thrown when trying to get the value of a meta variable
with the wrong type.
|
Modifier and Type | Field and Description |
---|---|
static SimpleDateFormat |
DATE_FORMAT
The FIPA-SL date format
|
static FalseNode |
FALSE
SL false boolean constant.
|
static Class[] |
META_REFERENCE_CLASSES |
static long |
NULL_TIME_OFFSET |
static TrueNode |
TRUE
SL true boolean constant.
|
Constructor and Description |
---|
SL() |
Modifier and Type | Method and Description |
---|---|
static Formula |
and(ListOfFormula literals)
Builds the conjunction of a list of formulas.
|
static Constant |
bytes(byte[] value) |
static void |
clearMetaReferences(Node expression) |
static Content |
content(String expression) |
static Constant |
date(Date value) |
static Constant |
date(String value) |
static Formula |
formula(String expression) |
static Content |
fromContent(String expression)
Deprecated.
use content instead
|
static Formula |
fromFormula(String expression)
Deprecated.
use formula instead
|
static Term |
fromTerm(String expression)
Deprecated.
use term instead
|
private static Node |
get(ArrayList mrefs,
Node mref) |
static String |
getMetaReferenceName(Node metaReference) |
static Node |
getMetaReferenceValue(Node metaReference) |
static Node |
instantiate(Node expression)
Return a tree representing the instantiated pattern, meaning all meta
variables have been replaced by their value.
|
static Node |
instantiate(Node node,
MatchResult mr)
Instantiates a formula by replacing all metavariables
contained in m by their values.
|
static Node |
instantiate(Node expression,
Object[] varNamesAndValues) |
static Node |
instantiate(Node expression,
String varname,
Node value) |
static Node |
instantiate(Node expression,
String varname1,
Node value1,
String varname2,
Node value2) |
static Node |
instantiate(Node expression,
String varname1,
Node value1,
String varname2,
Node value2,
String varname3,
Node value3) |
static Node |
instantiate(Node expression,
String varname1,
Node value1,
String varname2,
Node value2,
String varname3,
Node value3,
String varname4,
Node value4) |
static Constant |
integer(long value) |
static Constant |
integer(String value) |
static boolean |
isMetaReference(Node node)
Return true if the given node is a metareference node
|
static Node |
linkSameMetaReferences(Node expr)
This method transforms an SL expression so that all contained metareferences
with same name and same type are refered to by the same java reference.
|
static void |
linkSameMetaReferences(Node expr,
ArrayList mrefs) |
private static void |
linkSameMetaReferences(Node parent,
Node current,
int index,
ArrayList mrefs) |
static MatchResult |
match(Node expression1,
Node expression2)
TODO
|
private static String |
nameOf(String name) |
static Formula |
or(ListOfFormula literals)
Builds the disjunction of a list of formulas.
|
static Constant |
real(double value) |
static Constant |
real(String value) |
static String |
relativeTime(long time) |
private static long |
relativeTime(String value) |
static void |
removeOptionalParameter(Node node) |
static void |
set(Node expression,
String name,
Node value)
Assigned the value of the named meta variable.
|
static void |
setMetaReferenceName(Node metaReference,
String name) |
static void |
setMetaReferenceValue(Node metaReference,
Node value) |
static Constant |
string(String value) |
static void |
substituteMetaReferences(Node node) |
static Symbol |
symbol(String name) |
static Term |
term(String expression) |
static Node |
toPattern(Node expression,
ListOfNodes l,
String prefix)
This method returns a new expression corresponding to the given one in
which all variables of the given list are replaced by a
meta variable named
?? + given prefix + \ .The metaname is the same as the variable name. |
static Node |
toPattern(Node expression,
Variable x)
This method return a new expression corresponding to the given one in
which all variables equals to
x are replaced by a
meta variable named ??X . |
static Node |
toPattern(Node expression,
Variable x,
String metaname)
This method return a new expression corresponding to the given one in
which all variables equals to
x are replaced by a
meta variable named ??\ . |
private static void |
variable2MetaVariable(Node node,
Variable x,
String metavarname) |
static Constant |
word(String value) |
public static final SimpleDateFormat DATE_FORMAT
public static long NULL_TIME_OFFSET
public static final TrueNode TRUE
TrueNode
instances.public static final FalseNode FALSE
FalseNode
instances.public static final Class[] META_REFERENCE_CLASSES
public static Node toPattern(Node expression, Variable x)
x
are replaced by a
meta variable named ??X
.expression
- the expression to transform as a pattern.x
- the variable to be replaced by a meta variable.public static Node toPattern(Node expression, Variable x, String metaname)
x
are replaced by a
meta variable named ??\
.expression
- the expression to transform as a pattern.x
- the variable to be replaced by a meta variable.metaname
- the name of the introduced meta variable.public static Node toPattern(Node expression, ListOfNodes l, String prefix)
?? + given prefix + \
.expression
- the expression to transform as a pattern.l
- the list of variables to be replaced by meta variables.prefix
- the prefix of the name of the introduced meta variable.public static void set(Node expression, String name, Node value) throws SL.WrongTypeException
name
- the name of the meta variable to assign its value.value
- the value to be assigned to this meta variable.SL.WrongTypeException
- Thrown if the value of the variable is not f the good
type.public static Node instantiate(Node node, MatchResult mr)
f
- the Formula to instantiatem
- the MatchResult containinf the metavariable to instantiatepublic static Node instantiate(Node expression)
expression
- the expression to instantiate.public static Node instantiate(Node expression, String varname, Node value)
expression
- varname
- value
- SL.WrongTypeException
public static Node instantiate(Node expression, String varname1, Node value1, String varname2, Node value2)
expression
- varname1
- value1
- varname2
- value2
- SL.WrongTypeException
public static Node instantiate(Node expression, String varname1, Node value1, String varname2, Node value2, String varname3, Node value3)
expression
- varname1
- value1
- varname2
- value2
- varname3
- value3
- SL.WrongTypeException
public static Node instantiate(Node expression, String varname1, Node value1, String varname2, Node value2, String varname3, Node value3, String varname4, Node value4)
expression
- varname1
- value1
- varname2
- value2
- varname3
- value3
- varname4
- value4
- SL.WrongTypeException
public static Node instantiate(Node expression, Object[] varNamesAndValues)
expression
- arguments
- an array containing alternatively the var name and the value to be assigned.
var names are Strings while values are of type Node.SL.WrongTypeException
public static Constant string(String value)
value
- the value of that SL string constantpublic static Constant word(String value)
value
- the value of that SL word constantpublic static Constant integer(long value)
value
- the value of that SL integer constantpublic static Constant integer(String value)
value
- the value of that SL integer constantpublic static Constant real(double value)
value
- the value of that SL real constantpublic static Constant real(String value)
value
- the value of that SL real constantpublic static Constant date(Date value)
value
- the value of that SL date constantpublic static Constant date(String value)
value
- the value of that SL date constantprivate static long relativeTime(String value) throws ParseException
ParseException
public static String relativeTime(long time)
public static Constant bytes(byte[] value)
value
- the value of that SL date constantpublic static Symbol symbol(String name)
value
- the value of that symbol@Deprecated public static Formula fromFormula(String expression)
@Deprecated public static Term fromTerm(String expression)
@Deprecated public static Content fromContent(String expression)
public static Formula and(ListOfFormula literals)
false
if the list is empty.literals
- list of formulas that are to be linked with the
and
logical connector.public static Formula or(ListOfFormula literals)
true
if the list is empty.literals
- list of formulas that are to be linked with the
or
logical connector.public static MatchResult match(Node expression1, Node expression2)
public static String getMetaReferenceName(Node metaReference)
metaReference
- public static Node getMetaReferenceValue(Node metaReference)
metaReference
- public static boolean isMetaReference(Node node)
node
- public static void setMetaReferenceValue(Node metaReference, Node value) throws SL.WrongTypeException
metaReference
- value
- SL.WrongTypeException
public static void clearMetaReferences(Node expression)
expression
- public static void substituteMetaReferences(Node node) throws SL.LoopingInstantiationException
node
- SL.LoopingInstantiationException
public static void removeOptionalParameter(Node node)
node
- public static Node linkSameMetaReferences(Node expr)
expr
- mrefs
- private static void variable2MetaVariable(Node node, Variable x, String metavarname)