Source Code Cross Referenced for Content.java in  » Content-Management-System » dspace » org » w3 » atom » 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.w3.atom 
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.w3.atom;
037:
038:        import nu.xom.Attribute;
039:        import nu.xom.Element;
040:
041:        import org.purl.sword.base.InfoLogger;
042:        import org.purl.sword.base.Namespaces;
043:        import org.purl.sword.base.SwordElementInterface;
044:        import org.purl.sword.base.UnmarshallException;
045:        import org.purl.sword.base.XmlElement;
046:
047:        /**
048:         * Represents an ATOM Content element. 
049:         * 
050:         * @author Neil Taylor
051:         *
052:         */
053:        public class Content extends XmlElement implements 
054:                SwordElementInterface {
055:            /**
056:             * The identifier for the src attribute. 
057:             */
058:            public static final String ATTR_SRC = "src";
059:
060:            /**
061:             * The identifier for the type attribute. 
062:             */
063:            public static final String ATTR_TYPE = "type";
064:
065:            /**
066:             * The data for the type attribute. 
067:             */
068:            private String type;
069:
070:            /**
071:             * The data for the source attribute. 
072:             */
073:            private String source;
074:
075:            /**
076:             * Create a new instance and set the prefix to 
077:             * 'atom' and the local name to 'content'.  
078:             */
079:            public Content() {
080:                super ("atom", "content");
081:            }
082:
083:            /**
084:             * Get the Source. 
085:             * 
086:             * @return The Source. 
087:             */
088:            public String getSource() {
089:                return source;
090:            }
091:
092:            /**
093:             * Set the Source. 
094:             * 
095:             * @param source The source. 
096:             */
097:            public void setSource(String source) {
098:                this .source = source;
099:            }
100:
101:            /**
102:             * Get the type. 
103:             * 
104:             * @return The type. 
105:             */
106:            public String getType() {
107:                return type;
108:            }
109:
110:            /**
111:             * Set the type for the content. This should match the pattern 
112:             * ".* /.*" [Note, there is no space before the /, this has been added
113:             * to allow this text to be written in a Java comment.]. 
114:             * 
115:             * An example of the type is <code>application/zip</code>. 
116:             * 
117:             * @param type The specified type. 
118:             * @throws InvalidMediaTypeException If the specified type is null or
119:             * it does not match the specified pattern. 
120:             */
121:            public void setType(String type) throws InvalidMediaTypeException {
122:                if (type == null || !type.matches(".*/.*")) {
123:                    throw new InvalidMediaTypeException("Type: '" + type
124:                            + "' does not match .*/.*");
125:                }
126:
127:                this .type = type;
128:            }
129:
130:            /**
131:             * Marshall the data in this object to an Element object.
132:             * 
133:             * @return A XOM Element that holds the data for this Content element. 
134:             */
135:            public Element marshall() {
136:                Element content = new Element(getQualifiedName(),
137:                        Namespaces.NS_ATOM);
138:
139:                if (type != null) {
140:                    Attribute typeAttribute = new Attribute(ATTR_TYPE, type);
141:                    content.addAttribute(typeAttribute);
142:                }
143:
144:                if (source != null) {
145:                    Attribute typeAttribute = new Attribute(ATTR_SRC, source);
146:                    content.addAttribute(typeAttribute);
147:                }
148:
149:                return content;
150:            }
151:
152:            /**
153:             * Unmarshall the content element into the data in this object. 
154:             * 
155:             * @throws UnmarshallException If the element does not contain a
156:             *                             content element or if there are problems
157:             *                             accessing the data. 
158:             */
159:            public void unmarshall(Element content) throws UnmarshallException {
160:                if (!isInstanceOf(content, localName, Namespaces.NS_ATOM)) {
161:                    throw new UnmarshallException(
162:                            "Element is not of the correct type");
163:                }
164:
165:                try {
166:                    // get the attributes
167:                    int attributeCount = content.getAttributeCount();
168:                    Attribute attribute = null;
169:                    for (int i = 0; i < attributeCount; i++) {
170:                        attribute = content.getAttribute(i);
171:                        String name = attribute.getQualifiedName();
172:                        if (ATTR_TYPE.equals(name)) {
173:                            type = attribute.getValue();
174:                        }
175:
176:                        if (ATTR_SRC.equals(name)) {
177:                            source = attribute.getValue();
178:                        }
179:                    }
180:                } catch (Exception ex) {
181:                    InfoLogger.getLogger().writeError(
182:                            "Unable to parse an element in Content: "
183:                                    + ex.getMessage());
184:                    throw new UnmarshallException("Error parsing Content", ex);
185:                }
186:            }
187:
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.