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


001:        package jimm.datavision.source.charsep;
002:
003:        import jimm.datavision.*;
004:        import jimm.datavision.source.*;
005:        import jimm.util.XMLWriter;
006:        import java.io.*;
007:        import java.util.*;
008:
009:        /**
010:         * A data source for files whose lines are rows and columns are separated
011:         * by a character.
012:         *
013:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
014:         */
015:        public class CharSepSource extends DataSource {
016:
017:            protected static final char DEFAULT_SEP_CHAR = ',';
018:
019:            protected ArrayList columns;
020:            protected char sepChar;
021:            protected BufferedReader reader;
022:            protected String sourceFilePath;
023:
024:            public CharSepSource(Report report) {
025:                super (report, new CharSepQuery(report));
026:                columns = new ArrayList();
027:                sepChar = DEFAULT_SEP_CHAR;
028:            }
029:
030:            public boolean canJoinTables() {
031:                return true;
032:            }
033:
034:            public boolean isSQLGenerated() {
035:                return false;
036:            }
037:
038:            public boolean isConnectionEditable() {
039:                return false;
040:            }
041:
042:            public boolean areRecordsSelectable() {
043:                return true;
044:            }
045:
046:            public boolean areRecordsSortable() {
047:                return false;
048:            }
049:
050:            public boolean canGroupRecords() {
051:                return false;
052:            }
053:
054:            public boolean usesSourceFile() {
055:                return true;
056:            }
057:
058:            public boolean needsSourceFile() {
059:                return reader == null;
060:            }
061:
062:            public boolean alreadyUsedSourceFile() {
063:                return sourceFilePath != null && reader == null;
064:            }
065:
066:            public void setSourceFile(String filePath)
067:                    throws FileNotFoundException {
068:                sourceFilePath = filePath;
069:                reuseSourceFile();
070:            }
071:
072:            public void reuseSourceFile() throws FileNotFoundException {
073:                setInput(new FileReader(sourceFilePath));
074:            }
075:
076:            public void setInput(Reader reader) {
077:                if (reader instanceof  BufferedReader)
078:                    this .reader = (BufferedReader) reader;
079:                else
080:                    this .reader = new BufferedReader(reader);
081:            }
082:
083:            public void setInput(InputStreamReader inputStreamReader) {
084:                reader = new BufferedReader(inputStreamReader);
085:            }
086:
087:            public void setInput(String fileName) throws FileNotFoundException {
088:                setSourceFile(fileName);
089:            }
090:
091:            public char getSepChar() {
092:                return sepChar;
093:            }
094:
095:            public void setSepChar(char c) {
096:                sepChar = c;
097:            }
098:
099:            /**
100:             * This override not only remembers the column but also hands it to the
101:             * query for cacheing.
102:             *
103:             * @param col a column
104:             */
105:            public void addColumn(Column col) {
106:                columns.add(col);
107:                ((CharSepQuery) query).addColumn(col);
108:            }
109:
110:            /**
111:             * Given an id (a column name), returns the column that has that id. If no
112:             * column with the specified id exists, returns <code>null</code>. Uses
113:             * <code>Table.findColumn</code>.
114:             *
115:             * @param id a column id
116:             * @return a column, or <code>null</code> if no column with the specified
117:             * id exists
118:             * @see Table#findColumn
119:             */
120:            public Column findColumn(Object id) {
121:                for (Iterator iter = columns.iterator(); iter.hasNext();) {
122:                    Column col = (Column) iter.next();
123:                    if (col.getId().equals(id))
124:                        return col;
125:                }
126:                return null;
127:            }
128:
129:            public int indexOfSelectable(Selectable sel) {
130:                return columns.indexOf(sel);
131:            }
132:
133:            public Iterator tables() {
134:                return null;
135:            }
136:
137:            public Iterator tablesUsedInReport() {
138:                return null;
139:            }
140:
141:            public Iterator columns() {
142:                return columns.iterator();
143:            }
144:
145:            public DataCursor execute() {
146:                return new CharSepRow(this , query);
147:            }
148:
149:            BufferedReader getReader() {
150:                return reader;
151:            }
152:
153:            void closeReader() {
154:                try {
155:                    if (reader != null)
156:                        reader.close();
157:                } catch (IOException ioe) {
158:                    ErrorHandler.error(ioe);
159:                } finally {
160:                    reader = null;
161:                }
162:            }
163:
164:            /**
165:             * Writes this database and all its tables as an XML tag.
166:             *
167:             * @param out a writer that knows how to write XML
168:             */
169:            protected void doWriteXML(XMLWriter out) {
170:                out.startElement("charsep");
171:                out.attr("sepchar", sepChar);
172:                if (metadataURL != null)
173:                    out.textElement("metadata-url", metadataURL);
174:                else
175:                    for (Iterator iter = columns.iterator(); iter.hasNext();)
176:                        ((Column) iter.next()).writeXML(out);
177:                out.endElement();
178:            }
179:
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.