Source Code Cross Referenced for Metadata.java in  » Content-Management-System » dspace » org » dspace » app » xmlui » wing » element » 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.dspace.app.xmlui.wing.element 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Metadata.java
003:         *
004:         * Version: $Revision: 1.6 $
005:         *
006:         * Date: $Date: 2006/08/08 21:59:25 $
007:         *
008:         * Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
009:         * Institute of Technology.  All rights reserved.
010:         *
011:         * Redistribution and use in source and binary forms, with or without
012:         * modification, are permitted provided that the following conditions are
013:         * met:
014:         *
015:         * - Redistributions of source code must retain the above copyright
016:         * notice, this list of conditions and the following disclaimer.
017:         *
018:         * - Redistributions in binary form must reproduce the above copyright
019:         * notice, this list of conditions and the following disclaimer in the
020:         * documentation and/or other materials provided with the distribution.
021:         *
022:         * - Neither the name of the Hewlett-Packard Company nor the name of the
023:         * Massachusetts Institute of Technology nor the names of their
024:         * contributors may be used to endorse or promote products derived from
025:         * this software without specific prior written permission.
026:         *
027:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028:         * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031:         * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033:         * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034:         * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036:         * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037:         * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038:         * DAMAGE.
039:         */
040:
041:        package org.dspace.app.xmlui.wing.element;
042:
043:        import org.dspace.app.xmlui.wing.AttributeMap;
044:        import org.dspace.app.xmlui.wing.WingContext;
045:        import org.dspace.app.xmlui.wing.WingException;
046:        import org.xml.sax.ContentHandler;
047:        import org.xml.sax.SAXException;
048:        import org.xml.sax.ext.LexicalHandler;
049:        import org.xml.sax.helpers.NamespaceSupport;
050:
051:        /**
052:         * This is a class representing an individual metadata field in sudo-dublin core
053:         * format. The metadata elements carries generic metadata information in the
054:         * form of an attribute-value pair.
055:         * 
056:         * @author Scott Phillips
057:         */
058:
059:        public class Metadata extends TextContainer implements  MetadataElement {
060:            /** The name of the metadata element */
061:            public static final String E_METADATA = "metadata";
062:
063:            /** The name of the element attribute */
064:            public static final String A_ELEMENT = "element";
065:
066:            /** The name of the qualifier attribute */
067:            public static final String A_QUALIFIER = "qualifier";
068:
069:            /** The name of the language attribute */
070:            public static final String A_LANGUAGE = "lang";
071:
072:            /** The metadata's element */
073:            private String element;
074:
075:            /** The metadata's qualifier */
076:            private String qualifier;
077:
078:            /** The metadata's language */
079:            private String language;
080:
081:            /** 
082:             * Determine the addititive model for the metadata, should 
083:             * the metadata allways be added to the document or only if 
084:             * it does not allready exist?
085:             */
086:            private boolean allowMultiple;
087:
088:            /**
089:             * Construct a new metadata.
090:             * 
091:             * @param element
092:             *            (Required) The element of this metadata
093:             * @param qualifier
094:             *            (May be null) The qualifier of this metadata
095:             * @param language
096:             *            (May be null) the language of this metadata
097:             * @param allowMultiple
098:             *            (Required) Are multipe metadata elements with the same element,
099:             *            qualifier, and language allowed?
100:             */
101:            protected Metadata(WingContext context, String element,
102:                    String qualifier, String language, boolean allowMultiple)
103:                    throws WingException {
104:                super (context);
105:                this .element = element;
106:                this .qualifier = qualifier;
107:                this .language = language;
108:                this .allowMultiple = allowMultiple;
109:            }
110:
111:            /**
112:             * If an metadata with the same element, qualifier, and language exist
113:             * within the document should this metadata element be added into the
114:             * document or should only one metadata be allowed.
115:             */
116:            protected boolean allowMultiple() {
117:                return this .allowMultiple;
118:            }
119:
120:            /**
121:             * Determine if the given element, qualifier, and lang are equal to this
122:             * metadata.
123:             * 
124:             * @param element
125:             *            (Required) The element of this metadata
126:             * @param qualifier
127:             *            (May be null) The qualifier of this metadata
128:             * @param language
129:             *            (May be null) the language of this metadata
130:             * @return True if the given parameters are equal to this metadata.
131:             */
132:            protected boolean equals(String element, String qualifier,
133:                    String language) {
134:                // Element should never be null.
135:                if (this .element == null || element == null)
136:                    return false;
137:
138:                if (stringEqualsWithNulls(this .element, element) == false)
139:                    return false;
140:                if (stringEqualsWithNulls(this .qualifier, qualifier) == false)
141:                    return false;
142:                if (stringEqualsWithNulls(this .language, language) == false)
143:                    return false;
144:
145:                // Element, qualifier, and language are equal.
146:                return true;
147:            }
148:
149:            /**
150:             * This is just a silly private method to make the method above easier to
151:             * read. Compare the two parameters to see if they are equal while taking
152:             * into account nulls. So if both values are null that is considered an
153:             * equals.
154:             * 
155:             * The method is meant to replace the syntax current.equals(test) so that it
156:             * works when current is null.
157:             * 
158:             * @param current
159:             *            (May be null) The current value.
160:             * @param test
161:             *            (May be null) The value to be compared to current
162:             * @return If the strings are equal.
163:             */
164:            private boolean stringEqualsWithNulls(String current, String test) {
165:                if (current == null) {
166:                    if (test == null)
167:                        return true;
168:                    else
169:                        return false;
170:                } else {
171:                    return current.equals(test);
172:                }
173:            }
174:
175:            /**
176:             * Translate into SAX events.
177:             * 
178:             * @param contentHandler
179:             *            (Required) The registered contentHandler where SAX events
180:             *            should be routed too.
181:             * @param lexicalHandler
182:             *            (Required) The registered lexicalHandler where lexical 
183:             *            events (such as CDATA, DTD, etc) should be routed too.
184:             * @param namespaces
185:             *            (Required) SAX Helper class to keep track of namespaces able
186:             *            to determine the correct prefix for a given namespace URI.
187:             */
188:            public void toSAX(ContentHandler contentHandler,
189:                    LexicalHandler lexicalHandler, NamespaceSupport namespaces)
190:                    throws SAXException {
191:                AttributeMap attributes = new AttributeMap();
192:                attributes.put(A_ELEMENT, element);
193:                if (this .qualifier != null)
194:                    attributes.put(A_QUALIFIER, qualifier);
195:                if (this .language != null)
196:                    attributes.put(A_LANGUAGE, language);
197:
198:                startElement(contentHandler, namespaces, E_METADATA, attributes);
199:                super .toSAX(contentHandler, lexicalHandler, namespaces);
200:                endElement(contentHandler, namespaces, E_METADATA);
201:            }
202:
203:            /**
204:             * dispose()
205:             */
206:            public void dispose() {
207:                super.dispose();
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.