Source Code Cross Referenced for ParameterReader.java in  » Report » datavision-1.1.0 » jimm » datavision » 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 » Report » datavision 1.1.0 » jimm.datavision 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jimm.datavision;
002:
003:        import jimm.util.I18N;
004:        import java.io.*;
005:        import javax.xml.parsers.SAXParser;
006:        import javax.xml.parsers.SAXParserFactory;
007:        import org.xml.sax.*;
008:        import org.xml.sax.helpers.DefaultHandler;
009:
010:        /**
011:         * A parameter reader reads an XML file and sets a {@link Report}'s parameter
012:         * values. This class is used when the report is being run from the
013:         * command line and the user has given us the name of an XML file containing
014:         * parameter elements.
015:         * <p>
016:         * Unlike a {@link ReportReader}, a parameter reader's constructor
017:         * takes not only the report but also the input method (file name, stream,
018:         * or reader). That way the report object doesn't have to know how to hold
019:         * on to those multipule input types.
020:         * 
021:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
022:         */
023:        public class ParameterReader extends DefaultHandler {
024:
025:            /**
026:             * If there is no report element dtd-version attribute, this is the
027:             * default value to use.
028:             */
029:            protected static final double DEFAULT_DTD_VERSION = 0.1;
030:
031:            protected Report report;
032:            protected Parameter parameter;
033:            protected String textData;
034:            protected File inFile;
035:            protected InputSource inInputSource;
036:
037:            /**
038:             * Constructor.
039:             *
040:             * @param report the report whose parameters we are setting
041:             * @param f the parameter XML file
042:             */
043:            public ParameterReader(Report report, File f) {
044:                this .report = report;
045:                inFile = f;
046:            }
047:
048:            /**
049:             * Constructor. To specify a URL, use <code>new
050:             * InputSource("http://...")</code>.
051:             *
052:             * @param report the report whose parameters we are setting
053:             * @param in the param XML input source
054:             */
055:            public ParameterReader(Report report, InputSource in) {
056:                this .report = report;
057:                inInputSource = in;
058:            }
059:
060:            /**
061:             * Returns the file name or, if that is <code>null</code>, the class name of
062:             * whatever input source was handed to a constructor.
063:             *
064:             * @return a file name or class name
065:             */
066:            public String getInputName() {
067:                if (inFile != null)
068:                    return inFile.getPath();
069:                if (inInputSource != null)
070:                    return "org.xml.sax.InputSource";
071:                return "?";
072:            }
073:
074:            /**
075:             * Reads parameter values from whichever input method was specified
076:             * in the constructor.
077:             */
078:            public void read() throws Exception {
079:                SAXParser parser = SAXParserFactory.newInstance()
080:                        .newSAXParser();
081:                if (inFile != null)
082:                    parser.parse(inFile, this );
083:                else if (inInputSource != null)
084:                    parser.parse(inInputSource, this );
085:            }
086:
087:            public void startElement(final String namespaceURI,
088:                    final String localName, final String qName,
089:                    final Attributes attributes) throws SAXException {
090:                String tagName = localName;
091:                if (tagName == null || tagName.length() == 0)
092:                    tagName = qName;
093:
094:                // Get ready to start collecting text
095:                if (textData == null || textData.length() > 0)
096:                    textData = new String();
097:
098:                if ("parameter".equals(tagName)) {
099:                    String id = attributes.getValue("id");
100:                    parameter = report.findParameter(id);
101:                    if (parameter == null)
102:                        ErrorHandler.error(I18N
103:                                .get("ParameterReader.unknown_id")
104:                                + ' '
105:                                + id
106:                                + ' '
107:                                + I18N.get("ParameterReader.in_xml"));
108:                }
109:            }
110:
111:            public void endElement(final String namespaceURI,
112:                    final String localName, final String qName)
113:                    throws SAXException {
114:                String tagName = localName;
115:                if (tagName == null || tagName.length() == 0)
116:                    tagName = qName;
117:
118:                if ("value".equals(tagName) && parameter != null)
119:                    parameter.addValue(textData);
120:                else if ("parameter".equals(tagName))
121:                    parameter = null;
122:            }
123:
124:            /**
125:             * Reads text data. Text data inside a single tag can be broken up into
126:             * multiple calls to this method.
127:             */
128:            public void characters(char ch[], int start, int length) {
129:                textData += new String(ch, start, length);
130:            }
131:
132:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.