Source Code Cross Referenced for JSMediaType.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » serializer » objects » 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 » Portal » jetspeed 2.1.3 » org.apache.jetspeed.serializer.objects 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jetspeed.serializer.objects;
018:
019:        import java.util.ArrayList;
020:        import java.util.Iterator;
021:        import java.util.List;
022:
023:        import javolution.xml.XMLFormat;
024:        import javolution.xml.stream.XMLStreamException;
025:
026:        import org.apache.commons.lang.StringEscapeUtils;
027:        import org.apache.jetspeed.capabilities.MediaType;
028:
029:        public class JSMediaType {
030:            // private int refID;
031:
032:            private String name;
033:
034:            private int id;
035:
036:            private String characterSet;
037:
038:            private String title;
039:
040:            private String description;
041:
042:            private ArrayList capabilities;
043:
044:            private ArrayList mimeTypes;
045:
046:            private JSClientCapabilities capabilitiesString;
047:
048:            private JSClientMimeTypes mimeTypesString;
049:
050:            public JSMediaType() {
051:                // refID = id;
052:            }
053:
054:            public JSMediaType(MediaType c) {
055:                this .id = c.getMediatypeId();
056:                this .name = c.getName();
057:
058:                this .characterSet = c.getCharacterSet();
059:                this .title = c.getTitle();
060:                this .description = c.getDescription();
061:                capabilities = new ArrayList();
062:                mimeTypes = new ArrayList();
063:
064:            }
065:
066:            /***************************************************************************
067:             * SERIALIZER
068:             */
069:            private static final XMLFormat XML = new XMLFormat(
070:                    JSMediaType.class) {
071:                public void write(Object o, OutputElement xml)
072:                        throws XMLStreamException {
073:
074:                    try {
075:                        JSMediaType g = (JSMediaType) o;
076:                        /** attributes here */
077:
078:                        xml.setAttribute("name", g.name);
079:
080:                        /** named fields HERE */
081:
082:                        xml.add(g.characterSet, "charcterSet", String.class);
083:                        xml.add(g.title, "title", String.class);
084:                        xml.add(g.description, "description", String.class);
085:
086:                        /** implicitly named (through binding) fields here */
087:
088:                        g.capabilitiesString = new JSClientCapabilities(g
089:                                .putTokens(g.capabilities));
090:                        g.mimeTypesString = new JSClientMimeTypes(g
091:                                .putTokens(g.mimeTypes));
092:                        xml.add(g.capabilitiesString);
093:                        xml.add(g.mimeTypesString);
094:
095:                        // xml.add(g.groupString);
096:
097:                    } catch (Exception e) {
098:                        e.printStackTrace();
099:                    }
100:                }
101:
102:                public void read(InputElement xml, Object o) {
103:                    try {
104:                        JSMediaType g = (JSMediaType) o;
105:                        g.name = StringEscapeUtils.unescapeHtml(xml
106:                                .getAttribute("name", ""));
107:
108:                        /** named fields HERE */
109:                        Object o1 = xml.get("charcterSet", String.class); //characterSet
110:                        if ((o1 != null) && (o1 instanceof  String))
111:                            g.characterSet = StringEscapeUtils
112:                                    .unescapeHtml((String) o1);
113:                        g.title = StringEscapeUtils.unescapeHtml((String) xml
114:                                .get("title", String.class)); //title;
115:                        g.description = StringEscapeUtils
116:                                .unescapeHtml((String) xml.get("description",
117:                                        String.class)); //description;
118:
119:                        while (xml.hasNext()) {
120:                            o1 = xml.getNext(); // mime
121:
122:                            if (o1 instanceof  JSClientCapabilities)
123:                                g.capabilitiesString = (JSClientCapabilities) o1; //capabilitiesString;
124:                            else if (o1 instanceof  JSClientMimeTypes)
125:                                g.mimeTypesString = (JSClientMimeTypes) o1; //mimeTypesString;
126:                        }
127:                    } catch (Exception e) {
128:                        e.printStackTrace();
129:                    }
130:                }
131:            };
132:
133:            /**
134:             * @return Returns the characterSet.
135:             */
136:            public String getCharacterSet() {
137:                return characterSet;
138:            }
139:
140:            /**
141:             * @param characterSet The characterSet to set.
142:             */
143:            public void setCharacterSet(String characterSet) {
144:                this .characterSet = characterSet;
145:            }
146:
147:            /**
148:             * @return Returns the description.
149:             */
150:            public String getDescription() {
151:                return description;
152:            }
153:
154:            /**
155:             * @param description The description to set.
156:             */
157:            public void setDescription(String description) {
158:                this .description = description;
159:            }
160:
161:            /**
162:             * @return Returns the id.
163:             */
164:            public int getId() {
165:                return id;
166:            }
167:
168:            /**
169:             * @param id The id to set.
170:             */
171:            public void setId(int id) {
172:                this .id = id;
173:            }
174:
175:            /**
176:             * @return Returns the name.
177:             */
178:            public String getName() {
179:                return name;
180:            }
181:
182:            /**
183:             * @param name The name to set.
184:             */
185:            public void setName(String name) {
186:                this .name = name;
187:            }
188:
189:            /**
190:             * @return Returns the title.
191:             */
192:            public String getTitle() {
193:                return title;
194:            }
195:
196:            /**
197:             * @param title The title to set.
198:             */
199:            public void setTitle(String titel) {
200:                this .title = titel;
201:            }
202:
203:            private String append(JSCapability capability) {
204:                return capability.getName();
205:            }
206:
207:            private String append(JSMimeType mime) {
208:                return mime.getName();
209:            }
210:
211:            private String append(Object s) {
212:                if (s instanceof  JSCapability)
213:                    return append((JSCapability) s);
214:                if (s instanceof  JSMimeType)
215:                    return append((JSMimeType) s);
216:
217:                return s.toString();
218:            }
219:
220:            private String putTokens(ArrayList _list) {
221:                if ((_list == null) || (_list.size() == 0))
222:                    return "";
223:                boolean _start = true;
224:                Iterator _it = _list.iterator();
225:                StringBuffer _sb = new StringBuffer();
226:                while (_it.hasNext()) {
227:                    if (!_start)
228:                        _sb.append(',');
229:                    else
230:                        _start = false;
231:
232:                    _sb.append(append(_it.next()));
233:                }
234:                return _sb.toString();
235:            }
236:
237:            /**
238:             * @return Returns the capabilities.
239:             */
240:            public List getCapabilities() {
241:                return capabilities;
242:            }
243:
244:            /**
245:             * @param capabilities
246:             *            The capabilities to set.
247:             */
248:            public void setCapabilities(ArrayList capabilities) {
249:                this .capabilities = capabilities;
250:            }
251:
252:            /**
253:             * @return Returns the mimeTypes.
254:             */
255:            public List getMimeTypes() {
256:                return mimeTypes;
257:            }
258:
259:            /**
260:             * @param mimeTypes
261:             *            The mimeTypes to set.
262:             */
263:            public void setMimeTypes(ArrayList mimeTypes) {
264:                this .mimeTypes = mimeTypes;
265:            }
266:
267:            public JSClientCapabilities getCapabilitiesString() {
268:                return capabilitiesString;
269:            }
270:
271:            public JSClientMimeTypes getMimeTypesString() {
272:                return mimeTypesString;
273:            }
274:
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.