Class Document
java.lang.Object
se.conciliate.extensions.documents.Document
A document with meta-data from a source.
This class is immutable.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Document
createExisting
(DocumentSource source, String id, Collection<MetaData> data) Creates a document instance representing an existing document that is persisted in its source and thus has an id.static Document
createUnsaved
(DocumentSource source, Collection<MetaData> data) Creates a document instance representing a document that has not yet been persisted to its source and thus does not have a valid id yet.boolean
Checks this document's equality relation to some other object.Returns a globally unique ID for the document.getIcon()
Returns the icon of this document.getIcon
(MetaDataType.ColumnType columnType) getID()
getMetaData
(String typeId) getMetaData
(MetaDataType type) getMetaData
(MetaDataType.ColumnType columnType) Returns this document's source, the owner of the document.getTitle()
Returns the title of this document.int
hashCode()
Returns the hash for this document.setMetaData
(Collection<MetaData> data) setMetaData
(MetaData data) toString()
Returns a debug string representing this document.
-
Method Details
-
createUnsaved
Creates a document instance representing a document that has not yet been persisted to its source and thus does not have a valid id yet.- Parameters:
source
- The source that owns the document and knows how to persist it.data
- A collection of meta data to populate this document with. The data must have the same source as thesource
parameter.- Returns:
- a document representing a non-persisted document that does not have an id.
-
createExisting
Creates a document instance representing an existing document that is persisted in its source and thus has an id.- Parameters:
source
- The source that owns the document, the source where the document is persisted.id
- The document's id.data
- A collection of meta data for the document.- Returns:
- A document representing a persisted document that does have an id.
-
getSource
Returns this document's source, the owner of the document.- Returns:
- the owning source of this document.
-
getID
- Returns:
- A unique (for the source) ID for the document.
-
getGlobalID
Returns a globally unique ID for the document.- Returns:
- a globally unique ID for the document.
-
getTitle
Returns the title of this document.- Returns:
- the title of this document.
-
getIcon
Returns the icon of this document. If the icon is not 24x24 pixels, it may be scaled.- Returns:
- the icon of this document.
-
getMetaData
- Parameters:
typeId
- The meta-data type.- Returns:
- Optional meta-data of a given type set on this document.
-
getMetaData
- Parameters:
type
- The meta-data type.- Returns:
- Optional meta-data of a given type set on this document.
-
getMetaData
- Parameters:
type
- The meta-data type.- Returns:
- Optional meta-data of a given type set on this document.
-
getMetaData
- Parameters:
type
- The meta-data type.- Returns:
- Optional meta-data of a given type set on this document.
-
getMetaData
- Parameters:
type
- The meta-data type.- Returns:
- Optional meta-data of a given type set on this document.
-
getMetaData
- Parameters:
type
- The meta-data type.- Returns:
- Optional meta-data of a given type set on this document.
-
getMetaData
- Parameters:
type
- The meta-data type.- Returns:
- Optional meta-data of a given type set on this document.
-
getMetaData
- Parameters:
type
- The meta-data type.- Returns:
- Optional meta-data of a given type set on this document.
-
getMetaData
- Parameters:
type
- The meta-data type.- Returns:
- Optional meta-data of a given type set on this document.
-
getMetaData
- Parameters:
type
- The meta-data type.- Returns:
- Optional meta-data of a given type set on this document.
-
getMetaData
- Parameters:
type
- The meta-data type.- Returns:
- Optional meta-data of a given type set on this document.
-
getMetaData
- Parameters:
columnType
- The pre-defined column type- Returns:
- Optional meta data of a given column type
-
getIcon
- Parameters:
columnType
- The pre-defined column type- Returns:
- Optional meta data of a given column type
-
setMetaData
- Parameters:
data
- The data to set.- Returns:
- A new document with the new meta-data set.
- Throws:
IllegalArgumentException
- If any meta-data has a non-editable type.
-
setMetaData
- Parameters:
data
- The data to set.- Returns:
- A new document with the new meta-data set.
- Throws:
IllegalArgumentException
- If the meta-data has a non-editable type.
-
equals
Checks this document's equality relation to some other object. Will return false for any object that is not aDocument
. Documents are considered equal if they have the same id and source, even if they do not share the same set of meta data.
NewDocument
s are never equal to any other document (since they don't have an id).- Overrides:
equals
in classObject
- Parameters:
o
- The object to compare for equality.- Returns:
- True if o is a
Document
and has the same id and source as this document, false otherwise. False is also returned if either this or o is a new document (created with a call tocreateUnsaved
).
-
hashCode
public int hashCode()Returns the hash for this document. The hash will be the same for any documents that are equal. For non equal documents, the hash will be the same if the documents have the same source and are new documents created with a call tocreateUnsaved
. -
toString
Returns a debug string representing this document. The string will be"SourceID DocumentTitle
.
-