parser.absconparseur.tools
Class InstanceParser

java.lang.Object
  extended by parser.absconparseur.tools.InstanceParser

public class InstanceParser
extends Object

This class corresponds to a Java parser that uses DOM (Document Object Model) to parse CSP and WCSP instances in format "XCSP 2.1".
Here, we assume that the instance is well-formed (valid). This class is given for illustration purpose. Feel free to adapt it !

Version:
2.1.1
Author:
christophe lecoutre

Field Summary
 Document document
           
protected static Logger LOGGER
           
static String VERSION
           
 
Constructor Summary
InstanceParser()
           
 
Method Summary
protected static String buildStringRepresentationOf(Element parameters)
           
 String getConstraintsCategory()
           
 Map<String,PConstraint> getMapOfConstraints()
           
 Map<String,PDomain> getMapOfDomains()
           
 Map<String,PPredicate> getMapOfPredicat()
           
 Map<String,PRelation> getMapOfRelations()
           
 Map<String,PVariable> getMapOfVariables()
           
 int getMaxConstraintArity()
           
 String getMinViolatedConstraints()
           
 int getNBDomain()
           
 int getNbExtensionConstraints()
           
 int getNbGlobalConstraints()
           
 int getNbIntensionConstraints()
           
 int getNbVariables()
           
 String getSatisfiable()
           
 String getType()
           
 PVariable[] getVariables()
           
 void loadInstance(String fileName)
          Build a DOM object that corresponds to the file whose name is given.
static void main(String[] args)
           
 void parse(boolean displayInstance)
          Parse the DOM object that has been loaded.
protected  PConstraint parseCumulativeConstraint(String name, PVariable[] scope, Element parameters)
           
protected  PConstraint parseDisjunctiveConstraint(String name, PVariable[] scope, Element parameters)
           
protected  PConstraint parseGlobalConstraint(String reference, String name, PVariable[] scope, Element parameters)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final Logger LOGGER

VERSION

public static final String VERSION
See Also:
Constant Field Values

document

public Document document
Constructor Detail

InstanceParser

public InstanceParser()
Method Detail

getType

public String getType()

getVariables

public PVariable[] getVariables()

getNbVariables

public int getNbVariables()

getMaxConstraintArity

public int getMaxConstraintArity()

getMapOfConstraints

public Map<String,PConstraint> getMapOfConstraints()

getMapOfDomains

public Map<String,PDomain> getMapOfDomains()

getMapOfRelations

public Map<String,PRelation> getMapOfRelations()

getMapOfPredicat

public Map<String,PPredicate> getMapOfPredicat()

getMapOfVariables

public Map<String,PVariable> getMapOfVariables()

getNbExtensionConstraints

public int getNbExtensionConstraints()

getNbIntensionConstraints

public int getNbIntensionConstraints()

getNbGlobalConstraints

public int getNbGlobalConstraints()

getConstraintsCategory

public String getConstraintsCategory()

getNBDomain

public int getNBDomain()

getSatisfiable

public String getSatisfiable()

getMinViolatedConstraints

public String getMinViolatedConstraints()

loadInstance

public void loadInstance(String fileName)
Build a DOM object that corresponds to the file whose name is given.
The file must represent a CSP instance according to format XCSP 2.1

Parameters:
fileName - the name of a file representing a CSP instance.

buildStringRepresentationOf

protected static String buildStringRepresentationOf(Element parameters)

parseCumulativeConstraint

protected PConstraint parseCumulativeConstraint(String name,
                                                PVariable[] scope,
                                                Element parameters)

parseDisjunctiveConstraint

protected PConstraint parseDisjunctiveConstraint(String name,
                                                 PVariable[] scope,
                                                 Element parameters)

parseGlobalConstraint

protected PConstraint parseGlobalConstraint(String reference,
                                            String name,
                                            PVariable[] scope,
                                            Element parameters)

parse

public void parse(boolean displayInstance)
           throws UnsupportedConstraintException
Parse the DOM object that has been loaded.

Parameters:
displayInstance - if true , elements of the instance will be displayed.
Throws:
UnsupportedConstraintException

main

public static void main(String[] args)
                 throws UnsupportedConstraintException
Throws:
UnsupportedConstraintException


Copyright © 2012. All Rights Reserved.