KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > webservices > adminapi > sdk > EntrySet


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * 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. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 package org.apache.roller.webservices.adminapi.sdk;
19
20 import java.util.Arrays JavaDoc;
21 import java.util.List JavaDoc;
22 import org.jdom.Document;
23 import org.jdom.Element;
24
25 /**
26  * This class is the abstract notion of a set of entries.
27  * Weblog resources are represented by sets of entries.
28  *
29  * @author jtb
30  */

31 public abstract class EntrySet extends Entry {
32     /** Entry set types. */
33     public static interface Types {
34         /*
35          * Set of user entries.
36          * A user entry describes a user of the weblog server.
37          */

38         public static final String JavaDoc USERS = "users";
39         /**
40          * Set of weblog entries.
41          * Note that this is not a set of entries in a weblog, but rather,
42          * a set of entries that describe the weblog itself.
43          */

44         public static final String JavaDoc WEBLOGS = "weblogs";
45         /**
46          * Set of member entries.
47          * A member entry describes a user's membership to and
48          * permission with a particular weblog.
49          */

50         public static final String JavaDoc MEMBERS = "members";
51          /**
52           * Set of workspace entries.
53           * This type, along with WORKSPACE and COLLECTION, define
54           * the element that describe the introspection document
55           * for the AAPP service.
56           * <p>
57           * A service is a set of workspaces, and a workspace is a set of
58           * collections.
59           */

60         public static final String JavaDoc SERVICE = "service";
61         /** Set of collection entries. */
62         public static final String JavaDoc WORKSPACE = "workspace";
63     }
64     
65     private List JavaDoc entries = null;
66         
67     /** Get the type of this object. */
68     public abstract String JavaDoc getType();
69     
70     /** Get the entries in this object. */
71     public Entry[] getEntries() {
72         return (Entry[])entries.toArray(new Entry[0]);
73     }
74     
75     /** Set the entries of this object. */
76     public void setEntries(Entry[] entryArray) {
77         entries = Arrays.asList(entryArray);
78     }
79     
80     /** Is this entry set empty? */
81     public boolean isEmpty() {
82         return entries == null || entries.size() == 0;
83     }
84     
85     /** This object as a JDOM Document */
86     public Document toDocument() {
87         Element e = new Element(getType(), NAMESPACE);
88         Document doc = new Document(e);
89         
90         // href
91
e.setAttribute(Attributes.HREF, getHref());
92         
93         // entries
94
for (int i = 0; i < getEntries().length; i++) {
95             e.addContent(getEntries()[i].toDocument().detachRootElement());
96         }
97         
98         return doc;
99     }
100    
101     public boolean equals(Object JavaDoc o) {
102         if ( o == null || o.getClass() != this.getClass()) {
103             return false;
104         }
105                 
106         EntrySet other = (EntrySet)o;
107         
108         if (!areEqual(getHref(), other.getHref())) {
109             return false;
110         }
111         if (!areEqual(getType(), other.getType())) {
112             return false;
113         }
114         if (!areEqual(getEntries(), other.getEntries())) {
115             return false;
116         }
117         
118         return true;
119     }
120 }
121
Popular Tags