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


001:        /*
002:         * DCInput.java
003:         *
004:         * Version: $Revision: 2079 $
005:         *
006:         * Date: $Date: 2007-07-20 15:49:01 -0500 (Fri, 20 Jul 2007) $
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.util;
042:
043:        import java.util.List;
044:        import java.util.Map;
045:
046:        import org.dspace.content.MetadataSchema;
047:
048:        /**
049:         * Class representing a line in an input form.
050:         * 
051:         * @author Brian S. Hughes, based on work by Jenny Toves, OCLC
052:         * @version
053:         */
054:        public class DCInput {
055:            /** the DC element name */
056:            private String dcElement = null;
057:
058:            /** the DC qualifier, if any */
059:            private String dcQualifier = null;
060:
061:            /** the DC namespace schema */
062:            private String dcSchema = null;
063:
064:            /** a label describing input */
065:            private String label = null;
066:
067:            /** the input type */
068:            private String inputType = null;
069:
070:            /** is input required? */
071:            private boolean required = false;
072:
073:            /** if required, text to display when missing */
074:            private String warning = null;
075:
076:            /** is input repeatable? */
077:            private boolean repeatable = false;
078:
079:            /** 'hint' text to display */
080:            private String hint = null;
081:
082:            /** if input list-controlled, name of list */
083:            private String valueListName = null;
084:
085:            /** if input list-controlled, the list itself */
086:            private List valueList = null;
087:
088:            /** if non-null, visibility scope restriction */
089:            private String visibility = null;
090:
091:            /** the name of the controlled vocabulary to use */
092:            private String vocabulary = null;
093:
094:            /** is the entry closed to vocabulary terms? */
095:            private boolean closedVocabulary = false;
096:
097:            /**
098:             * Class constructor for creating a DCInput object based on the contents of
099:             * a HashMap
100:             * 
101:             * @param row
102:             *            the corresponding row in the table
103:             */
104:            public DCInput(Map fieldMap, Map listMap) {
105:                dcElement = (String) fieldMap.get("dc-element");
106:                dcQualifier = (String) fieldMap.get("dc-qualifier");
107:
108:                // Default the schema to dublin core
109:                dcSchema = (String) fieldMap.get("dc-schema");
110:                if (dcSchema == null) {
111:                    dcSchema = MetadataSchema.DC_SCHEMA;
112:                }
113:
114:                String repStr = (String) fieldMap.get("repeatable");
115:                repeatable = "true".equalsIgnoreCase(repStr)
116:                        || "yes".equalsIgnoreCase(repStr);
117:                label = (String) fieldMap.get("label");
118:                inputType = (String) fieldMap.get("input-type");
119:                // these types are list-controlled
120:                if ("dropdown".equals(inputType)
121:                        || "qualdrop_value".equals(inputType)
122:                        || "list".equals(inputType)) {
123:                    valueListName = (String) fieldMap.get("value-pairs-name");
124:                    valueList = (List) listMap.get(valueListName);
125:                }
126:                hint = (String) fieldMap.get("hint");
127:                warning = (String) fieldMap.get("required");
128:                required = (warning != null && warning.length() > 0);
129:                visibility = (String) fieldMap.get("visibility");
130:                vocabulary = (String) fieldMap.get("vocabulary");
131:                String closedVocabularyStr = (String) fieldMap
132:                        .get("closedVocabulary");
133:                closedVocabulary = "true".equalsIgnoreCase(closedVocabularyStr)
134:                        || "yes".equalsIgnoreCase(closedVocabularyStr);
135:            }
136:
137:            /**
138:             * Is this DCInput for display in the given scope? The scope should be
139:             * either "workflow" or "submit", as per the input forms definition. If the
140:             * internal visibility is set to "null" then this will always return true.
141:             * 
142:             * @param scope
143:             *            String identifying the scope that this input's visibility
144:             *            should be tested for
145:             * 
146:             * @return whether the input should be displayed or not
147:             */
148:            public boolean isVisible(String scope) {
149:                return (visibility == null || visibility.equals(scope));
150:            }
151:
152:            /**
153:             * Get the repeatable flag for this row
154:             * 
155:             * @return the repeatable flag
156:             */
157:            public boolean isRepeatable() {
158:                return repeatable;
159:            }
160:
161:            /**
162:             * Alternate way of calling isRepeatable()
163:             * 
164:             * @return the repeatable flag
165:             */
166:            public boolean getRepeatable() {
167:                return isRepeatable();
168:            }
169:
170:            /**
171:             * Get the input type for this row
172:             * 
173:             * @return the input type
174:             */
175:            public String getInputType() {
176:                return inputType;
177:            }
178:
179:            /**
180:             * Get the DC element for this form row.
181:             * 
182:             * @return the DC element
183:             */
184:            public String getElement() {
185:                return dcElement;
186:            }
187:
188:            /**
189:             * Get the DC namespace prefix for this form row.
190:             * 
191:             * @return the DC namespace prefix
192:             */
193:            public String getSchema() {
194:                return dcSchema;
195:            }
196:
197:            /**
198:             * Get the warning string for a missing required field, formatted for an
199:             * HTML table.
200:             * 
201:             * @return the string prompt if required field was ignored
202:             */
203:            public String getWarning() {
204:                return warning;
205:            }
206:
207:            /**
208:             * Is there a required string for this form row?
209:             * 
210:             * @return true if a required string is set
211:             */
212:            public boolean isRequired() {
213:                return required;
214:            }
215:
216:            /**
217:             * Get the DC qualifier for this form row.
218:             * 
219:             * @return the DC qualifier
220:             */
221:            public String getQualifier() {
222:                return dcQualifier;
223:            }
224:
225:            /**
226:             * Get the hint for this form row, formatted for an HTML table
227:             * 
228:             * @return the hints
229:             */
230:            public String getHints() {
231:                return hint;
232:            }
233:
234:            /**
235:             * Get the label for this form row.
236:             * 
237:             * @return the label
238:             */
239:            public String getLabel() {
240:                return label;
241:            }
242:
243:            /**
244:             * Get the name of the pairs type
245:             * 
246:             * @return the pairs type name
247:             */
248:            public String getPairsType() {
249:                return valueListName;
250:            }
251:
252:            /**
253:             * Get the name of the pairs type
254:             * 
255:             * @return the pairs type name
256:             */
257:            public List getPairs() {
258:                return valueList;
259:            }
260:
261:            /**
262:             * Get the name of the controlled vocabulary that is associated with this
263:             * field
264:             * 
265:             * @return the name of associated the vocabulary
266:             */
267:            public String getVocabulary() {
268:                return vocabulary;
269:            }
270:
271:            /**
272:             * Set the name of the controlled vocabulary that is associated with this
273:             * field
274:             * 
275:             * @param vocabulary
276:             *            the name of the vocabulary
277:             */
278:            public void setVocabulary(String vocabulary) {
279:                this .vocabulary = vocabulary;
280:            }
281:
282:            /**
283:             * Gets the display string that corresponds to the passed storage string in
284:             * a particular display-storage pair set.
285:             * 
286:             * @param allPairs
287:             *            HashMap of all display-storage pair sets
288:             * @param pairTypeName
289:             *            Name of display-storage pair set to search
290:             * @param storageString
291:             *            the string that gets stored
292:             * 
293:             * @return the displayed string whose selection causes storageString to be
294:             *         stored, null if no match
295:             */
296:            public String getDisplayString(String pairTypeName,
297:                    String storedString) {
298:                if (valueList != null) {
299:                    for (int i = 0; i < valueList.size(); i += 2) {
300:                        if (((String) valueList.get(i + 1))
301:                                .equals(storedString)) {
302:                            return (String) valueList.get(i);
303:                        }
304:                    }
305:                }
306:                return null;
307:            }
308:
309:            /**
310:             * Gets the stored string that corresponds to the passed display string in a
311:             * particular display-storage pair set.
312:             * 
313:             * @param allPairs
314:             *            HashMap of all display-storage pair sets
315:             * @param pairTypeName
316:             *            Name of display-storage pair set to search
317:             * @param displayString
318:             *            the string that gets displayed
319:             * 
320:             * @return the string that gets stored when displayString gets selected,
321:             *         null if no match
322:             */
323:            public String getStoredString(String pairTypeName,
324:                    String displayedString) {
325:                if (valueList != null) {
326:                    for (int i = 0; i < valueList.size(); i += 2) {
327:                        if (((String) valueList.get(i)).equals(displayedString)) {
328:                            return (String) valueList.get(i + 1);
329:                        }
330:                    }
331:                }
332:                return null;
333:            }
334:
335:            /**
336:             * The closed attribute of the vocabulary tag for this field as set in 
337:             * input-forms.xml
338:             * 
339:             * <code> 
340:             * <field>
341:             *     .....
342:             *     <vocabulary closed="true">nsrc</vocabulary>
343:             * </field>
344:             * </code>
345:             * @return the closedVocabulary flags: true if the entry should be restricted 
346:             *         only to vocabulary terms, false otherwise
347:             */
348:            public boolean isClosedVocabulary() {
349:                return closedVocabulary;
350:            }
351:
352:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.