|
Version: 1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.biomoby.shared.parser.MobyPackage
public class MobyPackage
This is the main container for Biomoby data once they are extracted from an XML format. It represents the package either sent from a client to a Biomoby service, or vice-versa. It also includes methods for parsing data from XML and for creating data back into XML.
Constructor Summary | |
---|---|
MobyPackage()
Default constructor. |
|
MobyPackage(MobyObject mObj,
String articleName)
Constructing a simplest MobyPackage - with one MobyObject. |
Method Summary | |
---|---|
void |
addException(ServiceException error)
Add a new exception reported by this service execution. |
void |
addException(ServiceException error,
MobyJob job)
Add a new exception reported by this service execution. |
void |
addJob(MobyJob job)
Add one job to the already stored here. |
static MobyPackage |
createFromXML(Object xmlData)
Constructing a MobyPackage object from XML. |
static MobyPackage |
createFromXML(Object xmlData,
Map<String,String> lowestKnownDataTypes)
Constructing a MobyPackage object from XML. |
static MobyPackage |
createFromXML(Object xmlData,
String lowestKnownDataType)
Constructing a MobyPackage object from XML. |
String |
evaluateExceptions(org.apache.commons.logging.Log log,
boolean throwException)
Evaluate current exceptions. |
String |
format(int indent)
Return the same contents as toString() method but
indented by level expressed in the parameter 'indent'. |
String |
getAuthority()
Get back the authority serving this package. |
ServiceException[] |
getExceptions()
Return all so far set exceptions. |
MobyJob |
getJob(int index)
Get back a job indicated by its order number. |
MobyJob[] |
getJobs()
Get back all jobs stored here. |
String |
getServiceNotes()
Get back service notes. |
static org.jdom.Element |
getXMLElement(String name)
Return a jDOM XML element equipped with the BioMoby namespace. |
boolean |
hasAnError()
Return true if this package contains at least one exception of the severity ServiceException.ERROR ). |
void |
setAuthority(String authority)
Fill in an authority of this whole package. |
void |
setExceptions(ServiceException[] errors)
Set one or more exceptions reported by this service invocation. |
void |
setJobs(MobyJob[] jobs)
Store here all jobs. |
void |
setServiceNotes(String notes)
Fill in any string representing service notes. |
void |
setServiceNotesXML(String notes)
Fill in any string representing service notes. |
static void |
setXMLAttribute(org.jdom.Element element,
String name,
String value)
Set attribute 'name' to 'value' in a jDOM XML element, equipped with the BioMoby namespace. |
static void |
setXMLAttributeForced(org.jdom.Element element,
String name,
String value)
Set attribute 'name' to 'value' in a jDOM XML element, equipped with the BioMoby namespace. |
int |
size()
Return the number of jobs (queries) contained in this package. |
String |
toString()
Format all non-empty public members in a human-readable way. |
String |
toXML()
Convert the whole contents and all its children to a Biomoby compliant XML string. |
org.jdom.Document |
toXMLDocument()
Convert the whole contents and all its children to a Biomoby compliant XML document. |
static org.jdom.Document |
toXMLDocument(org.jdom.Element[] jobs)
A static alternative returning much simpler XML document - without authority, without service notes, just with the given jobs. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MobyPackage()
public MobyPackage(MobyObject mObj, String articleName)
mObj
- to be inserted in this package as a simple object
in a single jobarticleName
- is the name given to the only SimpleMethod Detail |
---|
public static MobyPackage createFromXML(Object xmlData) throws MobyException
MobyException
public static MobyPackage createFromXML(Object xmlData, String lowestKnownDataType) throws MobyException
Additionally, it passes to the XML parser the
'lowestKnownDataType' as a falback object (the role of a
fallback object is explained in MobyParser
.
MobyException
public static MobyPackage createFromXML(Object xmlData, Map<String,String> lowestKnownDataTypes) throws MobyException
Additionally, it passes to the XML parser the
'lowestKnownDataType' as a falback object (the role of a
fallback object is explained in MobyParser
.
MobyException
public String toString()
toString
in class Object
for making the returned string better indented
public String format(int indent)
toString()
method but
indented by level expressed in the parameter 'indent'. It is
useful when a hierarchy of objects call toString
methods on their children/members.
indent
- means a level of wanted indentation: number 1
means three spaces, number two six spaces, etc.
public static org.jdom.Element getXMLElement(String name)
name
- of the returned element
public static void setXMLAttribute(org.jdom.Element element, String name, String value)
Do it only if 'value' is not empty. If you need to create an
attribute even if the value is empty use instead method setXMLAttributeForced(org.jdom.Element, java.lang.String, java.lang.String)
.
element
- where a new attribute is createdname
- of the created attributevalue
- of the created attributepublic static void setXMLAttributeForced(org.jdom.Element element, String name, String value)
Do it even for an empty 'value'.
element
- where a new attribute is createdname
- of the created attributevalue
- of the created attributepublic String toXML()
public org.jdom.Document toXMLDocument()
public static org.jdom.Document toXMLDocument(org.jdom.Element[] jobs)
public int size()
public void setJobs(MobyJob[] jobs)
public void addJob(MobyJob job)
public MobyJob[] getJobs()
public MobyJob getJob(int index) throws MobyException
MobyException
public void setAuthority(String authority)
public String getAuthority()
public void setServiceNotes(String notes)
notes
- human-readable descriptionfor adding CDATA section
,
for adding service exceptions
public void setServiceNotesXML(String notes)
notes
- human-readable descriptionfor adding string that will be properly escaped
,
for adding service exceptions
public String getServiceNotes()
public void addException(ServiceException error)
error
- to be addedpublic void addException(ServiceException error, MobyJob job)
error
- to be addedjob
- whose ID is aded to the 'error'public void setExceptions(ServiceException[] errors)
errors
- to be assignedpublic ServiceException[] getExceptions()
public String evaluateExceptions(org.apache.commons.logging.Log log, boolean throwException) throws MobyException
This is a utility (convenient) method that extracts all exceptions from this package and formats them into one string, and either returns it, or throws an exception (depending on the policy in 'throwException').
log
- if not null then the formatted exceptions are
written into this log (the severity of the exceptions dedicates
the log level used)throwException
- specify what to do when an error
condition was found: if 'throwException' is true then an
exception is thrown, otherwise the formatted exception is
returned
MobyException
- if there were at least one severe
exceptions and if the 'throwException' policy is truepublic boolean hasAnError()
ServiceException.ERROR
). Otherwise return false.
|
Version: 1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |