Source Code Cross Referenced for JBIComponentInfo.java in  » ESB » open-esb » com » sun » jbi » ui » common » 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 » ESB » open esb » com.sun.jbi.ui.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)JBIComponentInfo.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.ui.common;
030:
031:        import java.io.PrintWriter;
032:        import java.io.Reader;
033:        import java.io.StringReader;
034:        import java.io.StringWriter;
035:        import java.util.ArrayList;
036:        import java.util.Collections;
037:        import java.util.Comparator;
038:        import java.util.List;
039:        import org.w3c.dom.Document;
040:        import org.w3c.dom.Element;
041:        import org.w3c.dom.NodeList;
042:
043:        /** This class reads/writes the component info list xml.
044:         *
045:         * @author Sun Microsystems, Inc.
046:         */
047:        public class JBIComponentInfo {
048:
049:            /** namespace */
050:            public static final String XMLNS = "http://java.sun.com/xml/ns/jbi/component-info-list";
051:
052:            /** unknown type */
053:            public static final String UNKNOWN_TYPE = "unknown";
054:            /** Binding type  */
055:            public static final String BINDING_TYPE = "binding-component";
056:            /** Engine Type */
057:            public static final String ENGINE_TYPE = "service-engine";
058:            /** Namespace Type  */
059:            public static final String SHARED_LIBRARY_TYPE = "shared-library";
060:
061:            /** state  Loaded status.  */
062:            public static final String UNKNOWN_STATE = "Unknown";
063:            /** Installed status */
064:            public static final String SHUTDOWN_STATE = "Shutdown";
065:            /** Stopped status  */
066:            public static final String STOPPED_STATE = "Stopped";
067:            /** Started status */
068:            public static final String STARTED_STATE = "Started";
069:
070:            /**
071:             * Holds value of property name.
072:             */
073:            private String mName;
074:
075:            /**
076:             * Holds value of property state.
077:             */
078:            private String mState;
079:
080:            /**
081:             * Holds value of property description.
082:             */
083:            private String mDescription;
084:
085:            /**
086:             * Holds value of property type.
087:             */
088:            private String mType;
089:
090:            /** Creates a new instance of JBIComponentInfo */
091:            public JBIComponentInfo() {
092:                this .mType = "";
093:                this .mState = "";
094:                this .mName = "";
095:                this .mDescription = "";
096:            }
097:
098:            /** Creates a new instance of JBIComponentInfo
099:             * @param type type
100:             * @param state state
101:             * @param name name
102:             * @param description description
103:             */
104:            public JBIComponentInfo(String type, String state, String name,
105:                    String description) {
106:                this .mType = type;
107:                this .mState = state;
108:                this .mName = name;
109:                this .mDescription = description;
110:            }
111:
112:            /**
113:             * Getter for property aliasName.
114:             * @return Value of property aliasName.
115:             */
116:            public String getName() {
117:                return this .mName;
118:            }
119:
120:            /**
121:             * Setter for property aliasName.
122:             * @param name New value of property aliasName.
123:             */
124:            public void setName(String name) {
125:                this .mName = name;
126:            }
127:
128:            /**
129:             * Getter for property state.
130:             * @return Value of property state.
131:             */
132:            public String getState() {
133:                return this .mState;
134:            }
135:
136:            /**
137:             * Setter for property state.
138:             * @param state New value of property state.
139:             */
140:            public void setState(String state) {
141:                this .mState = state;
142:            }
143:
144:            /**
145:             * Getter for property description.
146:             * @return Value of property description.
147:             */
148:            public String getDescription() {
149:                return this .mDescription;
150:            }
151:
152:            /**
153:             * Setter for property description.
154:             * @param description New value of property description.
155:             */
156:            public void setDescription(String description) {
157:                this .mDescription = description;
158:            }
159:
160:            /**
161:             * Getter for property type.
162:             * @return Value of property type.
163:             */
164:            public String getType() {
165:                return this .mType;
166:            }
167:
168:            /**
169:             * Setter for property type.
170:             * @param type New value of property type.
171:             */
172:            public void setType(String type) {
173:                this .mType = type;
174:            }
175:
176:            /** string value
177:             * @return string value
178:             */
179:            public String toString() {
180:                return "\nType = " + this .getType() + "\nName = "
181:                        + this .getName() + "\nDescription = "
182:                        + this .getDescription() + "\nState = "
183:                        + this .getState();
184:            }
185:
186:            /** xml text
187:             * @return xml text
188:             */
189:            public String toXmlString() {
190:                return "<component-info \n" + "type=\"" + this .getType()
191:                        + "\" \n" + "name=\"" + this .getName() + "\" \n"
192:                        + "state=\"" + this .getState() + "\" >\n"
193:                        + "<description>" + this .getDescription()
194:                        + "</description> \n" + "</component-info> ";
195:            }
196:
197:            /** return component info object
198:             * @param compInfoElement xml element
199:             * @return object
200:             */
201:            public static JBIComponentInfo createJbiComponentInfo(
202:                    Element compInfoElement) {
203:
204:                JBIComponentInfo info = new JBIComponentInfo();
205:
206:                String type = compInfoElement.getAttribute("type");
207:                info.setType(type);
208:
209:                String name = compInfoElement.getAttribute("name");
210:                info.setName(name);
211:
212:                String state = compInfoElement.getAttribute("state");
213:                info.setState(state);
214:
215:                String desc = DOMUtil.UTIL.getTextData(DOMUtil.UTIL.getElement(
216:                        compInfoElement, "description"));
217:                info.setDescription(desc);
218:
219:                return info;
220:            }
221:
222:            /** creates list of objects
223:             * @param xmlReader Reader
224:             * @return list of objects
225:             */
226:            public static List readFromXmlText(Reader xmlReader) {
227:                ArrayList list = new ArrayList();
228:                Document xmlDoc = null;
229:
230:                try {
231:                    xmlDoc = DOMUtil.UTIL.buildDOMDocument(xmlReader);
232:
233:                } catch (Exception ex) {
234:                    Util.logDebug(ex);
235:                    return list;
236:                }
237:
238:                if (xmlDoc == null) {
239:                    return list; // return empty list
240:                }
241:
242:                // construct the compInfo list
243:                Element compInfoListElement = DOMUtil.UTIL.getElement(xmlDoc,
244:                        "component-info-list");
245:                if (compInfoListElement == null) {
246:                    // System.out.println("No Root Element <compInfoList>");
247:                    return list; // return empty list
248:                }
249:
250:                NodeList compInfoList = DOMUtil.UTIL.getChildElements(
251:                        compInfoListElement, "component-info");
252:                int size = compInfoList.getLength();
253:                // System.out.println("compInfo found in XML Document : " + size);
254:                for (int i = 0; i < size; ++i) {
255:                    Element compInfoElement = (Element) compInfoList.item(i);
256:                    if (compInfoElement != null) {
257:                        JBIComponentInfo compInfo = createJbiComponentInfo(compInfoElement);
258:                        list.add(compInfo);
259:                    }
260:                }
261:
262:                JBIComponentInfo.sort(list);
263:                return list;
264:            }
265:
266:            /** creates list of objects
267:             * @param xmlText xml text
268:             * @return list of objects
269:             */
270:            public static List readFromXmlText(String xmlText) {
271:                return readFromXmlText(new StringReader(xmlText));
272:            }
273:
274:            /** write to xml text
275:             * @param compInfoList list of objects
276:             * @return xml text
277:             */
278:            public static String writeAsXmlText(List compInfoList) {
279:                JBIComponentInfo.sort(compInfoList);
280:
281:                StringWriter stringWriter = new StringWriter();
282:                PrintWriter writer = new PrintWriter(stringWriter);
283:                // begine xml
284:                writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
285:                writer.println("<component-info-list " + " version=\"1.0\" "
286:                        + " xmlns=\"" + JBIComponentInfo.XMLNS + "\" " + " >");
287:                int size = compInfoList.size();
288:                for (int i = 0; i < size; ++i) {
289:                    JBIComponentInfo info = (JBIComponentInfo) compInfoList
290:                            .get(i);
291:                    writer.println(info.toXmlString());
292:                }
293:                writer.println("</component-info-list>");
294:                // end xml
295:                try {
296:                    writer.close();
297:                    stringWriter.close();
298:                } catch (Exception ex) {
299:                    // ignore as it will never happen for strings
300:                }
301:                return stringWriter.toString();
302:            }
303:
304:            /**
305:             * sort the list
306:             * @param compInfoList list
307:             */
308:            public static void sort(List compInfoList) {
309:                try {
310:                    Collections.sort(compInfoList, new Comparator() {
311:                        public int compare(Object o1, Object o2) {
312:                            return ((JBIComponentInfo) o1).getName().compareTo(
313:                                    ((JBIComponentInfo) o2).getName());
314:                        }
315:                    });
316:                } catch (ClassCastException ccEx) {
317:                    // log and
318:                    // do nothing.
319:                } catch (UnsupportedOperationException unsupEx) {
320:                    // log and 
321:                    // do nothing.
322:                }
323:            }
324:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.