Class FilteredDocument

java.lang.Object
com.levigo.jadice.web.client.model.document.FilteredDocument
All Implemented Interfaces:
com.google.gwt.user.client.rpc.IsSerializable, Document, Item, MetadataProvider, PermissionsProvider<Document>, PropertiesProvider, com.levigo.jadice.web.shared.model.internal.document.SerializableDocument

public class FilteredDocument extends Object implements com.levigo.jadice.web.shared.model.internal.document.SerializableDocument
A Document implementation that allows to apply a filter on its Pages.

Since the list of pages is represented by a Glazedlists FilterList, filtering is applied by setting a Matcher or a MatcherEditor, using the existing API of the FilterList.

The underlying original ("unfiltered") Document can be accessed by getDelegate() any time.

  • Constructor Details

    • FilteredDocument

      public FilteredDocument(com.levigo.jadice.web.shared.model.internal.document.SerializableDocument delegate)
  • Method Details

    • init

      public void init()
    • addDocumentListener

      public void addDocumentListener(DocumentListener listener)
      Description copied from interface: Document
      Register a DocumentListener to this document instance.
      Specified by:
      addDocumentListener in interface Document
      Parameters:
      listener - the listener to register
    • addDocumentInterceptor

      public void addDocumentInterceptor(DocumentInterceptor interceptor)
      Description copied from interface: Document
      Register a DocumentInterceptor to this document instance.
      Specified by:
      addDocumentInterceptor in interface Document
      Parameters:
      interceptor - the interceptor to register
    • close

      public boolean close()
      Description copied from interface: Document
      Closes a Document. This includes performing a state transition to Document.BasicState.CLOSED and cleaning up resources. Both will only happen if all registered DocumentInterceptors agree with the state change. In usual cases, this method should be preferred to calling Document.dispose().
      Specified by:
      close in interface Document
      Returns:
      flag indicating whether the process passed successfully or not
      See Also:
    • dispose

      public void dispose()
      Description copied from interface: Document

      Disposes of a Document performing necessary clean-up tasks. Disposed Documents will have Document.BasicState.CLOSED as their Document.State. This method is not expected to ask registered DocumentInterceptors for their consent about the state transition. DocumentListeners 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.

      Specified by:
      dispose in interface Document
    • isDisposed

      public boolean isDisposed()
      Description copied from interface: Document
      Return whether or not this Document has been disposed of. Disposed Documents will refuse further changes on themselves. Method calls on them may result in Exceptions being thrown.
      Specified by:
      isDisposed in interface Document
      Returns:
      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.
      See Also:
    • getName

      public String getName()
      Description copied from interface: Document
      Gets the document's name.
      Specified by:
      getName in interface Document
      Specified by:
      getName in interface Item
      Returns:
      Returns a String
    • getPage

      public Page getPage(int pageIndex)
      Description copied from interface: Document
      Convenience method: return the page at the given page index. Equivalent to Document.getPages().get(pageNumber). As an added convenience, callers need not lock the page list in order to be thread-safe.
      Specified by:
      getPage in interface Document
      Parameters:
      pageIndex - the 0-based index of the page to be returned.
      Returns:
      a Page or null if the page doesn't exist.
    • getDelegatePage

      public Page getDelegatePage(int pageIndex)
      Finds a page in the original document, given by its page index. Attention: The page index refers to the original document!
      Parameters:
      pageIndex - The index of the page in the unfiltered document
      Returns:
      The Page specified by the given index in the unfiltered document
    • getPage

      public Page getPage(int pageIndex, boolean create)
      Description copied from interface: Document
      Return the page at the given page index. Create it, if there is no page at this index at this point. As an added convenience, callers need not lock the page list in order to be thread-safe.
      Specified by:
      getPage in interface Document
      Parameters:
      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.
      Returns:
      a Pageor null if the page doesn't exist and create is false.
    • getPageCount

      public int getPageCount()
      Description copied from interface: Document
      Convenience method: determine the number of pages in this document. Equivalent to Document.getPages().size(). As an added convenience, callers need not lock the page list in order to be thread-safe.
      Specified by:
      getPageCount in interface Document
      Returns:
      int the page number count
    • getPageIndex

      public int getPageIndex(Page page)
      Description copied from interface: Document
      Convenience method: determine the index of a page in this document. Equivalent to Document.getPages().indexOf(page). As an added convenience, callers need not lock the page list in order to be thread-safe.
      Specified by:
      getPageIndex in interface Document
      Parameters:
      page - to search for
      Returns:
      int the page number of the given page in this document, or -1 if this document does not contain the page
    • getPages

      public org.jadice.util.glazedlists.EventList<Page> getPages()
      Description copied from interface: Document
      Returns a list of pages in the document. Please note that, unless stated otherwise by implementors, this list is not thread-safe. Care must therefore be taken to manipulate the page list with appropriate locking as detailed in the documentation of EventList. As a convenience, a non-thread-safe page list may be wrapped using GlazedLists.threadSafeList(EventList) to obtain a thread-safe one.
      Specified by:
      getPages in interface Document
      Returns:
      List of pages
    • removeDocumentListener

      public void removeDocumentListener(DocumentListener listener)
      Description copied from interface: Document
      Unregister a DocumentListener from this document.
      Specified by:
      removeDocumentListener in interface Document
      Parameters:
      listener - the listener to remove
    • removeDocumentInterceptor

      public void removeDocumentInterceptor(DocumentInterceptor interceptor)
      Description copied from interface: Document
      Unregister a DocumentInterceptor from this document.
      Specified by:
      removeDocumentInterceptor in interface Document
      Parameters:
      interceptor - the interceptor to remove
    • setName

      public void setName(String name)
      Description copied from interface: Document
      Sets the document's name.
      Specified by:
      setName in interface Document
      Parameters:
      name - The name to set
    • getState

      public Document.State getState()
      Specified by:
      getState in interface Document
    • setState

      public boolean setState(Document.State state)
      Description copied from interface: 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.

      Specified by:
      setState in interface Document
      Parameters:
      state - the new state
      Returns:
      whether the state change was successful (true) or rejected ( false).
      See Also:
    • getPermissions

      public Permissions<Document> getPermissions()
      Specified by:
      getPermissions in interface PermissionsProvider<Document>
    • getProperties

      public Map<String,Object> getProperties()
      Description copied from interface: PropertiesProvider
      Return a map of user properties. What to store and which keys to use is largely up to the user of classes implementing this interface, since those classes will generally be oblivious to the map's contents. There are no guarantees regarding the thread-safety of the returned map, unless otherwise specified by implementors.
      Specified by:
      getProperties in interface PropertiesProvider
      Returns:
      the map of user properties
    • getMetadata

      public Metadata getMetadata()
      Description copied from interface: MetadataProvider
      Return the exposed meta-data or null if no meta-data is available. An object being a MetadataProvider is not required to provide a non-null meta-data.
      Specified by:
      getMetadata in interface MetadataProvider
      Returns:
      the metadata document or null
    • getOriginalReadStructure

      public com.levigo.jadice.web.shared.model.internal.ReadStructure getOriginalReadStructure()
      Specified by:
      getOriginalReadStructure in interface com.levigo.jadice.web.shared.model.internal.document.SerializableDocument
    • getChangeSet

      public com.levigo.jadice.web.shared.model.serveroperation.internal.ChangeSet<Page> getChangeSet()
      Specified by:
      getChangeSet in interface com.levigo.jadice.web.shared.model.internal.document.SerializableDocument
    • setMatcher

      public void setMatcher(org.jadice.util.glazedlists.matchers.Matcher<? super Page> matcher)
      Since the list of Pages is represented by a Glazedlists FilterList, filtering is applied by setting a Matcher or a MatcherEditor, using the existing API of the FilterList.
      Parameters:
      matcher - The new Matcher to use
      See Also:
    • setMatcherEditor

      public void setMatcherEditor(org.jadice.util.glazedlists.matchers.MatcherEditor<? super Page> editor)
      Since the list of Pages is represented by a Glazedlists FilterList, filtering is applied by setting a Matcher or a MatcherEditor, using the existing API of the FilterList.
      Parameters:
      editor - The new Editor to use
      See Also:
    • getDelegate

      public Document getDelegate()
      Access the underlying original ("unfiltered") Document.
      Returns:
      the original Document (without any filtering applied to the document)