File Source: Entry.java
/*
P/P * Method: org.apache.roller.weblogger.webservices.adminprotocol.sdk.Entry$Attributes__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.io.IOException;
21 import java.io.StringWriter;
22 import java.io.Writer;
23 import java.util.Arrays;
24 import org.jdom.Document;
25 import org.jdom.Namespace;
26 import org.jdom.output.Format;
27 import org.jdom.output.XMLOutputter;
28
29 /**
30 * This class is the abstract notion of an entry.
31 * Weblog resources are represented by sets of entries.
32 */
/*
P/P * Method: void org.apache.roller.weblogger.webservices.adminprotocol.sdk.Entry()
*
* Postconditions:
* this.href == null
*/
33 public abstract class Entry {
/*
P/P * Method: org.apache.roller.weblogger.webservices.adminprotocol.sdk.Entry__static_init
*
* Postconditions:
* init'ed(NAMESPACE)
*/
34 protected static final Namespace NAMESPACE = Namespace.getNamespace("http://purl.org/apache/roller/rap#");
35
36 /** Entry types. */
37 public static interface Types {
38 /**
39 * User entry.
40 * A user entry is contained within a user entry set.
41 */
42 public static final String USER = "user";
43 /**
44 * Weblog entry.
45 * A weblog entry is contained within a weblog entry set.
46 */
47 public static final String WEBLOG = "weblog";
48 /**
49 * Member entry.
50 * A member entry is contained within a member entry set.
51 */
52 public static final String MEMBER = "member";
53 /**
54 * Collection entry.
55 * A collection entry is contained within a workspace, which is
56 * contained within a service.
57 */
58 public static final String COLLECTION = "collection";
59 }
60
61 /** XML attributes common to all entry types. */
62 protected static interface Attributes {
63 public static final String HREF = "href";
64 }
65
66 private String href = null;
67
68 /** Get the HREF that identifies this entry. */
69 public String getHref() {
/*
P/P * Method: String getHref()
*
* Preconditions:
* init'ed(this.href)
*
* Postconditions:
* return_value == this.href
* init'ed(return_value)
*/
70 return href;
71 }
72
73 /** Set the HREF that identifies this entry. */
74 public void setHref(String href) {
/*
P/P * Method: void setHref(String)
*
* Postconditions:
* this.href == href
* init'ed(this.href)
*/
75 this.href = href;
76 }
77
78 /** This entry, as a JDOM Document object. */
79 public abstract Document toDocument();
80
81 /**
82 * This entry, as a String (XML).
83 */
84 public String toString() {
/*
P/P * Method: String toString()
*
* Postconditions:
* java.lang.Object:toString(...)._tainted == 0
* return_value == &java.lang.Object:toString(...)
*/
85 Writer writer = new StringWriter();
86 XMLOutputter outputter = new XMLOutputter();
87 outputter.setFormat(Format.getPrettyFormat());
88 try {
89 outputter.output(toDocument(), writer);
90 writer.close();
91 } catch (IOException ioe) {
92 throw new IllegalStateException(ioe.getMessage());
93 }
94
95 return writer.toString();
96 }
97
98 public abstract String getType();
99
100 public boolean equals(Object o) {
/*
P/P * Method: bool equals(Object)
*
* Preconditions:
* (soft) init'ed(o.href)
* (soft) init'ed(this.href)
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* o: Addr_Set{null}, Inverse{null}
*/
101 if ( o == null || o.getClass() != this.getClass()) {
102 return false;
103 }
104
105 Entry other = (Entry)o;
106
107 if (!areEqual(getHref(), other.getHref())) {
108 return false;
109 }
110 if (!areEqual(getType(), other.getType())) {
111 return false;
112 }
113
114 return true;
115 }
116
117 protected static boolean areEqual(Object o1, Object o2) {
/*
P/P * Method: bool areEqual(Object, Object)
*
* Postconditions:
* init'ed(return_value)
*/
118 return o1 == null ? o2 == null : o1.equals(o2);
119 }
120
121 protected static boolean areEqual(Object[] oa1, Object[] oa2) {
/*
P/P * Method: bool areEqual(Object[], Object[])
*
* Postconditions:
* init'ed(return_value)
*/
122 return oa1 == null ? oa2 == null : Arrays.equals(oa1, oa2);
123 }
124 }
SofCheck Inspector Build Version : 2.18479
| Entry.java |
2009-Jan-02 14:24:46 |
| Entry.class |
2009-Sep-04 03:12:46 |
| Entry$Attributes.class |
2009-Sep-04 03:12:46 |
| Entry$Types.class |
2009-Sep-04 03:12:46 |