KickJava   Java API By Example, From Geeks To Geeks.

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


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: DocumentSet.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.cms.publication;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.List JavaDoc;
24
25 /**
26  * A set of documents.
27  */

28 public class DocumentSet {
29
30     /**
31      * Ctor.
32      */

33     public DocumentSet() {
34     }
35     
36     /**
37      * Ctor.
38      * @param documents The initial documents.
39      */

40     public DocumentSet(Document[] documents) {
41         for (int i = 0; i < documents.length; i++) {
42             add(documents[i]);
43         }
44     }
45
46     private List JavaDoc documents = new ArrayList JavaDoc();
47
48     /**
49      * Returns the documents contained in this set.
50      *
51      * @return An array of documents.
52      */

53     public Document[] getDocuments() {
54         return (Document[]) documents.toArray(new Document[documents.size()]);
55     }
56
57     /**
58      * Adds a document to this set.
59      *
60      * @param document The document to add.
61      */

62     public void add(Document document) {
63         assert document != null;
64         assert !documents.contains(document);
65         documents.add(document);
66     }
67
68     /**
69      * Checks if this set is empty.
70      *
71      * @return A boolean value.
72      */

73     public boolean isEmpty() {
74         return documents.isEmpty();
75     }
76     
77 }
78
Popular Tags