org.decisiondeck.jmcda.persist.xmcda2
Class XMCDAVarious

java.lang.Object
  extended by org.decisiondeck.jmcda.persist.xmcda2.utils.XMCDAHelper
      extended by org.decisiondeck.jmcda.persist.xmcda2.XMCDAVarious

public class XMCDAVarious
extends XMCDAHelper

Reads from and writes to various XMCDA fragments. Contains methods not found in other classes to read and write numbers, strings, and other elementary structures.


Constructor Summary
XMCDAVarious()
          Creates a new object which will use the default error management strategy XMCDAErrorsManager.ErrorManagement.THROW.
XMCDAVarious(XMCDAErrorsManager errorsManager)
          Creates a new object delegating error management to the given error manager in case of unexpected data read.
 
Method Summary
 Double readDouble(Collection<XValue> xValues, String contextMessageIfEmpty)
           Retrieves the number embedded in the given fragment.
 Double readDouble(XMethodParameters xMethodParameters, String contextMessageIfEmpty)
           Retrieves the number embedded in the given fragment.
 Double readDouble(XNumericValue xNumber)
           Retrieves the number embedded in the given fragment.
 Double readDouble(XParameter xParameter)
           Retrieves the number embedded in the given fragment.
 Double readDouble(XValue xValue)
           Retrieves the number embedded in the given fragment.
 String readLabel(XMethodParameters xMethodParameters, String contextMessageIfEmpty)
           Retrieves the label embedded in the given fragment.
 String readLabel(XParameter xParameter)
           Retrieves the label embedded in the given fragment.
 String readLabel(XValue xValue)
           Retrieves the label embedded in the given fragment.
 List<String> readMessages(XMethodMessages xMethodMessages)
           
 XMethodParameters writeAsMethodParameters(double value)
          Retrieves the given value as an XMCDA fragment.
 XMethodParameters writeAsMethodParameters(String value)
          Retrieves the given value as an XMCDA fragment.
 XParameter writeAsParameter(double value)
          Retrieves the given value as an XMCDA fragment.
 XParameter writeAsParameter(String value)
          Retrieves the given value as an XMCDA fragment.
 XProjectReference writeComment(String comment)
          Retrieves the given value as an XMCDA project reference fragment.
 XMessage writeErrorMessage(String errorMessage)
          Retrieves the given error message as an XMessage fragment.
 XMethodMessages writeErrorMessages(Collection<String> errorMessages)
          Retrieves the given error messages as an XMethodMessages fragment.
 XMessage writeLogMessage(String logMessage)
          Retrieves the given log message as an XMessage fragment.
 XMessage writeMessage(String message)
          Retrieves the given message as an XMessage fragment.
 XMethodMessages writeMessages(Collection<String> messages)
          Retrieves the given messages as an XMethodMessages fragment.
 
Methods inherited from class org.decisiondeck.jmcda.persist.xmcda2.utils.XMCDAHelper
error, getStrategy, setStrategy
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMCDAVarious

public XMCDAVarious()
Creates a new object which will use the default error management strategy XMCDAErrorsManager.ErrorManagement.THROW.


XMCDAVarious

public XMCDAVarious(XMCDAErrorsManager errorsManager)
Creates a new object delegating error management to the given error manager in case of unexpected data read.

Parameters:
errorsManager - not null.
Method Detail

writeComment

public XProjectReference writeComment(String comment)
Retrieves the given value as an XMCDA project reference fragment.

Parameters:
comment - not null.
Returns:
not null.

writeMessage

public XMessage writeMessage(String message)
Retrieves the given message as an XMessage fragment.

Parameters:
message - not null.
Returns:
not null.

writeErrorMessage

public XMessage writeErrorMessage(String errorMessage)
Retrieves the given error message as an XMessage fragment.

Parameters:
errorMessage - not null.
Returns:
not null.

writeLogMessage

public XMessage writeLogMessage(String logMessage)
Retrieves the given log message as an XMessage fragment.

Parameters:
logMessage - not null.
Returns:
not null.

readDouble

public Double readDouble(Collection<XValue> xValues,
                         String contextMessageIfEmpty)
                  throws InvalidInputException

Retrieves the number embedded in the given fragment.

This method expects there is exactly one element in the given collection and it contains a number. In case of unexpected contents, this method returns null or throws an exception depending on the strategy this object follows.

Parameters:
xValues - not null.
contextMessageIfEmpty - if not null, is used to give a more useful error message about the context when the given collection is empty.
Returns:
a real number, or null iff unexpected content has been read and this object follows a permissive strategy.
Throws:
InvalidInputException - iff unexpected content has been read and this object follows the XMCDAErrorsManager.ErrorManagement.THROW strategy.

readDouble

public Double readDouble(XMethodParameters xMethodParameters,
                         String contextMessageIfEmpty)
                  throws InvalidInputException

Retrieves the number embedded in the given fragment.

This method expects the fragments contains a unique number. In case of unexpected contents, this method returns null or throws an exception depending on the strategy this object follows.

Parameters:
xMethodParameters - not null.
contextMessageIfEmpty - if not null, is used to give a more useful error message about the context when the given fragment contains an empty collection.
Returns:
a real number, or null iff unexpected content has been read and this object follows a permissive strategy.
Throws:
InvalidInputException - iff unexpected content has been read and this object follows the XMCDAErrorsManager.ErrorManagement.THROW strategy.

readDouble

public Double readDouble(XNumericValue xNumber)
                  throws InvalidInputException

Retrieves the number embedded in the given fragment.

This method expects the fragments contains a number. In case of unexpected contents, this method returns null or throws an exception depending on the strategy this object follows.

Parameters:
xNumber - not null.
Returns:
a real number, or null iff unexpected content has been read and this object follows a permissive strategy.
Throws:
InvalidInputException - iff unexpected content has been read and this object follows the XMCDAErrorsManager.ErrorManagement.THROW strategy.

readDouble

public Double readDouble(XParameter xParameter)
                  throws InvalidInputException

Retrieves the number embedded in the given fragment.

This method expects the fragments contains a number. In case of unexpected contents, this method returns null or throws an exception depending on the strategy this object follows.

Parameters:
xParameter - not null.
Returns:
a real number, or null iff unexpected content has been read and this object follows a permissive strategy.
Throws:
InvalidInputException - iff unexpected content has been read and this object follows the XMCDAErrorsManager.ErrorManagement.THROW strategy.

readDouble

public Double readDouble(XValue xValue)
                  throws InvalidInputException

Retrieves the number embedded in the given fragment.

This method expects the fragments contains a number. In case of unexpected contents, this method returns null or throws an exception depending on the strategy this object follows.

Parameters:
xValue - not null.
Returns:
a real number, or null iff unexpected content has been read and this object follows a permissive strategy.
Throws:
InvalidInputException - iff unexpected content has been read and this object follows the XMCDAErrorsManager.ErrorManagement.THROW strategy.

readLabel

public String readLabel(XMethodParameters xMethodParameters,
                        String contextMessageIfEmpty)
                 throws InvalidInputException

Retrieves the label embedded in the given fragment.

This method expects the given fragment contains a unique non null label. In case of unexpected contents, this method returns null or throws an exception depending on the strategy this object follows.

Parameters:
xMethodParameters - not null.
contextMessageIfEmpty - if not null, is used to give a more useful error message about the context when the given fragment contains an empty collection.
Returns:
not empty; null iff unexpected content has been read and this object follows a permissive strategy.
Throws:
InvalidInputException - iff unexpected content has been read and this object follows the XMCDAErrorsManager.ErrorManagement.THROW strategy.

readLabel

public String readLabel(XParameter xParameter)
                 throws InvalidInputException

Retrieves the label embedded in the given fragment.

This method expects the given fragment contains a non null label. In case of unexpected contents, this method returns null or throws an exception depending on the strategy this object follows.

Parameters:
xParameter - not null.
Returns:
not empty; null iff unexpected content has been read and this object follows a permissive strategy.
Throws:
InvalidInputException - iff unexpected content has been read and this object follows the XMCDAErrorsManager.ErrorManagement.THROW strategy.

readLabel

public String readLabel(XValue xValue)
                 throws InvalidInputException

Retrieves the label embedded in the given fragment.

This method expects the given fragment contains a non null label. In case of unexpected contents, this method returns null or throws an exception depending on the strategy this object follows.

Parameters:
xValue - not null.
Returns:
not empty; null iff unexpected content has been read and this object follows a permissive strategy.
Throws:
InvalidInputException - iff unexpected content has been read and this object follows the XMCDAErrorsManager.ErrorManagement.THROW strategy.

writeAsMethodParameters

public XMethodParameters writeAsMethodParameters(double value)
Retrieves the given value as an XMCDA fragment.

Parameters:
value - the value to write.
Returns:
not null.

writeAsMethodParameters

public XMethodParameters writeAsMethodParameters(String value)
Retrieves the given value as an XMCDA fragment.

Parameters:
value - the value to write.
Returns:
not null.

writeAsParameter

public XParameter writeAsParameter(double value)
Retrieves the given value as an XMCDA fragment.

Parameters:
value - the value to write.
Returns:
not null.

writeAsParameter

public XParameter writeAsParameter(String value)
Retrieves the given value as an XMCDA fragment.

Parameters:
value - the value to write.
Returns:
not null.

writeMessages

public XMethodMessages writeMessages(Collection<String> messages)
Retrieves the given messages as an XMethodMessages fragment.

Parameters:
messages - not null.
Returns:
not null.

writeErrorMessages

public XMethodMessages writeErrorMessages(Collection<String> errorMessages)
Retrieves the given error messages as an XMethodMessages fragment.

Parameters:
errorMessages - not null.
Returns:
not null.

readMessages

public List<String> readMessages(XMethodMessages xMethodMessages)


Copyright © 2011. All Rights Reserved.