KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > publication > Collection


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: Collection.java 42624 2004-03-04 14:59:03Z edith $ */
19
20 package org.apache.lenya.cms.publication;
21
22 /**
23  * A document representing a collection of documents.
24  * This class is in prototyping stage.
25  */

26 public interface Collection extends Document {
27
28     String JavaDoc NAMESPACE = "http://apache.org/cocoon/lenya/collection/1.0";
29     String JavaDoc DEFAULT_PREFIX = "col";
30     
31     String JavaDoc ELEMENT_COLLECTION = "collection";
32     String JavaDoc ELEMENT_DOCUMENT = "document";
33     String JavaDoc ATTRIBUTE_ID = "id";
34
35     /**
36      * Returns the documents in this collection.
37      * @return An array of documents.
38      * @throws DocumentException when something went wrong.
39      */

40     Document[] getDocuments() throws DocumentException;
41
42     /**
43      * Adds a document to the collection.
44      * @param document A document.
45      * @throws DocumentException when an error occurs.
46      */

47     void add(Document document) throws DocumentException;
48
49     /**
50      * Inserts a document into the collection at a specific position.
51      * @param document A document.
52      * @param position The position of the document after insertion,
53      * starting with 0.
54      * @throws DocumentException when something went wrong.
55      */

56     void add(int position, Document document) throws DocumentException;
57
58     /**
59      * Removes a document from the collection.
60      * @param document A document.
61      * @throws DocumentException when the document is not contained
62      * or another error occurs.
63      */

64     void remove(Document document) throws DocumentException;
65     
66     /**
67      * Removes all documents from this collection.
68      * @throws DocumentException when something went wrong.
69      */

70     void clear() throws DocumentException;
71     
72     /**
73      * Checks if this collection contains a specific document.
74      * @param document The document to check.
75      * @return A boolean value.
76      * @throws DocumentException when something went wrong.
77      */

78     boolean contains(Document document) throws DocumentException;
79     
80     /**
81      * Returns the first position of this document in the collection.
82      * @param document The document.
83      * @return An integer.
84      * @throws DocumentException when the document is not contained.
85      */

86     int getFirstPosition(Document document) throws DocumentException;
87     
88     /**
89      * Returns the number of documents in this collection.
90      * @return An integer value.
91      * @throws DocumentException when something went wrong.
92      */

93     int size() throws DocumentException;
94     
95     /**
96      * Saves the XML source of this collection.
97      * @throws DocumentException when something went wrong.
98      */

99     void save() throws DocumentException;
100 }
101
Popular Tags