Package org.xcsp.parser
Class XParser
- java.lang.Object
-
- org.xcsp.parser.XParser
-
public class XParser extends Object
This class corresponds to a Java parser that uses DOM (Document Object Model) to parse XCSP3 instances.
Here, we assume that the instance is well-formed (valid). This class is given for illustration purpose. Feel free to adapt it !- Version:
- 1.3
- Author:
- Christophe Lecoutre, CRIL-CNRS - lecoutre@cril.fr
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
XParser.TypePrimitive
The enum type describing the different types of primitives that can be used for representing arrays of integer tuples.
-
Field Summary
Fields Modifier and Type Field Description Map<String,Object>
aEntries
List<ParsingEntry.CEntry>
cEntries
The list of entries of the element. Types.TypeClass[]
discardedClasses
The classes that must be discarded.Map<String,XVariables.XVar>
mapForVars
The map that stores pairs (id,variable).List<ParsingEntry.OEntry>
oEntries
The list of objectives of the element. Types.TypeCombination
typeCombination
In case of multi-objective optimization, indicates the type that must be considered.Types.TypeFramework
typeFramework
The type of the framework used for the loaded instance.List<ParsingEntry.VEntry>
vEntries
The list of entries of the element. static boolean
VERBOSE
-
Constructor Summary
Constructors Constructor Description XParser(InputStream inputStream, String... discardedClasses)
Loads and parses the XCSP3 file corresponding to the specified inputStream.XParser(InputStream inpuStream, Types.TypeClass[] discardedClasses)
Loads and parses the XCSP3 file corresponding to the specified inputStream.XParser(Document document, String... discardedClasses)
Loads and parses the XCSP3 file corresponding to the specified document.XParser(Document document, Types.TypeClass[] discardedClasses)
Loads and parses the XCSP3 file corresponding to the specified document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object[]
parseSequence(String seq, String delimiter)
Parse a sequence of tokens (separated by the specified delimiter).Object[]
parseSequence(Element elt)
void
parseVariables()
Parses all elements inside the element.
-
-
-
Field Detail
-
VERBOSE
public static boolean VERBOSE
-
mapForVars
public Map<String,XVariables.XVar> mapForVars
The map that stores pairs (id,variable).
-
vEntries
public List<ParsingEntry.VEntry> vEntries
The list of entries of the element. It contains variables and arrays.
-
cEntries
public List<ParsingEntry.CEntry> cEntries
The list of entries of the element. It contains stand-alone constraints (extension, intension, allDifferent, ...), groups of constraints, and meta-constraints (sliding and logical constructions).
-
oEntries
public List<ParsingEntry.OEntry> oEntries
The list of objectives of the element. Typically, it contains 0 or 1 objective.
-
typeFramework
public Types.TypeFramework typeFramework
The type of the framework used for the loaded instance.
-
typeCombination
public Types.TypeCombination typeCombination
In case of multi-objective optimization, indicates the type that must be considered.
-
discardedClasses
public Types.TypeClass[] discardedClasses
The classes that must be discarded. Used just before posting variables, constraints and objectives.
-
-
Constructor Detail
-
XParser
public XParser(Document document, Types.TypeClass[] discardedClasses) throws Exception
Loads and parses the XCSP3 file corresponding to the specified document. The specified array (possibly empty) of TypeClass denotes the classes that must be discarded (e.g., symmetryBreaking).- Throws:
Exception
-
XParser
public XParser(Document document, String... discardedClasses) throws Exception
Loads and parses the XCSP3 file corresponding to the specified document. The specified array (possibly empty) of strings denotes the classes that must be discarded (e.g., symmetryBreaking).- Throws:
Exception
-
XParser
public XParser(InputStream inpuStream, Types.TypeClass[] discardedClasses) throws Exception
Loads and parses the XCSP3 file corresponding to the specified inputStream. The specified array (possibly empty) of TypeClass denotes the classes that must be discarded (e.g., symmetryBreaking).- Throws:
Exception
-
XParser
public XParser(InputStream inputStream, String... discardedClasses) throws Exception
Loads and parses the XCSP3 file corresponding to the specified inputStream. The specified array (possibly empty) of strings denotes the classes that must be discarded (e.g., symmetryBreaking).- Throws:
Exception
-
-
Method Detail
-
parseVariables
public void parseVariables()
Parses all elements inside the element.
-
parseSequence
public Object[] parseSequence(String seq, String delimiter)
Parse a sequence of tokens (separated by the specified delimiter). Each token can represent a compact list of array variables, or a basic entity.
-
-