public abstract class AbstractPluginDocument extends Object implements PluginDocument, XMLSerializable.OldVersionCompatible
setURN(com.biomatters.geneious.publicapi.documents.URN) and setCreated.
setFieldValue(java.lang.String, java.lang.Object).
PluginDocument.getDescription() and PluginDocument.toHTML().PluginDocument.ReferencedDocumentsAlwaysLoaded, PluginDocument.ReferencedDocumentsNotLoaded, PluginDocument.SizeRequiredToLoadIntoMemoryProviderXMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportTypeFILE_DATA_ATTRIBUTE_NAME, MAXIMUM_HTML_LENGTH, MODIFIED_DATE_FIELDROOT_ELEMENT_NAME| Constructor and Description |
|---|
AbstractPluginDocument()
Create a new document with a creation date taken from system clock.
|
AbstractPluginDocument(Date created)
Construct a new document with a given time of creation.
|
AbstractPluginDocument(Date created,
URN urn)
Construct a new document with a given URN and time of creation.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDisplayableField(DocumentField field)
adds a displayable field to the document that is stored with the documents.
|
void |
addReferencedDocumentUrn(URN documentUrn)
Adds the given document URN to a list of documents to be referenced.
|
void |
clearReferencedDocumentUrns()
Clears the list of all referenced docments previously added using
addReferencedDocumentUrn(URN). |
void |
createFromBaseElement(org.jdom.Element element)
Restore document from base element.
|
void |
fromXML(org.jdom.Element root)
Restore the object from the JDOM Element returned by
XMLSerializable.toXML(). |
org.jdom.Element |
getBaseElement()
A JDOM element holding document data.
|
String |
getBaseElementString()
Base element as a XML text fragment.
|
Date |
getCreationDate()
Get the date this document was created.
|
List<DocumentField> |
getDisplayableFields()
A list of columns for display in the main document panel.
|
Object |
getFieldValue(String code)
Get the value of a particular field.
|
List<String> |
getFieldValueCodes()
Gets the code of all fields stored in this document, including non-displayable fields.
|
List<URN> |
getReferencedDocumentUrns()
This function can be called to retrieve the list of documents previously
remembered using the
addReferencedDocumentUrn(URN) function. |
URN |
getURN()
A Universal Resource Name.
|
Geneious.MajorVersion |
getVersionSupport(XMLSerializable.VersionSupportType versionType)
Gets either the latest version this class can serialize to via
XMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener)
or the most recent version in which the XML returned from XMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener) last changed. |
boolean |
hasProperties() |
void |
setBaseElement(org.jdom.Element baseElement)
Set document base element.
|
protected void |
setCreated(Date date)
Set document date of creation.
|
void |
setFieldValue(DocumentField field,
Object value)
Set value of one data item (field).
|
void |
setFieldValue(String code,
Object value)
Set value of one data item (field).
It is important to call addDisplayableField(DocumentField) if this field should be displayable and isn't already on this document.
For non displayable fields, the value must either implement XMLSerializable or be an instance of a simple type that Geneious knows how to serialize (e.g. |
void |
setFieldValues(Map<String,Object> fieldValues)
Set all fields in one go.
|
protected void |
setURN(URN urn)
Set document URN.
|
org.jdom.Element |
toXML()
Convert object to a JDOM element.
|
org.jdom.Element |
toXML(Geneious.MajorVersion version,
ProgressListener progressListener)
Serializes this class to XML format, potentially to a format readable by an earlier version of Geneious.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDescription, getName, toHTMLpublic AbstractPluginDocument(Date created)
created - the date this document was created, or null to use the current date.
The date will be serialized to XML by this document and then restored
when the document is deserialized again from XML. See PluginDocument.getCreationDate().public AbstractPluginDocument(Date created, URN urn)
created - the date this document was created, or null to use the current date.
The date will be serialized to XML by this document and then restored
when the document is deserialized again from XML. See PluginDocument.getCreationDate().urn - the urn for this documentpublic AbstractPluginDocument()
public org.jdom.Element getBaseElement()
public String getBaseElementString()
public void setBaseElement(org.jdom.Element baseElement)
baseElement - to setpublic void createFromBaseElement(org.jdom.Element element)
fromXML(org.jdom.Element) to let document set any variables
or fields from data inside base element.
The code in the base class does nothing since the semantics of the base element are not
known to it. Meaningful stuff happens only in subclasses which override this method.element - saved base elementpublic Object getFieldValue(String code)
PluginDocumentgetFieldValue in interface PluginDocumentcode - field code. This should be the
code of one of the fields
returned from PluginDocument.getDisplayableFields().DocumentField.getValueType() (or a subclass) of the corresponding DocumentField returned from PluginDocument.getDisplayableFields().public void setFieldValue(String code, Object value)
addDisplayableField(DocumentField) if this field should be displayable and isn't already on this document.
For non displayable fields, the value must either implement XMLSerializable or be an instance of a simple type that Geneious knows how to serialize (e.g. Integer, Double, Date, String) or a List or Map of any of these types.code - field codevalue - item valueIllegalArgumentException - if code was the code of DocumentField.CREATED_FIELD, and the associated value
was not of type Date.setFieldValue(DocumentField, Object)public void setFieldValue(DocumentField field, Object value)
addDisplayableField(DocumentField)field - the fieldvalue - item valuesetFieldValue(String, Object)public void setFieldValues(Map<String,Object> fieldValues)
fieldValues - all valuespublic List<String> getFieldValueCodes()
getFieldValue(String)protected final void setURN(URN urn)
urn - to setprotected final void setCreated(Date date)
date - to setpublic final URN getURN()
PluginDocumentgetURN in interface PluginDocumentpublic final Date getCreationDate()
PluginDocumentAnnotatedPluginDocument.getCreationDate()
instead as that will return either the date returned from
PluginDocument.getCreationDate() or if that returned null,
AnnotatedPluginDocument.getCreationDate() will return the date the
document was first instantiated.getCreationDate in interface PluginDocumentPluginDocument.MODIFIED_DATE_FIELDpublic Geneious.MajorVersion getVersionSupport(XMLSerializable.VersionSupportType versionType)
XMLSerializable.OldVersionCompatibleXMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener)
or the most recent version in which the XML returned from XMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener) last changed.getVersionSupport in interface XMLSerializable.OldVersionCompatibleversionType - specifies which version property to returnpublic org.jdom.Element toXML()
XMLSerializableXMLSerializable.fromXML(org.jdom.Element) can completely
restore the objects representation.
It is recommended that the returned element use XMLSerializable.ROOT_ELEMENT_NAME as its name,
in which case it must not define an attribute called "type". In this case,
fromXML, will be called with an element whose name may differ from the element
return from this function. This recommendation allows a more compact representation
of the XML can be stored.
This method generally should not be called directly. Instead, you should usually call
XMLSerializer.classToXML(String, XMLSerializable)
which calls this method internally.
PluginDocument implementations of this method may choose to throw an XMLSerializationException,
enclosed in a RuntimeException.toXML in interface XMLSerializablepublic org.jdom.Element toXML(Geneious.MajorVersion version, ProgressListener progressListener)
XMLSerializable.OldVersionCompatibleXMLSerializable.toXML() for a more
detailed description of what it means to serialize to XML.
All classes that implement this method must also implement XMLSerializable.toXML() and should delegate back to
this method using Geneious.getMajorVersion() and ProgressListener.EMPTY as parameters.toXML in interface XMLSerializable.OldVersionCompatibleversion - the major version of Geneious to serialize to XML for. For example "6.0" but not "6.0.0". This must be a version
returned greater or equal to a version returned from
getVersionSupport(VersionSupportType.OldestVersionSerializableTo)
and must never be greater than the current version (Geneious.getMajorVersion())progressListener - for reporting progress and cancellingpublic void fromXML(org.jdom.Element root)
throws XMLSerializationException
XMLSerializableXMLSerializable.toXML().
This method generally should not be called directly. Instead, you should usually call
XMLSerializer.classFromXML(org.jdom.Element)
or XMLSerializer.classFromXML(org.jdom.Element, Class)
which calls this method internally.
It is optional to implement this method. Instead of implementing an empty constructor and implementing
this method properly, the implementation may instead
throw an UnsupportedOperationException and implement a constructor
that takes a single Element as a parameter.
This allows for cleaner code such as support for final fields in the XMLSerializable class.
The element parameter should not be modified since it may be reused. If you need a modified version of it,
take a copy with Element.clone().fromXML in interface XMLSerializableroot - representation from a previous call to XMLSerializable.toXML()XMLSerializationException - if the Element can't be converted into this type of objectpublic void addDisplayableField(DocumentField field)
field - a DocumentFieldpublic List<DocumentField> getDisplayableFields()
PluginDocumentPluginDocument.getFieldValue(String).
Each column is specified by a Field. The fields should be obtained from a call to the appropriate
Field.createXXXXField, where XXXX is the appropriate type.
While it is not required, it is recommended that a PluginDocument
handle returning a complete list of its displayable fields before
the document has been properly constructed via a call to XMLSerializable.fromXML(org.jdom.Element)
The returned list need not and should not be modifiable.getDisplayableFields in interface PluginDocumentpublic void addReferencedDocumentUrn(URN documentUrn)
PluginDocument as a reference,
first call DocumentUtilities.createAnnotatedPluginDocument(PluginDocument) or similar then call
AnnotatedPluginDocument.getURN() to get a URN.
The reference document will be available later via getReferencedDocumentUrns().documentUrn - public List<URN> getReferencedDocumentUrns()
addReferencedDocumentUrn(URN) function.
Note: if the user has deleted one or more of the referenced documents from their
local database, then those documents still be available via this function.
Documents are not really deleted (just hidden from the user) until all documents
that reference it are also deleted.public void clearReferencedDocumentUrns()
addReferencedDocumentUrn(URN).public boolean hasProperties()
AbstractPluginDocument.toXML will return an empty element.