|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Document
Represents a logical document. A logical document consists of a two-dimensional structure:
Page
s. Pages are mere
containers for data which can be displayed or manipulated. Each page consists of 1-n
AbstractPageSegment
s, which occupy the document's layers for a
page (see below).
Nested Class Summary | |
---|---|
static class |
Document.BasicState
An enum consisting of the default document states. |
static interface |
Document.State
This is a marker interface to be implemented by objects serving as state designators for documents. |
Field Summary | |
---|---|
static int |
BASE_RESOLUTION
The base resolution. |
static String |
PROPERTY_KEY_DISPLAY_NAME
A user property key for the name of the document to be presented to users such as in a window title bar etc.. |
static String |
PROPERTY_KEY_DOCUMENT_ID
A user property key for the ID of an item in an archive with which the document is associated. |
static String |
PROPERTY_KEY_FILE_NAME
A user property key for the name of the file from which the document originated. |
static String |
PROPERTY_NAME
Property change key for the 'name' property. |
static String |
PROPERTY_PREFIX_PAGE
A property name prefix used for bridged property changes from pages. |
static String |
PROPERTY_PREFIX_USER_PROPERTY
A property name prefix used for bridged property changes from user properties. |
static String |
PROPERTY_STATE
Property change key for the 'state' property. |
Method Summary | |
---|---|
void |
addDocumentInterceptor(DocumentInterceptor interceptor)
Register a DocumentInterceptor to this document instance. |
void |
addDocumentListener(DocumentListener listener)
Register a DocumentListener to this document instance. |
boolean |
close()
Closes a Document . |
void |
dispose()
Disposes of a Document performing necessary clean-up tasks. |
String |
getName()
Gets the document's name. |
Page |
getPage(int pageIndex)
Convenience method: return the page at the given page index. |
Page |
getPage(int pageIndex,
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. |
EventList<Page> |
getPages()
Returns a list of pages in the document. |
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 . |
Methods inherited from interface com.levigo.jadice.document.PermissionsProvider |
---|
getPermissions |
Methods inherited from interface com.levigo.jadice.document.util.PropertiesProvider |
---|
getProperties |
Methods inherited from interface com.levigo.jadice.document.metadata.MetadataProvider |
---|
getMetadata |
Field Detail |
---|
static final String PROPERTY_STATE
getState()
,
setState(State)
,
Constant Field Valuesstatic final String PROPERTY_NAME
getName()
,
setName(String)
,
Constant Field Valuesstatic final String PROPERTY_PREFIX_PAGE
static final String PROPERTY_PREFIX_USER_PROPERTY
static final String PROPERTY_KEY_FILE_NAME
static final String PROPERTY_KEY_DISPLAY_NAME
static final String PROPERTY_KEY_DOCUMENT_ID
static final int BASE_RESOLUTION
Method Detail |
---|
void addDocumentListener(DocumentListener listener)
DocumentListener
to this document instance.
listener
- the listener to register
IllegalArgumentException
- if parameter is null
IllegalStateException
- if called on a Document
which has been disposed ofvoid addDocumentInterceptor(DocumentInterceptor interceptor)
DocumentInterceptor
to this document instance.
interceptor
- the interceptor to register
IllegalArgumentException
- if parameter is null
IllegalStateException
- if called on a Document
which has been disposed of.boolean close()
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 dispose()
.
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}.
void dispose()
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,
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.
boolean isDisposed()
Document
has been disposed of. Disposed Document
s
will refuse further changes on themselves. Method calls on them may result in Exceptions being
thrown.
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.dispose()
String getName()
getName
in interface Item
Page getPage(int pageIndex)
getPages()
.get(pageNumber)
. As an added convenience, callers need not
lock the page list in order to be thread-safe.
pageIndex
- the 0-based index of the page to be returned.
Page
or null
if the page doesn't exist.Page getPage(int pageIndex, boolean create)
pageIndex
- 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
.
IndexOutOfBoundsException
- if pageIndex < 0
IllegalStateException
- if called with parameter create==true
on a
Document
which has been disposed ofint getPageCount()
getPages()
.size()
. As an added convenience, callers need not lock the
page list in order to be thread-safe.
int getPageIndex(Page page)
getPages()
.indexOf(page)
. As an added convenience, callers need not lock
the page list in order to be thread-safe.
page
- to search for
NullPointerException
- if the page is null
EventList<Page> getPages()
EventList
.
As a convenience, a non-thread-safe page list may be wrapped using
GlazedLists.threadSafeList(EventList)
to obtain a thread-safe one.
IllegalStateException
- if called on a Document
which has been disposed of.void removeDocumentListener(DocumentListener listener)
DocumentListener
from this document.
listener
- the listener to removevoid removeDocumentInterceptor(DocumentInterceptor interceptor)
DocumentInterceptor
from this document.
interceptor
- the interceptor to removevoid setName(String name)
name
- The name to set
IllegalStateException
- if called on a Document
which has been disposed of.Document.State getState()
boolean setState(Document.State state)
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.
state
- the new state
true
) or rejected (
false
).
IllegalStateException
- if called on a Document
which has been disposed of.Document.State
,
Document.BasicState
,
DocumentInterceptor
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |