Source Code Cross Referenced for Workspace.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:        /**
039:         *   Author   : $Author: nst $
040:         *   Date     : $Date: 2007/09/21 15:18:53 $
041:         *   Revision : $Revision: 1.4 $
042:         *   Name     : $Name:  $
043:         */
044:
045:        import java.util.ArrayList;
046:        import java.util.Iterator;
047:        import java.util.List;
048:
049:        import org.purl.sword.base.Namespaces;
050:        import org.w3.atom.ContentType;
051:        import org.w3.atom.Title;
052:
053:        import nu.xom.Element;
054:        import nu.xom.Elements;
055:
056:        /**
057:         * Represents an Atom Publishing Protocol Workspace element. 
058:         * 
059:         * @author Neil Taylor
060:         */
061:        public class Workspace extends XmlElement implements 
062:                SwordElementInterface {
063:            /** 
064:             * The element name that is used in the textual representatin of the XML data. 
065:             */
066:            public static final String ELEMENT_NAME = "workspace";
067:
068:            /**
069:             * The title for the workspace. 
070:             */
071:            private Title title;
072:
073:            /**
074:             * A list of collections associated with this workspace. 
075:             */
076:            private List<Collection> collections;
077:
078:            /**
079:             * Create a new instance of the workspace, with no title. 
080:             */
081:            public Workspace() {
082:                this (null);
083:            }
084:
085:            /**
086:             * Create a new instance of the workspace with the specified title. 
087:             * 
088:             * @param title The title. 
089:             */
090:            public Workspace(String title) {
091:                super ("app", ELEMENT_NAME);
092:                setTitle(title);
093:                collections = new ArrayList<Collection>();
094:            }
095:
096:            /**
097:             * Set the title. The type for the title will be set to 
098:             * <code>ContentType.TEXT</code>
099:             * 
100:             * @param title The title. 
101:             */
102:            public void setTitle(String title) {
103:                if (this .title == null) {
104:                    this .title = new Title();
105:                }
106:                this .title.setContent(title);
107:                this .title.setType(ContentType.TEXT);
108:
109:            }
110:
111:            /**
112:             * Get the content of the Title element. 
113:             * 
114:             * @return The title. 
115:             */
116:            public String getTitle() {
117:                if (title == null) {
118:                    return null;
119:                }
120:
121:                return title.getContent();
122:            }
123:
124:            /**
125:             * Add a collection to the Workspace. 
126:             * 
127:             * @param collection The collection. 
128:             */
129:            public void addCollection(Collection collection) {
130:                collections.add(collection);
131:            }
132:
133:            /**
134:             * Get an Iterator over the collections. 
135:             * 
136:             * @return An iterator. 
137:             */
138:            public Iterator<Collection> collectionIterator() {
139:                return collections.iterator();
140:            }
141:
142:            /**
143:             * Get a list of the collections
144:             * 
145:             * @ return A list.
146:             */
147:            public List<Collection> getCollections() {
148:                return collections;
149:            }
150:
151:            /**
152:             * Marshall the data in this element to an Element. 
153:             * 
154:             * @return An element that contains the data in this object. 
155:             */
156:            public Element marshall() {
157:                // convert data into XOM elements and return the 'root', i.e. the one 
158:                // that represents the collection. 
159:                Element workspace = new Element(ELEMENT_NAME, Namespaces.NS_APP);
160:
161:                workspace.appendChild(title.marshall());
162:
163:                for (Collection item : collections) {
164:                    workspace.appendChild(item.marshall());
165:                }
166:
167:                return workspace;
168:            }
169:
170:            /**
171:             * Unmarshall the workspace element into the data in this object. 
172:             * 
173:             * @throws UnmarshallException If the element does not contain a
174:             *                             workspace element or if there are problems
175:             *                             accessing the data. 
176:             */
177:            public void unmarshall(Element workspace)
178:                    throws UnmarshallException {
179:                if (!isInstanceOf(workspace, ELEMENT_NAME, Namespaces.NS_APP)) {
180:                    throw new UnmarshallException(
181:                            "Not an app:workspace element");
182:                }
183:
184:                try {
185:                    collections.clear();
186:
187:                    // retrieve all of the sub-elements
188:                    Elements elements = workspace.getChildElements();
189:                    Element element = null;
190:                    int length = elements.size();
191:
192:                    for (int i = 0; i < length; i++) {
193:                        element = elements.get(i);
194:                        // FIXME - atom assumes that it has been defined. WHAT DID I MEAN???
195:                        if (isInstanceOf(element, "title", Namespaces.NS_ATOM)) {
196:                            title = new Title();
197:                            title.unmarshall(element);
198:                        } else if (isInstanceOf(element, "collection",
199:                                Namespaces.NS_APP)) {
200:                            Collection collection = new Collection();
201:                            collection.unmarshall(element);
202:                            collections.add(collection);
203:                        }
204:                    }
205:                } catch (Exception ex) {
206:                    InfoLogger.getLogger().writeError(
207:                            "Unable to parse an element in workspace: "
208:                                    + ex.getMessage());
209:                    throw new UnmarshallException(
210:                            "Unable to parse element in workspace.", ex);
211:                }
212:            }
213:
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.