File Source: AppModuleParser.java
/*
P/P * Method: org.apache.roller.weblogger.webservices.atomprotocol.AppModuleParser__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.atomprotocol;
19
20 import org.apache.roller.util.DateUtil;
21 import org.jdom.Element;
22 import org.jdom.Namespace;
23
24 import com.sun.syndication.feed.module.Module;
25 import com.sun.syndication.io.ModuleParser;
26
/*
P/P * Method: void org.apache.roller.weblogger.webservices.atomprotocol.AppModuleParser()
*/
27 public class AppModuleParser implements ModuleParser {
28
29 public String getNamespaceUri() {
/*
P/P * Method: String getNamespaceUri()
*
* Postconditions:
* return_value == &"http:..www.w3.org.2007.app"
*/
30 return AppModule.URI;
31 }
32
33 public Namespace getContentNamespace() {
/*
P/P * Method: Namespace getContentNamespace()
*
* Postconditions:
* init'ed(return_value)
*/
34 return Namespace.getNamespace(AppModule.URI);
35 }
36
37 public Module parse(Element elem) {
/*
P/P * Method: Module parse(Element)
*
* Preconditions:
* elem != null
*
* Postconditions:
* return_value == &new AppModuleImpl(parse#1)
* new AppModuleImpl(parse#1) num objects == 1
* init'ed(return_value.draft)
* init'ed(return_value.edited)
*
* Test Vectors:
* java.lang.String:equals(...)@44: {0}, {1}
* java.lang.String:equals(...)@45: {0}, {1}
* org.jdom.Element:getChild(...)@40: Addr_Set{null}, Inverse{null}
* org.jdom.Element:getChild(...)@42: Addr_Set{null}, Inverse{null}
* org.jdom.Element:getChild(...)@48: Addr_Set{null}, Inverse{null}
*/
38 boolean foundSomething = false;
39 AppModule m = new AppModuleImpl();
40 Element control = elem.getChild("control", getContentNamespace());
41 if (control != null) {
42 Element draftElem = control.getChild("draft", getContentNamespace());
43 if (draftElem != null) {
44 if ("yes".equals(draftElem.getText())) m.setDraft(true);
45 if ("no".equals(draftElem.getText())) m.setDraft(false);
46 }
47 }
48 Element edited = elem.getChild("edited", getContentNamespace());
49 if (edited != null) {
50 try {
51 m.setEdited(DateUtil.parseIso8601(edited.getTextTrim()));
52 } catch (Exception ignored) {}
53 }
54 return m;
55 }
56 }
57
SofCheck Inspector Build Version : 2.18479
| AppModuleParser.java |
2009-Jan-02 14:25:02 |
| AppModuleParser.class |
2009-Sep-04 03:12:46 |