public class XMLSerializer extends UWSSerializer
Modifier and Type | Field and Description |
---|---|
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.
|
MIME_TYPE_HTML, MIME_TYPE_JSON, MIME_TYPE_TEXT, MIME_TYPE_XML
Constructor and Description |
---|
XMLSerializer()
Builds a XML serializer.
|
XMLSerializer(java.lang.String xsltPath)
Builds a XML serializer with a XSLT link.
|
Modifier and Type | Method and Description |
---|---|
static char |
ensureLegalXml(char c)
Returns a legal XML character corresponding to an input character.
|
static java.lang.String |
escapeURL(java.lang.String url)
Escapes the given URL.
|
static java.lang.String |
escapeXMLAttribute(java.lang.String value)
Escapes the given value of an XML attribute.
|
static java.lang.String |
escapeXMLData(java.lang.String data)
Escapes the content of a node (data between the open and the close tags).
|
java.lang.String |
getAdditionalParameter(java.lang.String paramName,
java.lang.Object paramValue,
boolean root)
Serializes the specified parameter.
|
java.lang.String |
getAdditionalParameters(UWSJob job,
boolean root)
Serializes the parameters of the given job.
|
java.lang.String |
getCreationTime(UWSJob job,
boolean root)
Serializes the creation date/time of the given job.
|
java.lang.String |
getDestructionTime(UWSJob job,
boolean root)
Serializes the destruction time of the given job.
|
java.lang.String |
getEndTime(UWSJob 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(UWSJob 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(UWSJob job,
boolean root)
Serializes the whole given job.
|
java.lang.String |
getJobID(UWSJob job,
boolean root)
Serializes the ID of the given job.
|
java.lang.String |
getJobInfo(UWSJob job)
Serialize into XML the
JobInfo of the given job, if any. |
java.lang.String |
getJobList(JobList jobsList,
JobOwner owner,
JobListRefiner listRefiner,
boolean root)
Serializes the given jobs list, by filtering using user-specified
filters.
|
java.lang.String |
getJobRef(UWSJob job,
UWSUrl jobsListUrl)
Serializes just a reference on the given job.
|
java.lang.String |
getMimeType()
Gets the MIME type of the serialization format used by this serializer.
|
java.lang.String |
getOwnerID(UWSJob job,
boolean root)
Serializes the owner ID of the given job.
|
java.lang.String |
getPhase(UWSJob job,
boolean root)
Serializes the phase of the given job.
|
java.lang.String |
getQuote(UWSJob 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(UWSJob job,
boolean root)
Serializes the results of the given job.
|
java.lang.String |
getRunID(UWSJob job,
boolean root)
Serializes the run ID of the given job.
|
java.lang.String |
getStartTime(UWSJob job,
boolean root)
Serializes the start time of the given job.
|
java.lang.String |
getUWS(UWS uws,
JobOwner user)
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.
|
static boolean |
isValidXMLNodeName(java.lang.String nodeName)
Determine whether the given name is a valid XML node name
according to the W3C (XML 1.1).
|
void |
setXSLTPath(java.lang.String path)
Sets the path/URL of the XSLT style-sheet to use.
|
getJob, getJobList, getJobList, getUWS, toString
protected java.lang.String tabPrefix
protected java.lang.String xsltPath
public XMLSerializer()
public XMLSerializer(java.lang.String xsltPath)
xsltPath
- Path of a XSLT style-sheet.public final java.lang.String getXSLTPath()
public final void setXSLTPath(java.lang.String path)
path
- The new XSLT path/URL.public java.lang.String getHeader()
It is always called by the implementation of the UWSSerializer functions if their boolean parameter (root) is true.
public java.lang.String getUWSNamespace()
protected final java.lang.String getUWSNamespace(boolean root)
root
- false if the attribute to serialize will be included
in a top level serialization (for a job attribute: job),
true otherwise.getUWSNamespace()
public final java.lang.String getMimeType()
UWSSerializer
getMimeType
in class UWSSerializer
public java.lang.String getUWS(UWS uws, JobOwner user)
UWSSerializer
getUWS
in class UWSSerializer
uws
- The UWS to serialize.user
- The user which has asked the serialization of the given UWS.public java.lang.String getJobList(JobList jobsList, JobOwner owner, JobListRefiner listRefiner, boolean root) throws java.lang.Exception
UWSSerializer
getJobList
in class UWSSerializer
jobsList
- The jobs list to serialize.owner
- The user which has asked the serialization of the
given jobs list. If NULL, all anonymous jobs are
displayed.listRefiner
- Represent all the specified job filters to apply ;
only the job that pass through this filter should be
displayed. If NULL, all jobs are displayed.root
- false
if the jobs list to serialize
will be included in a top level serialization (for a
jobs list: uws),
true
otherwise.java.lang.Exception
- If there is an error during the serialization.public java.lang.String getJob(UWSJob job, boolean root) throws UWSException
UWSSerializer
getJob
in class UWSSerializer
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.UWSException
public java.lang.String getJobRef(UWSJob job, UWSUrl jobsListUrl)
UWSSerializer
getJobRef
in class UWSSerializer
job
- The job to reference.jobsListUrl
- URL to the jobs lists which contains the given job.public java.lang.String getJobID(UWSJob job, boolean root)
UWSSerializer
getJobID
in class UWSSerializer
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.public java.lang.String getRunID(UWSJob job, boolean root)
UWSSerializer
getRunID
in class UWSSerializer
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.public java.lang.String getOwnerID(UWSJob job, boolean root)
UWSSerializer
getOwnerID
in class UWSSerializer
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.public java.lang.String getPhase(UWSJob job, boolean root)
UWSSerializer
getPhase
in class UWSSerializer
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.public java.lang.String getQuote(UWSJob job, boolean root)
UWSSerializer
Warning!
UWSJob.getQuote()
is a long, BUT the UWS standard explicitly
requires a quote as an ISO-8601 date (cf section "2.2.1. Resources and
URIs").
This function MUST return a quote only when the job is
started/finished and MUST add the quote duration to the startTime and
format it as an ISO-8601 date.
getQuote
in class UWSSerializer
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.public java.lang.String getCreationTime(UWSJob job, boolean root)
UWSSerializer
getCreationTime
in class UWSSerializer
job
- The job whose the creation date/time must be serialized.root
- false if the creation time to serialize will be
included in a top level serialization (for a creation time:
job), true otherwise.public java.lang.String getStartTime(UWSJob job, boolean root)
UWSSerializer
getStartTime
in class UWSSerializer
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.public java.lang.String getEndTime(UWSJob job, boolean root)
UWSSerializer
getEndTime
in class UWSSerializer
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.public java.lang.String getDestructionTime(UWSJob job, boolean root)
UWSSerializer
getDestructionTime
in class UWSSerializer
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.public java.lang.String getExecutionDuration(UWSJob job, boolean root)
UWSSerializer
getExecutionDuration
in class UWSSerializer
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.public java.lang.String getErrorSummary(ErrorSummary error, boolean root)
UWSSerializer
getErrorSummary
in class UWSSerializer
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.public java.lang.String getAdditionalParameters(UWSJob job, boolean root)
UWSSerializer
getAdditionalParameters
in class UWSSerializer
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.public java.lang.String getAdditionalParameter(java.lang.String paramName, java.lang.Object paramValue, boolean root)
UWSSerializer
getAdditionalParameter
in class UWSSerializer
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.public java.lang.String getResults(UWSJob job, boolean root)
UWSSerializer
getResults
in class UWSSerializer
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.public java.lang.String getResult(Result result, boolean root)
UWSSerializer
getResult
in class UWSSerializer
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.public java.lang.String getJobInfo(UWSJob job) throws UWSException
JobInfo
of the given job, if any.
Important note:
By default, this function wrap the XML content returned by
JobInfo.getXML(String)
inside an XML node "jobInfo".
To change this behavior, you should overwrite this function.
job
- The job whose the jobInfo must be serialized into XML.UWSException
public static java.lang.String escapeXMLData(java.lang.String data)
data
- Data to escape.public static java.lang.String escapeXMLAttribute(java.lang.String value)
value
- Value of an XML attribute.public static java.lang.String escapeURL(java.lang.String url)
url
- URL to escape.URLEncoder
,
escapeXMLAttribute(String)
public static char ensureLegalXml(char c)
Returns a legal XML character corresponding to an input character. Certain characters are simply illegal in XML (regardless of encoding). If the input character is legal in XML, it is returned; otherwise some other weird but legal character (currently the inverted question mark, "¿") is returned instead.
Note: copy of the STILTS VOSerializer.ensureLegalXml(char) function.
c
- input characterc
if possiblepublic static boolean isValidXMLNodeName(java.lang.String nodeName)
Note:
In addition of validating the given name against the regular expression
provided by the W3C (see XML_NODE_NAME_REGEX
), this function
ensures the given name does not start with "XML" according to the
following W3C note:
https://www.w3.org/TR/2006/REC-xml11-20060816/#dt-name
nodeName
- XML node name to test.true
if the given node name is valid,
false
otherwise.