org.decisiondeck.jmcda.persist.xmcda2.aggregates
Class XMCDASortingProblemWriter

java.lang.Object
  extended by org.decisiondeck.jmcda.persist.xmcda2.aggregates.XMCDASortingProblemWriter

public class XMCDASortingProblemWriter
extends Object

A class to write MCDA sorting problems to XMCDA documents, including the typical preferences informations related to a sorting problem, namely thresholds and coalitions; and sorting results, namely assignments. Support is given for assignments to single categories, assignments to multiple categories and assignments with credibilites. This class supports the case of a single decision maker.

Although this class is meant to write characters rather than bytes, it uses output streams rather than writers. This is because the writer hides the encoding used, which disables the possibility to correctly write the encoding used in the XML header. Objects of this class use the UTF-8 encoding by default. See getSaveOptions().


Constructor Summary
XMCDASortingProblemWriter()
          Creates a new writer.
XMCDASortingProblemWriter(OutputSupplier<? extends OutputStream> mainDestination)
          Creates a new writer with a main destination.
 
Method Summary
 void append(ICatsAndProfs catsAndProfs, XMCDADoc.XMCDA xmcda)
           
 void append(ICoalitions coalitions, Set<Criterion> criteriaOrder, XMCDADoc.XMCDA xmcda)
           
 void append(IOrderedAssignmentsToMultipleRead assignments, Set<Alternative> alternativesOrder, XMCDADoc.XMCDA xmcda)
           
 void append(IRdEvaluations evaluations, Set<Alternative> alternativesOrder, Set<Criterion> criteriaOrder, XMCDADoc.XMCDA xmcda)
           
 void append(Map<DecisionMaker,ICoalitions> coalitions, Set<DecisionMaker> dmsOrder, Set<Criterion> criteriaOrder, XMCDADoc.XMCDA xmcda)
           
 void append(Map<DecisionMaker,IRdEvaluations> profilesEvaluations, Set<DecisionMaker> dmsOrder, Set<Alternative> profilesOrder, Set<Criterion> criteriaOrder, XMCDADoc.XMCDA xmcda)
           
 void append(Set<Alternative> alternatives, XAlternativeType.Enum type, XMCDADoc.XMCDA xmcda)
           
 void append(Set<Criterion> criteria, Map<Criterion,IOrderedInterval> scales, ICriteriaWithThresholds thresholds, XMCDADoc.XMCDA xmcda)
           
 void append(Set<DecisionMaker> dms, XMCDADoc.XMCDA xmcda)
           
 void appendAssignments(Map<DecisionMaker,? extends IOrderedAssignmentsToMultipleRead> assignments, Set<DecisionMaker> dmsOrder, Set<Alternative> alternativesOrder, XMCDADoc.XMCDA xmcda)
           
 void appendAssignmentsWithCredibilities(Map<DecisionMaker,? extends IOrderedAssignmentsWithCredibilitiesRead> assignments, Set<DecisionMaker> dmsOrder, Set<Alternative> alternativesOrder, XMCDADoc.XMCDA xmcda)
           
 void appendData(ISortingData data, ICriteriaWithThresholds thresholds, XMCDADoc.XMCDA xmcda)
           
 void appendGroupData(IGroupSortingData data, ICriteriaWithThresholds thresholds, XMCDADoc.XMCDA xmcda)
           
 void appendGroupPreferences(IGroupSortingPreferences data, XMCDADoc.XMCDA xmcda)
           
 void appendPreferences(ISortingPreferences data, XMCDADoc.XMCDA xmcda)
           
 void appendWithCredibilities(IOrderedAssignmentsWithCredibilitiesRead assignments, Set<Alternative> alternativesOrder, XMCDADoc.XMCDA xmcda)
           
 boolean doesValidate()
          Retrieves the information whether this object only accepts to write valid documents.
 OutputSupplier<? extends OutputStream> getDestinationAlternatives()
          Retrieves the destination dedicated to alternatives.
 OutputSupplier<? extends OutputStream> getDestinationAlternativesEvaluations()
          Retrieves the destination dedicated to alternatives evaluations.
 OutputSupplier<? extends OutputStream> getDestinationAssignments()
          Retrieves the destination dedicated to assignments.
 OutputSupplier<? extends OutputStream> getDestinationCategories()
          Retrieves the destination dedicated to categories.
 OutputSupplier<? extends OutputStream> getDestinationCategoriesProfiles()
          Retrieves the destination dedicated to definition of the categories through bounding profiles.
 OutputSupplier<? extends OutputStream> getDestinationCoalitions()
          Retrieves the destination dedicated to coalitions.
 OutputSupplier<? extends OutputStream> getDestinationCriteria()
          Retrieves the destination dedicated to criteria.
 OutputSupplier<? extends OutputStream> getDestinationMain()
          Retrieves the main destination.
 OutputSupplier<? extends OutputStream> getDestinationProfiles()
          Retrieves the destination dedicated to profiles.
 OutputSupplier<? extends OutputStream> getDestinationProfilesEvaluations()
          Retrieves the destination dedicated to profiles evaluations.
 XmlOptions getSaveOptions()
          Retrieves a writable view of the options used to save XML streams.
 void setDestinationAlternatives(OutputSupplier<? extends OutputStream> destinationAlternatives)
          Sets the dedicated destination used to write alternatives.
 void setDestinationAlternativesEvaluations(OutputSupplier<? extends OutputStream> destinationAlternativesEvaluations)
          Sets the dedicated destination used to write the evaluations of the alternatives.
 void setDestinationAssignments(OutputSupplier<? extends OutputStream> destination)
          Sets the dedicated destination used to write assignments.
 void setDestinationCategories(OutputSupplier<? extends OutputStream> destination)
          Sets the dedicated destination used to write the categories.
 void setDestinationCategoriesProfiles(OutputSupplier<? extends OutputStream> destinationCategoriesProfiles)
          Sets the dedicated destination used to write the categories and associated profiles.
 void setDestinationCoalitions(OutputSupplier<? extends OutputStream> destinationCoalitions)
          Sets the dedicated destination used to write the coalitions.
 void setDestinationCriteria(OutputSupplier<? extends OutputStream> destinationCriteria)
          Sets the dedicated destination used to write the criteria.
 void setDestinationMain(OutputSupplier<? extends OutputStream> destinationMain)
          Sets the main destination used to write all types of objects for which no dedicated destination is set.
 void setDestinationProfiles(OutputSupplier<? extends OutputStream> destinationProfiles)
          Sets the dedicated destination used to write the profiles.
 void setDestinationProfilesEvaluations(OutputSupplier<? extends OutputStream> destination)
          Sets the dedicated destination used to write the profiles evaluations.
 void setValidate(boolean validate)
          Enables or disables the check for validation before writing any document.
 void write(XMCDADoc doc, OutputSupplier<? extends OutputStream> destination)
          Writes the given XMCDA document to the given destination or to the main destination if the given destination is null.
 void writeAssignments(ISortingAssignments data)
           
 void writeAssignments(ISortingAssignmentsToMultiple data)
           
 void writeAssignmentsWithCredibilities(ISortingAssignmentsWithCredibilities data)
           
 void writeData(ISortingData data)
           
 void writeGroupAssignments(IGroupSortingAssignments data)
           
 void writeGroupAssignments(IGroupSortingAssignmentsToMultiple data)
           
 void writeGroupAssignmentsWithCredibilities(IGroupSortingAssignmentsWithCredibilities data)
           
 void writeGroupPreferences(IGroupSortingPreferences data)
           
 void writeGroupResults(IGroupSortingResults data)
           
 void writeGroupResults(IGroupSortingResultsToMultiple data)
           
 void writeGroupResultsWithCredibilities(IGroupSortingResultsWithCredibilities data)
           
 void writePreferences(ISortingPreferences data)
           
 void writeResults(ISortingResults data)
           
 void writeResults(ISortingResultsToMultiple data)
           
 void writeResultsWithCredibilities(ISortingResultsWithCredibilities data)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMCDASortingProblemWriter

public XMCDASortingProblemWriter()
Creates a new writer.


XMCDASortingProblemWriter

public XMCDASortingProblemWriter(OutputSupplier<? extends OutputStream> mainDestination)
Creates a new writer with a main destination.

Parameters:
mainDestination - not null.
Method Detail

getSaveOptions

public XmlOptions getSaveOptions()
Retrieves a writable view of the options used to save XML streams. Default options are to use pretty print and to use the UTF-8 encoding.

Returns:
not null.

writeData

public void writeData(ISortingData data)
               throws IOException
Throws:
IOException

append

public void append(ICatsAndProfs catsAndProfs,
                   XMCDADoc.XMCDA xmcda)

append

public void append(IRdEvaluations evaluations,
                   Set<Alternative> alternativesOrder,
                   Set<Criterion> criteriaOrder,
                   XMCDADoc.XMCDA xmcda)

append

public void append(Set<Criterion> criteria,
                   Map<Criterion,IOrderedInterval> scales,
                   ICriteriaWithThresholds thresholds,
                   XMCDADoc.XMCDA xmcda)

append

public void append(Set<Alternative> alternatives,
                   XAlternativeType.Enum type,
                   XMCDADoc.XMCDA xmcda)

setDestinationCategoriesProfiles

public void setDestinationCategoriesProfiles(OutputSupplier<? extends OutputStream> destinationCategoriesProfiles)
Sets the dedicated destination used to write the categories and associated profiles.

Parameters:
destinationCategoriesProfiles - null for not set.

getDestinationCategories

public OutputSupplier<? extends OutputStream> getDestinationCategories()
Retrieves the destination dedicated to categories.

Returns:
null if not set.

getDestinationCategoriesProfiles

public OutputSupplier<? extends OutputStream> getDestinationCategoriesProfiles()
Retrieves the destination dedicated to definition of the categories through bounding profiles.

Returns:
null if not set.

getDestinationProfiles

public OutputSupplier<? extends OutputStream> getDestinationProfiles()
Retrieves the destination dedicated to profiles.

Returns:
null if not set.

getDestinationProfilesEvaluations

public OutputSupplier<? extends OutputStream> getDestinationProfilesEvaluations()
Retrieves the destination dedicated to profiles evaluations.

Returns:
null if not set.

setDestinationCategories

public void setDestinationCategories(OutputSupplier<? extends OutputStream> destination)
Sets the dedicated destination used to write the categories.

Parameters:
destination - null for not set.

setDestinationProfiles

public void setDestinationProfiles(OutputSupplier<? extends OutputStream> destinationProfiles)
Sets the dedicated destination used to write the profiles.

Parameters:
destinationProfiles - null for not set.

setDestinationProfilesEvaluations

public void setDestinationProfilesEvaluations(OutputSupplier<? extends OutputStream> destination)
Sets the dedicated destination used to write the profiles evaluations.

Parameters:
destination - null for not set.

getDestinationAlternatives

public OutputSupplier<? extends OutputStream> getDestinationAlternatives()
Retrieves the destination dedicated to alternatives.

Returns:
null if not set.

setDestinationAlternatives

public void setDestinationAlternatives(OutputSupplier<? extends OutputStream> destinationAlternatives)
Sets the dedicated destination used to write alternatives.

Parameters:
destinationAlternatives - null for not set.

getDestinationAlternativesEvaluations

public OutputSupplier<? extends OutputStream> getDestinationAlternativesEvaluations()
Retrieves the destination dedicated to alternatives evaluations.

Returns:
null if not set.

setDestinationAlternativesEvaluations

public void setDestinationAlternativesEvaluations(OutputSupplier<? extends OutputStream> destinationAlternativesEvaluations)
Sets the dedicated destination used to write the evaluations of the alternatives.

Parameters:
destinationAlternativesEvaluations - null for not set.

getDestinationCoalitions

public OutputSupplier<? extends OutputStream> getDestinationCoalitions()
Retrieves the destination dedicated to coalitions.

Returns:
null if not set.

setDestinationCoalitions

public void setDestinationCoalitions(OutputSupplier<? extends OutputStream> destinationCoalitions)
Sets the dedicated destination used to write the coalitions.

Parameters:
destinationCoalitions - null for not set.

getDestinationCriteria

public OutputSupplier<? extends OutputStream> getDestinationCriteria()
Retrieves the destination dedicated to criteria.

Returns:
null if not set.

setDestinationCriteria

public void setDestinationCriteria(OutputSupplier<? extends OutputStream> destinationCriteria)
Sets the dedicated destination used to write the criteria.

Parameters:
destinationCriteria - null for not set.

getDestinationMain

public OutputSupplier<? extends OutputStream> getDestinationMain()
Retrieves the main destination. This is used to write any type of object when the dedicated destination is not set.

Returns:
null if not set.

setDestinationMain

public void setDestinationMain(OutputSupplier<? extends OutputStream> destinationMain)
Sets the main destination used to write all types of objects for which no dedicated destination is set.

Parameters:
destinationMain - null for not set.

write

public void write(XMCDADoc doc,
                  OutputSupplier<? extends OutputStream> destination)
           throws IOException
Writes the given XMCDA document to the given destination or to the main destination if the given destination is null. The document must be valid, except if this object is specifically set to not validate documents.

Parameters:
doc - not null, must conform to the XMCDA schema.
destination - may be null, in which case the main destination in this object must be non null.
Throws:
IOException - if an exception happens while opening or closing the given writer, or while writing to the destination.
See Also:
setValidate(boolean)

doesValidate

public boolean doesValidate()
Retrieves the information whether this object only accepts to write valid documents. The default is true.

Returns:
true if this object validates documents before writing them.

setValidate

public void setValidate(boolean validate)
Enables or disables the check for validation before writing any document. The default is true, thus this object validates each document before writing them. It is not recommanded to disable validation but it can be useful for debug.

Parameters:
validate - false to allow writing invalid documents.

getDestinationAssignments

public OutputSupplier<? extends OutputStream> getDestinationAssignments()
Retrieves the destination dedicated to assignments.

Returns:
null if not set.

setDestinationAssignments

public void setDestinationAssignments(OutputSupplier<? extends OutputStream> destination)
Sets the dedicated destination used to write assignments.

Parameters:
destination - null for not set.

writePreferences

public void writePreferences(ISortingPreferences data)
                      throws IOException
Throws:
IOException

appendPreferences

public void appendPreferences(ISortingPreferences data,
                              XMCDADoc.XMCDA xmcda)

writeAssignments

public void writeAssignments(ISortingAssignments data)
                      throws IOException
Throws:
IOException

appendWithCredibilities

public void appendWithCredibilities(IOrderedAssignmentsWithCredibilitiesRead assignments,
                                    Set<Alternative> alternativesOrder,
                                    XMCDADoc.XMCDA xmcda)

append

public void append(ICoalitions coalitions,
                   Set<Criterion> criteriaOrder,
                   XMCDADoc.XMCDA xmcda)

append

public void append(IOrderedAssignmentsToMultipleRead assignments,
                   Set<Alternative> alternativesOrder,
                   XMCDADoc.XMCDA xmcda)

writeAssignments

public void writeAssignments(ISortingAssignmentsToMultiple data)
                      throws IOException
Throws:
IOException

writeResults

public void writeResults(ISortingResults data)
                  throws IOException
Throws:
IOException

writeResults

public void writeResults(ISortingResultsToMultiple data)
                  throws IOException
Throws:
IOException

writeResultsWithCredibilities

public void writeResultsWithCredibilities(ISortingResultsWithCredibilities data)
                                   throws IOException
Throws:
IOException

writeAssignmentsWithCredibilities

public void writeAssignmentsWithCredibilities(ISortingAssignmentsWithCredibilities data)
                                       throws IOException
Throws:
IOException

writeGroupPreferences

public void writeGroupPreferences(IGroupSortingPreferences data)
                           throws IOException
Throws:
IOException

appendGroupPreferences

public void appendGroupPreferences(IGroupSortingPreferences data,
                                   XMCDADoc.XMCDA xmcda)

appendGroupData

public void appendGroupData(IGroupSortingData data,
                            ICriteriaWithThresholds thresholds,
                            XMCDADoc.XMCDA xmcda)

appendData

public void appendData(ISortingData data,
                       ICriteriaWithThresholds thresholds,
                       XMCDADoc.XMCDA xmcda)

append

public void append(Map<DecisionMaker,IRdEvaluations> profilesEvaluations,
                   Set<DecisionMaker> dmsOrder,
                   Set<Alternative> profilesOrder,
                   Set<Criterion> criteriaOrder,
                   XMCDADoc.XMCDA xmcda)

append

public void append(Map<DecisionMaker,ICoalitions> coalitions,
                   Set<DecisionMaker> dmsOrder,
                   Set<Criterion> criteriaOrder,
                   XMCDADoc.XMCDA xmcda)

append

public void append(Set<DecisionMaker> dms,
                   XMCDADoc.XMCDA xmcda)

writeGroupAssignments

public void writeGroupAssignments(IGroupSortingAssignments data)
                           throws IOException
Throws:
IOException

appendAssignments

public void appendAssignments(Map<DecisionMaker,? extends IOrderedAssignmentsToMultipleRead> assignments,
                              Set<DecisionMaker> dmsOrder,
                              Set<Alternative> alternativesOrder,
                              XMCDADoc.XMCDA xmcda)

writeGroupAssignments

public void writeGroupAssignments(IGroupSortingAssignmentsToMultiple data)
                           throws IOException
Throws:
IOException

writeGroupAssignmentsWithCredibilities

public void writeGroupAssignmentsWithCredibilities(IGroupSortingAssignmentsWithCredibilities data)
                                            throws IOException
Throws:
IOException

appendAssignmentsWithCredibilities

public void appendAssignmentsWithCredibilities(Map<DecisionMaker,? extends IOrderedAssignmentsWithCredibilitiesRead> assignments,
                                               Set<DecisionMaker> dmsOrder,
                                               Set<Alternative> alternativesOrder,
                                               XMCDADoc.XMCDA xmcda)

writeGroupResults

public void writeGroupResults(IGroupSortingResults data)
                       throws IOException
Throws:
IOException

writeGroupResults

public void writeGroupResults(IGroupSortingResultsToMultiple data)
                       throws IOException
Throws:
IOException

writeGroupResultsWithCredibilities

public void writeGroupResultsWithCredibilities(IGroupSortingResultsWithCredibilities data)
                                        throws IOException
Throws:
IOException


Copyright © 2011. All Rights Reserved.