uws.job.serializer
Class UWSSerializer

java.lang.Object
  extended by uws.job.serializer.UWSSerializer
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
JSONSerializer, XMLSerializer

public abstract class UWSSerializer
extends java.lang.Object
implements java.io.Serializable

Lets returning any UWS resource in a given format.

By default two formats are already implemented:

Version:
12/2010
Author:
Grégory Mantelet (CDS)
See Also:
XMLSerializer, JSONSerializer, Serialized Form

Field Summary
static java.lang.String MIME_TYPE_HTML
          MIME type for HTML: text/html
static java.lang.String MIME_TYPE_JSON
          MIME type for JSON: application/json
static java.lang.String MIME_TYPE_TEXT
          MIME type for TEXT: text/plain
static java.lang.String MIME_TYPE_XML
          MIME type for XML: application/xml
 
Constructor Summary
UWSSerializer()
           
 
Method Summary
abstract  java.lang.String getAdditionalParameter(java.lang.String paramName, java.lang.String paramValue, boolean root)
          Serializes the specified parameter.
abstract  java.lang.String getAdditionalParameters(AbstractJob job, boolean root)
          Serializes the parameters of the given job.
abstract  java.lang.String getDestructionTime(AbstractJob job, boolean root)
          Serializes the destruction time of the given job.
abstract  java.lang.String getEndTime(AbstractJob job, boolean root)
          Serializes the end time of the given job.
abstract  java.lang.String getErrorSummary(ErrorSummary error, boolean root)
          Serializes the given error summary.
abstract  java.lang.String getExecutionDuration(AbstractJob job, boolean root)
          Serializes the execution duration of the given job.
abstract  java.lang.String getJob(AbstractJob job, boolean root)
          Serializes the whole given job.
 java.lang.String getJob(AbstractJob job, java.lang.String[] attributes, boolean root)
          Serializes the given parameter of the given job or serializes the whole job if the given attributes array is empty or null.
abstract  java.lang.String getJobID(AbstractJob job, boolean root)
          Serializes the ID of the given job.
 java.lang.String getJobList(JobList<? extends AbstractJob> jobsList, boolean root)
          Serializes the given jobs list.
abstract  java.lang.String getJobList(JobList<? extends AbstractJob> jobsList, java.lang.String ownerId, boolean root)
          Serializes the given jobs list.
abstract  java.lang.String getMimeType()
          Gets the MIME type of the serialization format used by this serializer.
abstract  java.lang.String getOwnerID(AbstractJob job, boolean root)
          Serializes the owner ID of the given job.
abstract  java.lang.String getPhase(AbstractJob job, boolean root)
          Serializes the phase of the given job.
abstract  java.lang.String getQuote(AbstractJob job, boolean root)
          Serializes the quote of the given job.
abstract  java.lang.String getResult(Result result, boolean root)
          Serializes the given result.
abstract  java.lang.String getResults(AbstractJob job, boolean root)
          Serializes the results of the given job.
abstract  java.lang.String getRunID(AbstractJob job, boolean root)
          Serializes the run ID of the given job.
abstract  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)
          Serializes the given UWS.
abstract  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 toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIME_TYPE_XML

public static final java.lang.String MIME_TYPE_XML
MIME type for XML: application/xml

See Also:
Constant Field Values

MIME_TYPE_JSON

public static final java.lang.String MIME_TYPE_JSON
MIME type for JSON: application/json

See Also:
Constant Field Values

MIME_TYPE_TEXT

public static final java.lang.String MIME_TYPE_TEXT
MIME type for TEXT: text/plain

See Also:
Constant Field Values

MIME_TYPE_HTML

public static final java.lang.String MIME_TYPE_HTML
MIME type for HTML: text/html

See Also:
Constant Field Values
Constructor Detail

UWSSerializer

public UWSSerializer()
Method Detail

getJob

public java.lang.String getJob(AbstractJob job,
                               java.lang.String[] attributes,
                               boolean root)
                        throws UWSException
Serializes the given parameter of the given job or serializes the whole job if the given attributes array is empty or null.

Parameters:
job - The job whose the attribute must be serialized.
attributes - All the given attributes (may be null or empty).
root - false if the attribute to serialize will be included in a top level serialization (for a job attribute: job), true otherwise.
Returns:
The serialization of the given attribute or the serialization of the whole job if the given attributes array is empty or null.
Throws:
UWSException - If the specified attribute/parameter/result does not exist.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getMimeType

public abstract java.lang.String getMimeType()
Gets the MIME type of the serialization format used by this serializer.

Returns:
The corresponding MIME type.

getUWS

public java.lang.String getUWS(AbstractUWS<? extends JobList<? extends AbstractJob>,? extends AbstractJob> uws)
                        throws UWSException
Serializes the given UWS.

Parameters:
uws - The UWS to serialize.
Returns:
The serialization of the given UWS.
Throws:
UWSException - If there is an error during the serialization.
See Also:
getUWS(AbstractUWS, String)

getUWS

public abstract java.lang.String getUWS(AbstractUWS<? extends JobList<? extends AbstractJob>,? extends AbstractJob> uws,
                                        java.lang.String userId)
                                 throws UWSException
Serializes the given UWS for the specified user.

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.
Throws:
UWSException - If there is an error during the serialization.

getJobList

public java.lang.String getJobList(JobList<? extends AbstractJob> jobsList,
                                   boolean root)
                            throws UWSException
Serializes the given jobs list.

Parameters:
jobsList - The jobs list to serialize.
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.

getJobList

public abstract java.lang.String getJobList(JobList<? extends AbstractJob> jobsList,
                                            java.lang.String ownerId,
                                            boolean root)
                                     throws UWSException
Serializes the given jobs list.

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 abstract java.lang.String getJob(AbstractJob job,
                                        boolean root)
                                 throws UWSException
Serializes the whole given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getJobID

public abstract java.lang.String getJobID(AbstractJob job,
                                          boolean root)
                                   throws UWSException
Serializes the ID of the given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getRunID

public abstract java.lang.String getRunID(AbstractJob job,
                                          boolean root)
                                   throws UWSException
Serializes the run ID of the given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getOwnerID

public abstract java.lang.String getOwnerID(AbstractJob job,
                                            boolean root)
                                     throws UWSException
Serializes the owner ID of the given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getPhase

public abstract java.lang.String getPhase(AbstractJob job,
                                          boolean root)
                                   throws UWSException
Serializes the phase of the given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getQuote

public abstract java.lang.String getQuote(AbstractJob job,
                                          boolean root)
                                   throws UWSException
Serializes the quote of the given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getStartTime

public abstract java.lang.String getStartTime(AbstractJob job,
                                              boolean root)
                                       throws UWSException
Serializes the start time of the given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getEndTime

public abstract java.lang.String getEndTime(AbstractJob job,
                                            boolean root)
                                     throws UWSException
Serializes the end time of the given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getExecutionDuration

public abstract java.lang.String getExecutionDuration(AbstractJob job,
                                                      boolean root)
                                               throws UWSException
Serializes the execution duration of the given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getDestructionTime

public abstract java.lang.String getDestructionTime(AbstractJob job,
                                                    boolean root)
                                             throws UWSException
Serializes the destruction time of the given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getErrorSummary

public abstract java.lang.String getErrorSummary(ErrorSummary error,
                                                 boolean root)
                                          throws UWSException
Serializes the given error summary.

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.
Throws:
UWSException - If there is an error during the serialization.

getResults

public abstract java.lang.String getResults(AbstractJob job,
                                            boolean root)
                                     throws UWSException
Serializes the results of the given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getResult

public abstract java.lang.String getResult(Result result,
                                           boolean root)
                                    throws UWSException
Serializes the given result.

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.
Throws:
UWSException - If there is an error during the serialization.

getAdditionalParameters

public abstract java.lang.String getAdditionalParameters(AbstractJob job,
                                                         boolean root)
                                                  throws UWSException
Serializes the parameters of the given job.

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.
Throws:
UWSException - If there is an error during the serialization.

getAdditionalParameter

public abstract java.lang.String getAdditionalParameter(java.lang.String paramName,
                                                        java.lang.String paramValue,
                                                        boolean root)
                                                 throws UWSException
Serializes the specified parameter.

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.
Throws:
UWSException - If there is an error during the serialization.