File Source: EntrySet.java
/*
P/P * Method: org.apache.roller.weblogger.webservices.adminprotocol.sdk.EntrySet__static_init
*/
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.weblogger.webservices.adminprotocol.sdk;
19
20 import java.util.Arrays;
21 import java.util.List;
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 */
/*
P/P * Method: void org.apache.roller.weblogger.webservices.adminprotocol.sdk.EntrySet()
*
* Postconditions:
* this.entries == null
* this.href == null
*/
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 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 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 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 RAP 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 SERVICE = "service";
61 /** Set of collection entries. */
62 public static final String WORKSPACE = "workspace";
63 }
64
65 private List entries = null;
66
67 /** Get the type of this object. */
68 public abstract String getType();
69
70 /** Get the entries in this object. */
71 public Entry[] getEntries() {
/*
P/P * Method: Entry[] getEntries()
*
* Preconditions:
* this.entries != null
*
* Postconditions:
* init'ed(return_value)
*/
72 return (Entry[])entries.toArray(new Entry[0]);
73 }
74
75 /** Set the entries of this object. */
76 public void setEntries(Entry[] entryArray) {
/*
P/P * Method: void setEntries(Entry[])
*
* Postconditions:
* init'ed(this.entries)
*/
77 entries = Arrays.asList(entryArray);
78 }
79
80 /** Is this entry set empty? */
81 public boolean isEmpty() {
/*
P/P * Method: bool isEmpty()
*
* Preconditions:
* init'ed(this.entries)
*
* Postconditions:
* init'ed(return_value)
*/
82 return entries == null || entries.size() == 0;
83 }
84
85 /** This object as a JDOM Document */
86 public Document toDocument() {
/*
P/P * Method: Document toDocument()
*
* Preconditions:
* this.entries != null
* init'ed(this.href)
*
* Presumptions:
* getEntries(...).length@94 <= 232-1
* getEntries(...).length@95 >= 1
* getEntries(...).length@94 <= getEntries(...).length@95
* java.util.List:toArray(...)@72 != null
* toDocument(...)@95 != null
*
* Postconditions:
* return_value == &new Document(toDocument#2)
* new Document(toDocument#2) num objects == 1
*/
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 o) {
/*
P/P * Method: bool equals(Object)
*
* Preconditions:
* (soft) o.entries != null
* (soft) init'ed(o.href)
* (soft) this.entries != null
* (soft) init'ed(this.href)
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* o: Addr_Set{null}, Inverse{null}
* org.apache.roller.weblogger.webservices.adminprotocol.sdk.EntrySet:areEqual(...)@108: {1}, {0}
* org.apache.roller.weblogger.webservices.adminprotocol.sdk.EntrySet:areEqual(...)@111: {1}, {0}
* org.apache.roller.weblogger.webservices.adminprotocol.sdk.EntrySet:areEqual(...)@114: {1}, {0}
*/
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 }
SofCheck Inspector Build Version : 2.18479
| EntrySet.java |
2009-Jan-02 14:25:44 |
| EntrySet.class |
2009-Sep-04 03:12:46 |
| EntrySet$Types.class |
2009-Sep-04 03:12:46 |