Source Code Cross Referenced for Main.java in  » XML » X2JB » arrayssupport » 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 » XML » X2JB » arrayssupport 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * XML 2 Java Binding (X2JB) - the excellent Java tool.
003:         * Copyright 2007, by Richard Opalka.
004:         *
005:         * This is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU Lesser General Public License as
007:         * published by the Free Software Foundation; either version 2.1 of
008:         * the License, or (at your option) any later version.
009:         *
010:         * This software is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this software; if not see the FSF site:
017:         * http://www.fsf.org/ and search for the LGPL License document there.
018:         */
019:        package arrayssupport;
020:
021:        import arrayssupport.ifaces.Data;
022:        import org.x2jb.bind.XML2Java;
023:        import org.w3c.dom.Document;
024:        import javax.xml.parsers.DocumentBuilder;
025:        import javax.xml.parsers.DocumentBuilderFactory;
026:        import javax.xml.parsers.ParserConfigurationException;
027:
028:        /**
029:         * Arrays support sample
030:         * 
031:         * @author <a href="mailto:richard_opalka@yahoo.com">Richard Opalka</a>
032:         * @version 1.0
033:         */
034:        public final class Main {
035:
036:            /**
037:             * Lookups specified resource on the classpath and returns parsed document instance
038:             * @param classpath resource to return
039:             */
040:            private static Document getDocument(String resource)
041:                    throws Exception {
042:                Document retVal = null;
043:                try {
044:                    DocumentBuilderFactory builderFactory = DocumentBuilderFactory
045:                            .newInstance();
046:                    builderFactory.setNamespaceAware(true);
047:                    builderFactory.setIgnoringComments(true);
048:                    DocumentBuilder builder = builderFactory
049:                            .newDocumentBuilder();
050:                    retVal = builder.parse(Main.class
051:                            .getResourceAsStream(resource));
052:                } catch (ParserConfigurationException e) {
053:                    e.printStackTrace(System.err);
054:                    System.exit(1);
055:                }
056:                return retVal;
057:            }
058:
059:            public static void main(String[] args) throws Exception {
060:                Document parsedDocument = getDocument("/arrayssupport.xml");
061:                Data data = (Data) XML2Java.bind(parsedDocument, Data.class);
062:                Data.Arrays arrays = data.getArrays();
063:
064:                // display byte array values
065:                byte[] byteValues = arrays.byteValues();
066:                for (int i = 0; i < byteValues.length; i++) {
067:                    System.out.println("byte value on position " + i + " is "
068:                            + byteValues[i]);
069:                }
070:                System.out.println();
071:
072:                // display char array values
073:                char[] charValues = arrays.charValues();
074:                for (int i = 0; i < charValues.length; i++) {
075:                    System.out.println("char value on position " + i + " is "
076:                            + charValues[i]);
077:                }
078:                System.out.println();
079:
080:                // display short array values
081:                short[] shortValues = arrays.shortValues();
082:                for (int i = 0; i < shortValues.length; i++) {
083:                    System.out.println("short value on position " + i + " is "
084:                            + shortValues[i]);
085:                }
086:                System.out.println();
087:
088:                // display int array values
089:                int[] intValues = arrays.intValues();
090:                for (int i = 0; i < intValues.length; i++) {
091:                    System.out.println("int value on position " + i + " is "
092:                            + intValues[i]);
093:                }
094:                System.out.println();
095:
096:                // display long array values
097:                long[] longValues = arrays.longValues();
098:                for (int i = 0; i < longValues.length; i++) {
099:                    System.out.println("long value on position " + i + " is "
100:                            + longValues[i]);
101:                }
102:                System.out.println();
103:
104:                // display float array values
105:                float[] floatValues = arrays.floatValues();
106:                for (int i = 0; i < floatValues.length; i++) {
107:                    System.out.println("float value on position " + i + " is "
108:                            + floatValues[i]);
109:                }
110:                System.out.println();
111:
112:                // display double array values
113:                double[] doubleValues = arrays.doubleValues();
114:                for (int i = 0; i < doubleValues.length; i++) {
115:                    System.out.println("double value on position " + i + " is "
116:                            + doubleValues[i]);
117:                }
118:                System.out.println();
119:
120:                // display BigInteger array values
121:                java.math.BigInteger[] bigIntegerValues = arrays
122:                        .bigIntegerValues();
123:                for (int i = 0; i < bigIntegerValues.length; i++) {
124:                    System.out.println("BigInteger value on position " + i
125:                            + " is " + bigIntegerValues[i]);
126:                }
127:                System.out.println();
128:
129:                // display BigDecimal array values
130:                java.math.BigDecimal[] bigDecimalValues = arrays
131:                        .bigDecimalValues();
132:                for (int i = 0; i < bigDecimalValues.length; i++) {
133:                    System.out.println("BigDecimal value on position " + i
134:                            + " is " + bigDecimalValues[i]);
135:                }
136:                System.out.println();
137:
138:                // display String array values
139:                String[] stringValues = arrays.stringValues();
140:                for (int i = 0; i < stringValues.length; i++) {
141:                    System.out.println("String value on position " + i + " is "
142:                            + stringValues[i]);
143:                }
144:                System.out.println();
145:
146:            }
147:
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.