|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.levigo.jadice.document.AbstractDocument
public abstract class AbstractDocument
A basic implementation of the Document
interface. Not thread-safe!
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.levigo.jadice.document.Document |
---|
Document.BasicState, Document.State |
Field Summary | |
---|---|
protected com.levigo.jadice.document.DocumentInterceptorSupport |
interceptorSupport
|
protected com.levigo.jadice.document.DocumentListenerSupport |
listenerSupport
|
protected static Logger |
LOGGER
|
Fields inherited from interface com.levigo.jadice.document.Document |
---|
BASE_RESOLUTION, PROPERTY_KEY_DISPLAY_NAME, PROPERTY_KEY_DOCUMENT_ID, PROPERTY_KEY_FILE_NAME, PROPERTY_NAME, PROPERTY_PREFIX_PAGE, PROPERTY_PREFIX_USER_PROPERTY, PROPERTY_STATE |
Constructor Summary | |
---|---|
AbstractDocument()
Construct a new document. |
|
AbstractDocument(String name)
Construct a new document with the given name. |
Method Summary | |
---|---|
void |
addDocumentInterceptor(DocumentInterceptor interceptor)
Register a DocumentInterceptor to this document instance. |
void |
addDocumentListener(DocumentListener listener)
Register a DocumentListener to this document instance. |
void |
addPage(Page page)
Adds a page to the document. |
protected void |
cleanUpResources()
Performes the actual clean-up required for disposing of Document s. |
boolean |
close()
Closes a Document . |
void |
dispose()
Disposes of a Document performing necessary clean-up tasks. |
protected void |
exceptionIfDisposed()
|
Metadata |
getMetadata()
Return the exposed meta-data or null if no meta-data is available. |
MutableMetadataNode |
getMutableMetadataRoot()
Return the mutable root node of the meta-data tree belonging to this metadata provider. |
String |
getName()
Gets the document's name. |
Page |
getPage(int pageIndex)
Convenience method: return the page at the given page index. |
Page |
getPage(int pageNumber,
boolean create)
Return the page at the given page index. |
int |
getPageCount()
Convenience method: determine the number of pages in this document. |
int |
getPageIndex(Page page)
Convenience method: determine the index of a page in this document. |
abstract EventList<Page> |
getPages()
Returns a list of pages in the document. |
Permissions<Document> |
getPermissions()
Provides an instance of Permissions . |
Map<String,Object> |
getProperties()
Return a map of user properties. |
Document.State |
getState()
|
boolean |
isDisposed()
Return whether or not this Document has been disposed of. |
void |
removeDocumentInterceptor(DocumentInterceptor interceptor)
Unregister a DocumentInterceptor from this document. |
void |
removeDocumentListener(DocumentListener listener)
Unregister a DocumentListener from this document. |
void |
setName(String name)
Sets the document's name. |
boolean |
setState(Document.State state)
Sets the current state of the Document . |
String |
toString()
The description of the document |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final Logger LOGGER
protected final com.levigo.jadice.document.DocumentListenerSupport listenerSupport
protected final com.levigo.jadice.document.DocumentInterceptorSupport interceptorSupport
Constructor Detail |
---|
public AbstractDocument()
public AbstractDocument(String name)
name
- the name of the documentMethod Detail |
---|
public void addDocumentListener(DocumentListener listener)
Document
DocumentListener
to this document instance.
addDocumentListener
in interface Document
listener
- the listener to registerpublic final void addPage(Page page)
page
- the page to add
IllegalStateException
- if called on a Document
which has been disposed of.public final boolean close()
Document
Document
. This includes performing a state transition to
Document.BasicState.CLOSED
and cleaning up resources. Both will only happen if all registered
DocumentInterceptor
s agree with the state change. In usual cases, this method should be
preferred to calling Document.dispose()
.
close
in interface Document
for details about resource clean-up
,
will be asked to accept or deny the state change. Implementations
could ask the user for acknowledgment.
,
gets the chance to perform save or clean-up actions when it receives the
state change to new state {@link BasicState#CLOSED}.
public void dispose()
Document
Disposes of a Document
performing necessary clean-up tasks. Disposed Document
s
will have Document.BasicState.CLOSED
as their Document.State
. This method is not expected
to ask registered DocumentInterceptor
s for their consent about the state transition.
DocumentListener
s may or may not be informed about the state change. In most cases,
Document.close()
should be used instead of this method.
Since cleaning up releases any resources held by this Document
, it will no longer be
practically useful afterwards. A Document
which has been disposed of will refuse
further changes on itself and may throw Exceptions if methods are called.
Before calling dispose it is for this reason important to make sure that the Document
to be disposed of is not registered with any other (GUI or non-GUI) component which might call
methods later on.
dispose
in interface Document
protected void cleanUpResources()
Document
s.
public boolean isDisposed()
Document
Document
has been disposed of. Disposed Document
s
will refuse further changes on themselves. Method calls on them may result in Exceptions being
thrown.
isDisposed
in interface Document
true
if this Document
has been disposed of and all of its
resources have been cleaned up. false
if this Document
has not yet
been disposed of and is therefore fully usable.Document.dispose()
public String getName()
Document
getName
in interface Document
getName
in interface Item
public Page getPage(int pageIndex)
Document
Document.getPages()
.get(pageNumber)
. As an added convenience, callers need not
lock the page list in order to be thread-safe.
getPage
in interface Document
pageIndex
- the 0-based index of the page to be returned.
Page
or null
if the page doesn't exist.public int getPageIndex(Page page)
Document
Document.getPages()
.indexOf(page)
. As an added convenience, callers need not lock
the page list in order to be thread-safe.
getPageIndex
in interface Document
page
- to search for
public Page getPage(int pageNumber, boolean create)
Document
getPage
in interface Document
pageNumber
- the 0-based index of the page to be returned.create
- flag indicating if the page should be created if it doesn't exist.
Page
or null
if the page doesn't exist and create
is
false
.public int getPageCount()
Document
Document.getPages()
.size()
. As an added convenience, callers need not lock the
page list in order to be thread-safe.
getPageCount
in interface Document
public abstract EventList<Page> getPages()
Document
EventList
.
As a convenience, a non-thread-safe page list may be wrapped using
GlazedLists.threadSafeList(EventList)
to obtain a thread-safe one.
getPages
in interface Document
public final Document.State getState()
getState
in interface Document
public void removeDocumentListener(DocumentListener listener)
Document
DocumentListener
from this document.
removeDocumentListener
in interface Document
listener
- the listener to removepublic void setName(String name)
Document
setName
in interface Document
name
- The name to setpublic boolean setState(Document.State state)
Document
Sets the current state of the Document
.
The document Document.State
is not only a simple information about a document instance, but also
it provides the decision base of the enabled state for many document functionalities. If the
document state is not set or is set to a wrong state, these functionalities may become disabled
or fail to execute.
Registered interceptors may disapprove state changes. Therefore the requested state is not
necessarily the actual next state.
setState
in interface Document
state
- the new state
true
) or rejected (
false
).Document.State
,
Document.BasicState
,
DocumentInterceptor
public String toString()
toString
in class Object
public Map<String,Object> getProperties()
PropertiesProvider
getProperties
in interface PropertiesProvider
PropertiesProvider.getProperties()
public void addDocumentInterceptor(DocumentInterceptor interceptor)
Document
DocumentInterceptor
to this document instance.
addDocumentInterceptor
in interface Document
interceptor
- the interceptor to registerpublic void removeDocumentInterceptor(DocumentInterceptor interceptor)
Document
DocumentInterceptor
from this document.
removeDocumentInterceptor
in interface Document
interceptor
- the interceptor to removepublic Permissions<Document> getPermissions()
PermissionsProvider
Permissions
. Must never return null
.
getPermissions
in interface PermissionsProvider<Document>
Permissions
object.public Metadata getMetadata()
MetadataProvider
null
if no meta-data is available. An object being
a MetadataProvider is not required to provide a non-null
meta-data.
getMetadata
in interface MetadataProvider
null
public MutableMetadataNode getMutableMetadataRoot()
MutableMetadataProvider
getMutableMetadataRoot
in interface MutableMetadataProvider
protected void exceptionIfDisposed()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |