Class 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
    • Field Detail

      • VERBOSE

        public static boolean VERBOSE
      • HYBRID

        public static String HYBRID
      • 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.