org.exist.fluent
Class Folder.DocumentsFacet

java.lang.Object
  extended by org.exist.fluent.Resource
      extended by org.exist.fluent.Folder.DocumentsFacet
All Implemented Interfaces:
Iterable<Document>
Enclosing class:
Folder

public class Folder.DocumentsFacet
extends Resource
implements Iterable<Document>

The immediate documents facet of a folder. Gives access to the (conceptual) set of documents contained directly in a folder. All functions will not consider documents contained in subfolders.

Author:
Piotr Kaminski

Nested Class Summary
 class Folder.DocumentsFacet.ListenersFacet
          The facet that gives control over listeners for documents contained directly within a folder.
 
Method Summary
 ElementBuilder<XMLDocument> build(Name name)
          Build a new XML document in this collection, with the given relative path.
 boolean contains(String documentPath)
          Return whether this facet's folder contains a document with the given relative path.
 void export(File destination)
          Export the immediately contained documents to the given directory.
 Document get(String documentPath)
          Get the contained document with the given relative path.
 Iterator<Document> iterator()
          Return an iterator over the folder's immediate documents.
 Folder.DocumentsFacet.ListenersFacet listeners()
          Return the facet that allows control over listenersof the folder's immediate documents.
 Document load(Name name, Source.Blob source)
          Create a binary document with the given relative path, takings its contents from the given source.
 XMLDocument load(Name name, Source.XML source)
          Create an XML document with the given relative path, takings its contents from the given source.
 QueryService query()
          Query over the documents immediately contained in the folder, ignoring any documents in subfolders.
 int size()
          Return the number of documents immediately contained in the folder.
 
Methods inherited from class org.exist.fluent.Resource
database, namespaceBindings
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

listeners

public Folder.DocumentsFacet.ListenersFacet listeners()
Return the facet that allows control over listenersof the folder's immediate documents.

Returns:
the immediate documents' listener facet

build

public ElementBuilder<XMLDocument> build(Name name)
Build a new XML document in this collection, with the given relative path. Remember to commit commit the builder when done. If the builder doesn't commit, no document is created.

Parameters:
name - the relative path to the new document
Returns:
a builder to use to create the document

contains

public boolean contains(String documentPath)
Return whether this facet's folder contains a document with the given relative path.

Parameters:
documentPath - the relative path of the document to check for
Returns:
true if the folder contains a document with the given path, false otherwise

load

public XMLDocument load(Name name,
                        Source.XML source)
Create an XML document with the given relative path, takings its contents from the given source.

Parameters:
name - the desired relative path of the document
source - the source of XML data to read in the document contents from; the folder's namespace bindings are not applied
Returns:
the newly created document
Throws:
DatabaseException - if anything else goes wrong

load

public Document load(Name name,
                     Source.Blob source)
Create a binary document with the given relative path, takings its contents from the given source.

Parameters:
name - the desired relative path of the document
source - the source to read the document contents from
Returns:
the newly created document
Throws:
DatabaseException - if anything else goes wrong

get

public Document get(String documentPath)
Get the contained document with the given relative path.

Parameters:
documentPath - the relative path of the document to find
Returns:
the document with the given path
Throws:
DatabaseException - if unable to find or access the desired document

size

public int size()
Return the number of documents immediately contained in the folder.

Returns:
the number of child documents

export

public void export(File destination)
            throws IOException
Export the immediately contained documents to the given directory. If the directory does not exist it will be created. Documents in this folder will appear directly in the given directory.

Parameters:
destination - the destination folder to export into
Throws:
IOException - if the export failed due to an I/O error

query

public QueryService query()
Query over the documents immediately contained in the folder, ignoring any documents in subfolders.

Overrides:
query in class Resource
Returns:
a query service over the folder's immediate documents

iterator

public Iterator<Document> iterator()
Return an iterator over the folder's immediate documents. This iterator can be used to selectively delete documents as well.

Specified by:
iterator in interface Iterable<Document>
Returns:
an iterator over the folder's immediate documents


Copyright (C) All rights reserved.