Source Code Cross Referenced for Instance.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:         * Instance.java
003:         *
004:         * Version: $Revision: 1.2 $
005:         *
006:         * Date: $Date: 2006/07/06 17:02:03 $
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 java.util.ArrayList;
044:        import java.util.List;
045:
046:        import org.dspace.app.xmlui.wing.Message;
047:        import org.dspace.app.xmlui.wing.WingContext;
048:        import org.dspace.app.xmlui.wing.WingException;
049:        import org.xml.sax.ContentHandler;
050:        import org.xml.sax.SAXException;
051:        import org.xml.sax.ext.LexicalHandler;
052:        import org.xml.sax.helpers.NamespaceSupport;
053:
054:        /**
055:         * Instance represents multiple value instances of a field.
056:         * 
057:         * 
058:         * @author Scott Phillips
059:         */
060:
061:        public class Instance extends Container {
062:            /** The name of the field instance element */
063:            public static final String E_INSTANCE = "instance";
064:
065:            /**
066:             * Construct a new field value, when used in a multiple value context
067:             * 
068:             * @param context
069:             *            (Required) The context this element is contained in
070:             */
071:            protected Instance(WingContext context) throws WingException {
072:                super (context);
073:            }
074:
075:            /** ******************************************************************** */
076:            /** Values * */
077:            /** ******************************************************************** */
078:
079:            /**
080:             * Set the raw value of the field removing any previous raw values.
081:             * 
082:             * @param characters
083:             *            (May be null) Field value as a string
084:             */
085:            public Value setValue() throws WingException {
086:                this .removeValueOfType(Value.TYPE_RAW);
087:                Value value = new Value(context, Value.TYPE_RAW);
088:                contents.add(value);
089:                return value;
090:            }
091:
092:            /**
093:             * Set the raw value of the field removing any previous raw values.
094:             * 
095:             * @param characters
096:             *            (May be null) Field value as a string
097:             */
098:            public void setValue(String characters) throws WingException {
099:                Value value = this .setValue();
100:                value.addContent(characters);
101:            }
102:
103:            /**
104:             * Set the raw value of the field removing any previous raw values.
105:             * 
106:             * @param message
107:             *            (Required) A key into the i18n catalogue for translation into
108:             *            the user's preferred language.
109:             */
110:            public void setValue(Message message) throws WingException {
111:                Value value = this .setValue();
112:                value.addContent(message);
113:            }
114:
115:            /**
116:             * Set the raw value of the field removing any previous raw values. This
117:             * will set the field as either checked or unchecked. This should only be
118:             * used on checkbox or radio button fields.
119:             * 
120:             * @param checked
121:             *            (Required) Whether the checkbox is checked or not.
122:             */
123:            public void setValue(boolean checked) throws WingException {
124:                this .removeValueOfType(Value.TYPE_RAW);
125:                Value value = new Value(context, Value.TYPE_RAW, checked);
126:                contents.add(value);
127:            }
128:
129:            /**
130:             * Set the given option as selected.
131:             * 
132:             * @param returnValue
133:             *            (Required) The return value of the option to be selected.
134:             */
135:            public void setOptionSelected(String returnValue)
136:                    throws WingException {
137:                Value value = new Value(context, Value.TYPE_OPTION, returnValue);
138:                contents.add(value);
139:            }
140:
141:            /**
142:             * Set the given option as selected.
143:             * 
144:             * @param returnValue
145:             *            (Required) The return value of the option to be selected.
146:             */
147:            public void setOptionSelected(int returnValue) throws WingException {
148:                setOptionSelected(String.valueOf(returnValue));
149:            }
150:
151:            /** ******************************************************************** */
152:            /** Interpreted Values * */
153:            /** ******************************************************************** */
154:
155:            /**
156:             * Set the interpreted value of the field removing any previous interpreted
157:             * values.
158:             * 
159:             * @param characters
160:             *            (May be null) Field value as a string
161:             */
162:            public Value setInterpretedValue() throws WingException {
163:                removeValueOfType(Value.TYPE_INTERPRETED);
164:                Value value = new Value(context, Value.TYPE_INTERPRETED);
165:                contents.add(value);
166:                return value;
167:            }
168:
169:            /**
170:             * Set the interpreted value of the field removing any previous interpreted
171:             * values.
172:             * 
173:             * @param characters
174:             *            (May be null) Field value as a string
175:             */
176:            public void setInterpretedValue(String characters)
177:                    throws WingException {
178:                Value value = this .setInterpretedValue();
179:                value.addContent(characters);
180:            }
181:
182:            /**
183:             * Set the interpreted value of the field removing any previous interpreted
184:             * values.
185:             * 
186:             * @param message
187:             *            (Required) A key into the i18n catalogue for translation into
188:             *            the user's preferred language.
189:             */
190:            public void setInterpretedValue(Message message)
191:                    throws WingException {
192:                Value value = this .setInterpretedValue();
193:                value.addContent(message);
194:            }
195:
196:            /** ******************************************************************** */
197:            /** Special Values * */
198:            /** ******************************************************************** */
199:
200:            /**
201:             * Add an option value, there may be many of these. These values refrence 
202:             * an option all ready added to the field.
203:             * 
204:             * @param option
205:             *            (Required) The return value of the selected option.
206:             */
207:            public Value addOptionValue(String option) throws WingException {
208:                Value value = new Value(context, Value.TYPE_OPTION, option);
209:                contents.add(value);
210:                return value;
211:            }
212:
213:            /**
214:             * Set the checkbox (or radio) value of this field. This is a parameter
215:             * wheather the field is selected or not along with the return string that
216:             * should be used with this parameter.
217:             * 
218:             * @param checked
219:             *            (Required) determine if the value is selected or not.
220:             * @param characters
221:             *            (may be null) The returned value for this field, if selected.
222:             */
223:            public void setCheckedValue(boolean checked, String characters)
224:                    throws WingException {
225:                this .removeValueOfType(Value.TYPE_RAW);
226:                Value value = new Value(context, Value.TYPE_RAW, checked);
227:                contents.add(value);
228:                value.addContent(characters);
229:            }
230:
231:            /**
232:             * Translate this element and all contained elements into SAX events. The
233:             * events should be routed to the contentHandler found in the WingContext.
234:             * 
235:             * @param contentHandler
236:             *            (Required) The registered contentHandler where SAX events
237:             *            should be routed too.
238:             * @param lexicalHandler
239:             *            (Required) The registered lexicalHandler where lexical events
240:             *            (such as CDATA, DTD, etc) should be routed too.
241:             * @param namespaces
242:             *            (Required) SAX Helper class to keep track of namespaces able
243:             *            to determine the correct prefix for a given namespace URI.
244:             */
245:
246:            public void toSAX(ContentHandler contentHandler,
247:                    LexicalHandler lexicalHandler, NamespaceSupport namespaces)
248:                    throws SAXException {
249:                startElement(contentHandler, namespaces, E_INSTANCE, null);
250:                super .toSAX(contentHandler, lexicalHandler, namespaces);
251:                endElement(contentHandler, namespaces, E_INSTANCE);
252:            }
253:
254:            /**
255:             * dispose
256:             */
257:            public void dispose() {
258:                super .dispose();
259:            }
260:
261:            /**
262:             * Private function to remove all values of a particular type.
263:             * 
264:             * @param removeType
265:             *            The type to be removed.
266:             */
267:            private void removeValueOfType(String removeType) {
268:                List<Value> found = new ArrayList<Value>();
269:                for (AbstractWingElement awe : contents) {
270:                    if (awe instanceof  Value) {
271:                        Value value = (Value) awe;
272:                        if (value.getType().equals(removeType)) {
273:                            found.add(value);
274:                        }
275:                    }
276:                }
277:
278:                for (Value remove : found) {
279:                    contents.remove(remove);
280:                    remove.dispose();
281:                }
282:            }
283:
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.