org.ws4d.java.util
Class ParameterUtil

java.lang.Object
  extended by org.ws4d.java.util.ParameterUtil

public class ParameterUtil
extends java.lang.Object

Utility class for easier parameter handling.

This class implements methods for parameters based on the default implementation inside the framework. It allows to handle AttachmentValue and StringValue as before.


Constructor Summary
ParameterUtil()
           
 
Method Summary
static IncomingAttachment getAttachment(ParameterValue wVal, java.lang.String path)
          Returns the value for a AttachmentValue based parameter.
static java.lang.String getAttachmentFilename(ParameterValue wVal)
          Return the filename of the attachment.
static List getAttachments(ParameterValue wVal)
          Returns a list of attachments from the given structure.
static java.lang.String getAttributeValue(ParameterValue wVal, java.lang.String path, java.lang.String attribute)
          Returns the value of the attribute.
static QName getQName(ParameterValue wVal, java.lang.String path)
          Returns the value for a QNameValue based parameter.
static java.lang.String getString(ParameterValue wVal, java.lang.String path)
          Returns the value for a StringValue based parameter.
static boolean hasAttachment(ParameterValue pv)
          Returns true if any of the values (even the inner-elements) is an attachment, false otherwise.
static void removeAttachment(ParameterValue wVal)
          Removes attachment from a given parameter.
static void setAttachment(ParameterValue wVal, java.lang.String filename)
          Creates new FileAttachment with the given filename.
static void setAttachment(ParameterValue wVal, java.lang.String path, Attachment attachment)
          Sets the value for a AttachmentValue based parameter.
static void setAttachmentScope(ParameterValue wVal, ContextID context)
          Sets the attachments scope for the given parameter and his children.
static void setAttributeValue(ParameterValue wVal, java.lang.String path, java.lang.String attribute, java.lang.String value)
           
static void setQName(ParameterValue wVal, java.lang.String path, QName value)
          Sets the value for a QNameValue based parameter.
static void setString(ParameterValue wVal, java.lang.String path, java.lang.String value)
          Sets the value for a StringValue based parameter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterUtil

public ParameterUtil()
Method Detail

getAttributeValue

public static java.lang.String getAttributeValue(ParameterValue wVal,
                                                 java.lang.String path,
                                                 java.lang.String attribute)
Returns the value of the attribute.

Parameters:
wVal - the parameter which should be used to get the attributes from, or should be used as parent.
path - the path which should be used to get the child of the given parameter.
attribute - the attribute.
Returns:
the attribute value.

setAttributeValue

public static void setAttributeValue(ParameterValue wVal,
                                     java.lang.String path,
                                     java.lang.String attribute,
                                     java.lang.String value)
Parameters:
wVal - the parameter which should be used to get the attributes from, or should be used as parent.
path - the path which should be used to get the child of the given parameter.
attribute - the attribute.
value - the attribute value.

setString

public static void setString(ParameterValue wVal,
                             java.lang.String path,
                             java.lang.String value)
Sets the value for a StringValue based parameter.

Parameters:
wVal - the parameter from type StringValue, or the parent of it.
path - the path which allows to address a child of the given parameter.
value - the value.

getString

public static java.lang.String getString(ParameterValue wVal,
                                         java.lang.String path)
Returns the value for a StringValue based parameter.

Parameters:
wVal - the parameter from type StringValue, or the parent of it.
path - the path which allows to address a child of the given parameter.
Returns:
the value.

hasAttachment

public static boolean hasAttachment(ParameterValue pv)
Returns true if any of the values (even the inner-elements) is an attachment, false otherwise.

Parameters:
pv - the parameter which should be checked for attachments.
Returns:
true if any of the values (even the inner-elements) is an attachment, false otherwise.

setAttachmentScope

public static void setAttachmentScope(ParameterValue wVal,
                                      ContextID context)
Sets the attachments scope for the given parameter and his children.

Parameters:
wVal - the parameter which should be used to set the scope
context - the MIME context identifier.

getAttachments

public static List getAttachments(ParameterValue wVal)
Returns a list of attachments from the given structure. Every attachment used inside this structure will be in this list.

Parameters:
wVal - the parameter which should be used to collect the attachments.
Returns:
the list of attachments.

getAttachmentFilename

public static java.lang.String getAttachmentFilename(ParameterValue wVal)
Return the filename of the attachment. (Only for FileAttachment)

Parameters:
wVal - the parameter which should be used to determinate the filename.
Returns:
the filename if attachment is FileAttachment else null

removeAttachment

public static void removeAttachment(ParameterValue wVal)
Removes attachment from a given parameter.

Parameters:
wVal - the parameter which should get the attachment removed.

setAttachment

public static void setAttachment(ParameterValue wVal,
                                 java.lang.String filename)
Creates new FileAttachment with the given filename.

Parameters:
wVal - the parameter which should be used to set the attachment to.
filename - filename of the attachment.

getAttachment

public static IncomingAttachment getAttachment(ParameterValue wVal,
                                               java.lang.String path)
Returns the value for a AttachmentValue based parameter.

Parameters:
wVal - the parameter from type AttachmentValue, or the parent of it.
path - the path which allows to address a child of the given parameter.
Returns:
the value.

setAttachment

public static void setAttachment(ParameterValue wVal,
                                 java.lang.String path,
                                 Attachment attachment)
Sets the value for a AttachmentValue based parameter.

Parameters:
wVal - the parameter from type AttachmentValue, or the parent of it.
path - the path which allows to address a child of the given parameter.
value - the value.

setQName

public static void setQName(ParameterValue wVal,
                            java.lang.String path,
                            QName value)
Sets the value for a QNameValue based parameter.

Parameters:
wVal - the parameter from type QNameValue, or the parent of it.
path - the path which allows to address a child of the given parameter.
value - the value.

getQName

public static QName getQName(ParameterValue wVal,
                             java.lang.String path)
Returns the value for a QNameValue based parameter.

Parameters:
wVal - the parameter from type QNameValue, or the parent of it.
path - the path which allows to address a child of the given parameter.
Returns:
the value.