Source Code Cross Referenced for SWORDEntry.java in  » Content-Management-System » dspace » org » purl » sword » base » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » dspace » org.purl.sword.base 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2007, Aberystwyth University
003:         *
004:         * All rights reserved.
005:         * 
006:         * Redistribution and use in source and binary forms, with or without 
007:         * modification, are permitted provided that the following conditions 
008:         * are met:
009:         * 
010:         *  - Redistributions of source code must retain the above 
011:         *    copyright notice, this list of conditions and the 
012:         *    following disclaimer.
013:         *  
014:         *  - Redistributions in binary form must reproduce the above copyright 
015:         *    notice, this list of conditions and the following disclaimer in 
016:         *    the documentation and/or other materials provided with the 
017:         *    distribution.
018:         *    
019:         *  - Neither the name of the Centre for Advanced Software and 
020:         *    Intelligent Systems (CASIS) nor the names of its 
021:         *    contributors may be used to endorse or promote products derived 
022:         *    from this software without specific prior written permission.
023:         * 
024:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
025:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
026:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
027:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
028:         * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
029:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
030:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
031:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
032:         * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
033:         * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
034:         * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
035:         * SUCH DAMAGE.
036:         */package org.purl.sword.base;
037:
038:        import nu.xom.Element;
039:        import nu.xom.Elements;
040:
041:        import org.purl.sword.base.Namespaces;
042:        import org.w3.atom.Entry;
043:
044:        /**
045:         * Extension of the ATOM Entry class. This adds support for the additional 
046:         * SWORD elements. These elements reside inside the ATOM Entry object, 
047:         * created in org.w3.atom.Entry class. 
048:         * 
049:         * @author Neil Taylor
050:         */
051:        public class SWORDEntry extends Entry {
052:            /**
053:             * Specifies whether the document was run in noOp mode, i.e. 
054:             * if the document records that no operation was taken for the 
055:             * deposit other than to generate a response. 
056:             */
057:            private boolean noOp;
058:
059:            /**
060:             * Use to supply a verbose description. 
061:             */
062:            private String verboseDescription;
063:
064:            /**
065:             * Used for a human readable statement about what treatment 
066:             * the deposited resource has received. Include either a
067:             * text description or a URI. 
068:             */
069:            private String treatment;
070:
071:            /**
072:             * Used to record the format namespace. 
073:             */
074:            private String formatNamespace;
075:
076:            /**
077:             * Used to determine if the noOp value has been set.
078:             */
079:            private boolean noOpSet;
080:
081:            /**
082:             * Create a new instance of the class. 
083:             */
084:            public SWORDEntry() {
085:                // NO BODY 
086:            }
087:
088:            /**
089:             * Get the current value of NoOp.  
090:             * 
091:             * @return True if the value is set, false otherwise. 
092:             */
093:            public boolean isNoOp() {
094:                return noOp;
095:            }
096:
097:            /**
098:             * Call this method to set noOp. It should be called even by internal 
099:             * methods so that the object can determine if the value has been set 
100:             * or whether it just holds the default value.  
101:             * 
102:             * @param noOp
103:             */
104:            public void setNoOp(boolean noOp) {
105:                this .noOp = noOp;
106:                this .noOpSet = true;
107:            }
108:
109:            /**
110:             * Determine if the noOp value has been set. This should be called 
111:             * if you want to know whether false for noOp means that it is the 
112:             * default value (i.e. no code has set it) or it is a value that
113:             * has been actively set. 
114:             * 
115:             * @return True if the value has been set. Otherwise, false. 
116:             */
117:            public boolean isNoOpSet() {
118:                return noOpSet;
119:            }
120:
121:            /**
122:             * Get the Verbose Description for this entry. 
123:             * 
124:             * @return The description. 
125:             */
126:            public String getVerboseDescription() {
127:                return verboseDescription;
128:            }
129:
130:            /**
131:             * Set the verbose description. 
132:             * 
133:             * @param verboseDescription The description. 
134:             */
135:            public void setVerboseDescription(String verboseDescription) {
136:                this .verboseDescription = verboseDescription;
137:            }
138:
139:            /**
140:             * Get the treatment value. 
141:             * 
142:             * @return The treatment. 
143:             */
144:            public String getTreatment() {
145:                return treatment;
146:            }
147:
148:            /**
149:             * Set the treatment value. 
150:             *  
151:             * @param treatment The treatment. 
152:             */
153:            public void setTreatment(String treatment) {
154:                this .treatment = treatment;
155:            }
156:
157:            /**
158:             * Overrides the marshall method in the parent Entry. This will 
159:             * call the parent marshall method and then add the additional 
160:             * elements that have been added in this subclass.  
161:             */
162:            public Element marshall() {
163:                Element entry = super .marshall();
164:
165:                if (treatment != null) {
166:                    Element treatmentElement = new Element("sword:treatment",
167:                            Namespaces.NS_SWORD);
168:                    treatmentElement.appendChild(treatment);
169:                    entry.appendChild(treatmentElement);
170:                }
171:
172:                if (formatNamespace != null) {
173:                    Element formatNamespaceElement = new Element(
174:                            "sword:formatNamespace", Namespaces.NS_SWORD);
175:                    formatNamespaceElement.appendChild(formatNamespace);
176:                    entry.appendChild(formatNamespaceElement);
177:                }
178:
179:                if (verboseDescription != null) {
180:                    Element verboseDescriptionElement = new Element(
181:                            "sword:verboseDescription", Namespaces.NS_SWORD);
182:                    verboseDescriptionElement.appendChild(verboseDescription);
183:                    entry.appendChild(verboseDescriptionElement);
184:                }
185:
186:                if (noOpSet) {
187:                    Element noOpElement = new Element("sword:noOp",
188:                            Namespaces.NS_SWORD);
189:                    noOpElement.appendChild(Boolean.toString(noOp));
190:                    entry.appendChild(noOpElement);
191:                }
192:
193:                return entry;
194:            }
195:
196:            /**
197:             * Overrides the unmarshall method in the parent Entry. This will 
198:             * call the parent method to parse the general Atom elements and
199:             * attributes. This method will then parse the remaining sword
200:             * extensions that exist in the element. 
201:             * 
202:             * @param entry The entry to parse. 
203:             * 
204:             * @throws UnmarshallException If the entry is not an atom:entry 
205:             *              or if there is an exception extracting the data. 
206:             */
207:            public void unmarshall(Element entry) throws UnmarshallException {
208:                super .unmarshall(entry);
209:
210:                try {
211:                    // retrieve all of the sub-elements
212:                    Elements elements = entry.getChildElements();
213:                    Element element = null;
214:                    int length = elements.size();
215:
216:                    for (int i = 0; i < length; i++) {
217:                        element = elements.get(i);
218:
219:                        if (isInstanceOf(element, "treatment",
220:                                Namespaces.NS_SWORD)) {
221:                            treatment = unmarshallString(element);
222:                        } else if (isInstanceOf(element, "formatNamespace",
223:                                Namespaces.NS_SWORD)) {
224:                            formatNamespace = unmarshallString(element);
225:                        } else if (isInstanceOf(element, "noOp",
226:                                Namespaces.NS_SWORD)) {
227:                            setNoOp(unmarshallBoolean(element));
228:                        } else if (isInstanceOf(element, "verboseDescription",
229:                                Namespaces.NS_SWORD)) {
230:                            verboseDescription = unmarshallString(element);
231:                        }
232:                    } // for
233:
234:                } catch (UnmarshallException ex) {
235:                    InfoLogger.getLogger().writeError(
236:                            "Error parsing SWORDEntry. " + ex.getMessage());
237:                    throw new UnmarshallException("Error parsing SWORD Entry",
238:                            ex);
239:                }
240:
241:            }
242:
243:            /**
244:             * Get the format namespace. 
245:             * 
246:             * @return The format namespace. 
247:             */
248:            public String getFormatNamespace() {
249:                return formatNamespace;
250:            }
251:
252:            /**
253:             * Set the format namespace. 
254:             * 
255:             * @param formatNamespace The format namespace. 
256:             */
257:            public void setFormatNamespace(String formatNamespace) {
258:                this.formatNamespace = formatNamespace;
259:            }
260:
261:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.