public class SingleValueJobInfo extends java.lang.Object implements JobInfo
JobInfo
. It aims to represent a
key-value pair.
Both functions getXML(String)
and
write(HttpServletResponse)
will return the following XML document:
<KEY>VALUE</KEY>
, where:
KEY
can be get with getName()
and can be
set only at creationVALUE
can be get with getValue()
and set
with setValue(String)
.Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
name
Name of the value stored inside this
JobInfo . |
protected java.lang.String |
value
Value stored inside this
JobInfo . |
protected java.lang.String |
xmlRepresentation
|
Constructor and Description |
---|
SingleValueJobInfo(java.lang.String name)
Build a
JobInfo representing a single value having the given
name. |
SingleValueJobInfo(java.lang.String name,
java.lang.String value)
Build a
JobInfo representing a single value having the given
name and initial value. |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Free/Discard any resource associated with this
JobInfo . |
java.lang.String |
getName()
Get the name of the represented value.
|
java.lang.String |
getValue()
Get the represented value.
|
java.lang.String |
getXML(java.lang.String newLinePrefix)
Get the XML representation of this
JobInfo . |
void |
setJob(UWSJob myJob)
Notify this
JobInfo that it is now owned by the given job. |
void |
setValue(java.lang.String value)
Set the value represented by this
JobInfo . |
void |
write(javax.servlet.http.HttpServletResponse response)
Write the content of this jobInfo as a complete HTTP response
when the URL
{uws-root}/{job-list}/{job-id}/jobInfo is
requested. |
protected java.lang.String name
JobInfo
.
Warning: By default, this name is not supposed to be changed after initialization of this class. That's why only a public getter function is provided.
protected java.lang.String value
JobInfo
.protected java.lang.String xmlRepresentation
JobInfo
, returned by
getXML(String)
and write(HttpServletResponse)
.
Note:
It has to be updated each time the value
is changed. So by
default, it is rebuilt by setValue(String)
.
public SingleValueJobInfo(java.lang.String name) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
JobInfo
representing a single value having the given
name.
Note 1: The name can not be changed after creation.
Note 2:
With this constructor, the represented value is NULL. To set a value,
you have to use the function setValue(String)
. An alternative
would be to use the constructor
SingleValueJobInfo(String, String)
so that setting immediately
the name and value.
name
- Name of the value to represent.java.lang.NullPointerException
- If the given name is NULL or an empty
string.java.lang.IllegalArgumentException
- If the given name is not a valid XML
node name according to the W3C (see
XMLSerializer.isValidXMLNodeName(String)
for more details).public SingleValueJobInfo(java.lang.String name, java.lang.String value) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
JobInfo
representing a single value having the given
name and initial value.
Note 1: The name can not be changed after creation.
Note 2:
The value can change after object creation with the function
setValue(String)
.
name
- Name of the value to represent. Can not be NULL or an
empty string, and must be a valid XML node name.value
- Value to represent. May be NULL.java.lang.NullPointerException
- If the given name is NULL or an empty
string.java.lang.IllegalArgumentException
- If the given name is not a valid XML
node name according to the W3C (see
XMLSerializer.isValidXMLNodeName(String)
for more details).public java.lang.String getName()
public java.lang.String getValue()
public void setValue(java.lang.String value)
JobInfo
.value
- The new value to represent. Can be NULL.public java.lang.String getXML(java.lang.String newLinePrefix)
JobInfo
JobInfo
.
Note 1: This function does not force the jobInfo to be in XML but asks for a piece of XML document to append to the XML representation of a job and representing this jobInfo. It may be a full serialization of it or merely a link (see Xlink) toward a complete document (XML or not).
Note 2: The returned piece of XML can refer to the following XML schemas:
If more namespaces are needed they should be specified directly
at the root of the XML returned by this function (if possible
with a valid xsi:schemaLocation
). An alternative
would be to extend XMLSerializer
in order to append
the needed namespaces to the root XML node of any formatted XML
documents.
getXML
in interface JobInfo
newLinePrefix
- Characters (generally white-spaces) that should
prefix all new line of the returned piece of
XML. New line characters should also be
included in this string ; if not, the
returned XML should be on a single line.
This parameter may be NULL.public void write(javax.servlet.http.HttpServletResponse response) throws java.io.IOException, UWSException
JobInfo
{uws-root}/{job-list}/{job-id}/jobInfo
is
requested.
Important: At least the Content-Type, the Content-Length and Character-Encoding should be set in addition of the response content.
Note: If formatted into XML, the root node of the returned document may be the UWS node "jobInfo" or not, depending on your desired implementation. Since the UWS standard does not specify any way to retrieve individually a jobInfo, this part is left here totally free to the developer will.
write
in interface JobInfo
response
- HTTP response in which the jobInfo content must be
written.java.io.IOException
- If there is any error while writing the jobInfo
content.UWSException
- If there is any error while formating the jobInfo
content.public void setJob(UWSJob myJob)
JobInfo
JobInfo
that it is now owned by the given job.public void destroy() throws UWSException
JobInfo
JobInfo
.
Note: This function should be called only at job destruction. It particularly aims to delete any file containing the full content of this JobInfo, but it should also be used for any other kind of associated resource.
destroy
in interface JobInfo
UWSException
- If all associated resources can not be freed.