uws.job.serializer
Class XMLSerializer

java.lang.Object
  extended by uws.job.serializer.UWSSerializer
      extended by uws.job.serializer.XMLSerializer
All Implemented Interfaces:
java.io.Serializable

public class XMLSerializer
extends UWSSerializer

Lets serializing any UWS resource in XML.

Version:
01/2011
Author:
Grégory Mantelet (CDS)
See Also:
Serialized Form

Field Summary
protected  java.lang.String tabPrefix
          Tab to add just before each next XML node.
protected  java.lang.String xsltPath
          The path of the XSLT style-sheet.
 
Fields inherited from class uws.job.serializer.UWSSerializer
MIME_TYPE_HTML, MIME_TYPE_JSON, MIME_TYPE_TEXT, MIME_TYPE_XML
 
Constructor Summary
XMLSerializer()
          Builds a XML serializer.
XMLSerializer(java.lang.String xsltPath)
          Builds a XML serializer with a XSLT link.
 
Method Summary
 java.lang.String getAdditionalParameter(java.lang.String paramName, java.lang.String paramValue, boolean root)
          Serializes the specified parameter.
 java.lang.String getAdditionalParameters(AbstractJob job, boolean root)
          Serializes the parameters of the given job.
 java.lang.String getDestructionTime(AbstractJob job, boolean root)
          Serializes the destruction time of the given job.
 java.lang.String getEndTime(AbstractJob job, boolean root)
          Serializes the end time of the given job.
 java.lang.String getErrorSummary(ErrorSummary error, boolean root)
          Serializes the given error summary.
 java.lang.String getExecutionDuration(AbstractJob job, boolean root)
          Serializes the execution duration of the given job.
 java.lang.String getHeader()
          Gets the XML file header (xml version, encoding and the xslt style-sheet link if any).
 java.lang.String getJob(AbstractJob job, boolean root)
          Serializes the whole given job.
 java.lang.String getJobID(AbstractJob job, boolean root)
          Serializes the ID of the given job.
 java.lang.String getJobList(JobList<? extends AbstractJob> jobsList, java.lang.String ownerId, boolean root)
          Serializes the given jobs list.
 java.lang.String getMimeType()
          Gets the MIME type of the serialization format used by this serializer.
 java.lang.String getOwnerID(AbstractJob job, boolean root)
          Serializes the owner ID of the given job.
 java.lang.String getPhase(AbstractJob job, boolean root)
          Serializes the phase of the given job.
 java.lang.String getQuote(AbstractJob job, boolean root)
          Serializes the quote of the given job.
 java.lang.String getResult(Result result, boolean root)
          Serializes the given result.
 java.lang.String getResults(AbstractJob job, boolean root)
          Serializes the results of the given job.
 java.lang.String getRunID(AbstractJob job, boolean root)
          Serializes the run ID of the given job.
 java.lang.String getStartTime(AbstractJob job, boolean root)
          Serializes the start time of the given job.
 java.lang.String getUWS(AbstractUWS<? extends JobList<? extends AbstractJob>,? extends AbstractJob> uws, java.lang.String userId)
          Serializes the given UWS for the specified user.
 java.lang.String getUWSNamespace()
          Gets all UWS namespaces declarations needed for an XML representation of a UWS object.
protected  java.lang.String getUWSNamespace(boolean root)
          Gets the node attributes which declare the UWS namespace.
 java.lang.String getXSLTPath()
          Gets the path/URL of the XSLT style-sheet to use.
 void setXSLTPath(java.lang.String path)
          Sets the path/URL of the XSLT style-sheet to use.
 
Methods inherited from class uws.job.serializer.UWSSerializer
getJob, getJobList, getUWS, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tabPrefix

protected java.lang.String tabPrefix
Tab to add just before each next XML node.


xsltPath

protected java.lang.String xsltPath
The path of the XSLT style-sheet.

Constructor Detail

XMLSerializer

public XMLSerializer()
Builds a XML serializer.


XMLSerializer

public XMLSerializer(java.lang.String xsltPath)
Builds a XML serializer with a XSLT link.

Parameters:
xsltPath - Path of a XSLT style-sheet.
Method Detail

getXSLTPath

public final java.lang.String getXSLTPath()
Gets the path/URL of the XSLT style-sheet to use.

Returns:
XSLT path/url.

setXSLTPath

public final void setXSLTPath(java.lang.String path)
Sets the path/URL of the XSLT style-sheet to use.

Parameters:
path - The new XSLT path/URL.

getHeader

public java.lang.String getHeader()

Gets the XML file header (xml version, encoding and the xslt style-sheet link if any).

It is always called by the implementation of the UWSSerializer functions if their boolean parameter (root) is true.

Returns:
The XML file header.

getUWSNamespace

public java.lang.String getUWSNamespace()
Gets all UWS namespaces declarations needed for an XML representation of a UWS object.

Returns:
The UWS namespaces:
(i.e. = "xmlns:uws=[...] xmlns:xlink=[...] xmlns:xs=[...] xmlns:xsi=[...]").

getUWSNamespace

protected final java.lang.String getUWSNamespace(boolean root)
Gets the node attributes which declare the UWS namespace.

Parameters:
root - false if the attribute to serialize will be included in a top level serialization (for a job attribute: job), true otherwise.
Returns:
"" if root is false, " "+UWSNamespace otherwise.
See Also:
getUWSNamespace()

getMimeType

public final java.lang.String getMimeType()
Description copied from class: UWSSerializer
Gets the MIME type of the serialization format used by this serializer.

Specified by:
getMimeType in class UWSSerializer
Returns:
The corresponding MIME type.

getUWS

public java.lang.String getUWS(AbstractUWS<? extends JobList<? extends AbstractJob>,? extends AbstractJob> uws,
                               java.lang.String userId)
Description copied from class: UWSSerializer
Serializes the given UWS for the specified user.

Specified by:
getUWS in class UWSSerializer
Parameters:
uws - The UWS to serialize.
userId - The ID of the user which has asked the serialization of the given UWS.
Returns:
The serialization of the UWS.

getJobList

public java.lang.String getJobList(JobList<? extends AbstractJob> jobsList,
                                   java.lang.String ownerId,
                                   boolean root)
                            throws UWSException
Description copied from class: UWSSerializer
Serializes the given jobs list.

Specified by:
getJobList in class UWSSerializer
Parameters:
jobsList - The jobs list to serialize.
ownerId - The ID of the user which has asked the serialization of the given jobs list.
root - false if the jobs list to serialize will be included in a top level serialization (for a jobs list: uws), true otherwise.
Returns:
The serialization of the given jobs list.
Throws:
UWSException - If there is an error during the serialization.

getJob

public java.lang.String getJob(AbstractJob job,
                               boolean root)
Description copied from class: UWSSerializer
Serializes the whole given job.

Specified by:
getJob in class UWSSerializer
Parameters:
job - The job to serialize.
root - false if the job to serialize will be included in a top level serialization (for a job: jobList), true otherwise.
Returns:
The serialization of the given job.

getJobID

public java.lang.String getJobID(AbstractJob job,
                                 boolean root)
Description copied from class: UWSSerializer
Serializes the ID of the given job.

Specified by:
getJobID in class UWSSerializer
Parameters:
job - The job whose the ID must be serialized.
root - false if the job ID to serialize will be included in a top level serialization (for a job ID: job), true otherwise.
Returns:
The serialization of the job ID.

getRunID

public java.lang.String getRunID(AbstractJob job,
                                 boolean root)
Description copied from class: UWSSerializer
Serializes the run ID of the given job.

Specified by:
getRunID in class UWSSerializer
Parameters:
job - The job whose the run ID must be serialized.
root - false if the run ID to serialize will be included in a top level serialization (for a run ID: job), true otherwise.
Returns:
The serialization of the run ID.

getOwnerID

public java.lang.String getOwnerID(AbstractJob job,
                                   boolean root)
Description copied from class: UWSSerializer
Serializes the owner ID of the given job.

Specified by:
getOwnerID in class UWSSerializer
Parameters:
job - The job whose the owner ID must be serialized.
root - false if the owner ID to serialize will be included in a top level serialization (for a owner ID: job), true otherwise.
Returns:
The serialization of the owner ID.

getPhase

public java.lang.String getPhase(AbstractJob job,
                                 boolean root)
Description copied from class: UWSSerializer
Serializes the phase of the given job.

Specified by:
getPhase in class UWSSerializer
Parameters:
job - The job whose the phase must be serialized.
root - false if the phase to serialize will be included in a top level serialization (for a phase: job), true otherwise.
Returns:
The serialization of the phase.

getQuote

public java.lang.String getQuote(AbstractJob job,
                                 boolean root)
Description copied from class: UWSSerializer
Serializes the quote of the given job.

Specified by:
getQuote in class UWSSerializer
Parameters:
job - The job whose the quote must be serialized.
root - false if the quote to serialize will be included in a top level serialization (for a quote: job), true otherwise.
Returns:
The serialization of the quote.

getStartTime

public java.lang.String getStartTime(AbstractJob job,
                                     boolean root)
Description copied from class: UWSSerializer
Serializes the start time of the given job.

Specified by:
getStartTime in class UWSSerializer
Parameters:
job - The job whose the start time must be serialized.
root - false if the start time to serialize will be included in a top level serialization (for a start time: job), true otherwise.
Returns:
The serialization of the start time.

getEndTime

public java.lang.String getEndTime(AbstractJob job,
                                   boolean root)
Description copied from class: UWSSerializer
Serializes the end time of the given job.

Specified by:
getEndTime in class UWSSerializer
Parameters:
job - The job whose the end time must be serialized.
root - false if the end time to serialize will be included in a top level serialization (for a end time: job), true otherwise.
Returns:
The serialization of the end time.

getDestructionTime

public java.lang.String getDestructionTime(AbstractJob job,
                                           boolean root)
Description copied from class: UWSSerializer
Serializes the destruction time of the given job.

Specified by:
getDestructionTime in class UWSSerializer
Parameters:
job - The job whose the destruction time must be serialized.
root - false if the destruction time to serialize will be included in a top level serialization (for a destruction time: job), true otherwise.
Returns:
The serialization of the destruction time.

getExecutionDuration

public java.lang.String getExecutionDuration(AbstractJob job,
                                             boolean root)
Description copied from class: UWSSerializer
Serializes the execution duration of the given job.

Specified by:
getExecutionDuration in class UWSSerializer
Parameters:
job - The job whose the execution duration must be serialized.
root - false if the execution duration to serialize will be included in a top level serialization (for a execution duration: job), true otherwise.
Returns:
The serialization of the execution duration.

getErrorSummary

public java.lang.String getErrorSummary(ErrorSummary error,
                                        boolean root)
Description copied from class: UWSSerializer
Serializes the given error summary.

Specified by:
getErrorSummary in class UWSSerializer
Parameters:
error - The error to serialize.
root - false if the error summary to serialize will be included in a top level serialization (for an error summary: job), true otherwise.
Returns:
The serialization of the error summary.

getAdditionalParameters

public java.lang.String getAdditionalParameters(AbstractJob job,
                                                boolean root)
Description copied from class: UWSSerializer
Serializes the parameters of the given job.

Specified by:
getAdditionalParameters in class UWSSerializer
Parameters:
job - The job whose the parameters must be serialized.
root - false if the parameters list to serialize will be included in a top level serialization (for a list of parameters: job), true otherwise.
Returns:
The serialization of the parameters.

getAdditionalParameter

public java.lang.String getAdditionalParameter(java.lang.String paramName,
                                               java.lang.String paramValue,
                                               boolean root)
Description copied from class: UWSSerializer
Serializes the specified parameter.

Specified by:
getAdditionalParameter in class UWSSerializer
Parameters:
paramName - The name of the parameter to serialize.
paramValue - The value of the parameter to serialize.
root - false if the parameter to serialize will be included in a top level serialization (for a parameter: parameters), true otherwise.
Returns:
The serialization of the parameter.

getResults

public java.lang.String getResults(AbstractJob job,
                                   boolean root)
Description copied from class: UWSSerializer
Serializes the results of the given job.

Specified by:
getResults in class UWSSerializer
Parameters:
job - The job whose the results must be serialized.
root - false if the results list to serialize will be included in a top level serialization (for a list of results: job), true otherwise.
Returns:
The serialization of the results.

getResult

public java.lang.String getResult(Result result,
                                  boolean root)
Description copied from class: UWSSerializer
Serializes the given result.

Specified by:
getResult in class UWSSerializer
Parameters:
result - The result to serialize.
root - false if the result to serialize will be included in a top level serialization (for a result: results), true otherwise.
Returns:
The serialization of the result.