Source Code Cross Referenced for FieldNode.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » connection » 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 » iReport 2.0.5 » it.businesslogic.ireport.connection 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005 - 2008 JasperSoft Corporation.  All rights reserved. 
003:         * http://www.jaspersoft.com.
004:         *
005:         * Unless you have purchased a commercial license agreement from JasperSoft,
006:         * the following license terms apply:
007:         *
008:         * This program is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU General Public License version 2 as published by
010:         * the Free Software Foundation.
011:         *
012:         * This program is distributed WITHOUT ANY WARRANTY; and without the
013:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014:         * See the GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018:         * or write to:
019:         *
020:         * Free Software Foundation, Inc.,
021:         * 59 Temple Place - Suite 330,
022:         * Boston, MA  USA  02111-1307
023:         *
024:         *
025:         *
026:         *
027:         * FieldNode.java
028:         * 
029:         * Created on 22 giugno 2004, 15.09
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.connection;
034:
035:        /**
036:         *
037:         * @author  Administrator
038:         */
039:        public class FieldNode {
040:
041:            /** Attributi del nodo */
042:            private java.util.Properties attributes;
043:            /** Nodi figli di questo nodo */
044:            private java.util.Vector children;
045:
046:            /** Nome del nodo di configurazione */
047:            private String name = "";
048:
049:            /** Valore del nodo */
050:            private String value = null;
051:
052:            private int childIndex = 0;
053:
054:            private boolean consumed = false;
055:
056:            /**
057:             * Creates a new instance of FieldNode
058:             * @param name Nome del nodo
059:             */
060:            public FieldNode(String name) {
061:                attributes = new java.util.Properties();
062:                children = new java.util.Vector();
063:                this .name = name;
064:            }
065:
066:            /**
067:             * Attributi del nodo.
068:             * @return Value of property attributes.
069:             */
070:            public java.util.Properties getAttributes() {
071:                return attributes;
072:            }
073:
074:            /**
075:             * Setter for property attributes.
076:             * @param attributes New value of property attributes.
077:             */
078:            public void setAttributes(java.util.Properties attributes) {
079:                this .attributes = attributes;
080:            }
081:
082:            /**
083:             * Getter for property name.
084:             * @return Value of property name.
085:             */
086:            public java.lang.String getName() {
087:                return name;
088:            }
089:
090:            /**
091:             * Setter for property name.
092:             * @param name New value of property name.
093:             */
094:            public void setName(java.lang.String name) {
095:                this .name = name;
096:            }
097:
098:            /**
099:             * Restituisce il valore di questo nodo come stringa
100:             * @return Value of property value.
101:             */
102:            public java.lang.String getValue() {
103:                return value;
104:            }
105:
106:            /**
107:             * Restituisce il valore di questo nodo come stringa
108:             * @return Value of property value.
109:             */
110:            public java.lang.String getValue(String def) {
111:                if (value == null || value.length() == 0)
112:                    return def;
113:                return value;
114:            }
115:
116:            /**
117:             * Restituisce il valore di questo nodo come booleano
118:             * @return Value of property value.
119:             */
120:            public boolean getValueAsBoolean() {
121:                if (value != null && value.trim().equalsIgnoreCase("true"))
122:                    return true;
123:                return false;
124:            }
125:
126:            /**
127:             * Restituisce il valore di questo nodo come intero
128:             * @return Value of property value.
129:             */
130:            public int getValueAsInteger() {
131:                try {
132:                    return Integer.parseInt(value + "");
133:                } catch (Exception ex) {
134:                    return 0;
135:                }
136:            }
137:
138:            /**
139:             * Setter for property value.
140:             * @param value New value of property value.
141:             */
142:            public void setValue(java.lang.String value) {
143:                this .value = value;
144:            }
145:
146:            /**
147:             * Ritorna il child specificato.
148:             * @param childName Nome del nodo figlio
149:             * @param noNull Se true, verra' restituito un FieldNode invece di null. Il nuovo FieldNode verra' inserito nella lista dei childs.
150:             * @return Ritorna il nodo richiesto
151:             */
152:            public FieldNode getChild(java.lang.String childName, boolean noNull) {
153:
154:                java.util.Enumeration enum_children = children.elements();
155:                while (enum_children.hasMoreElements()) {
156:                    FieldNode cn = (FieldNode) enum_children.nextElement();
157:                    if (cn.getName().equals(childName))
158:                        return cn;
159:                }
160:
161:                if (noNull) {
162:                    FieldNode cn = new FieldNode(childName);
163:                    this .children.add(cn);
164:                    return cn;
165:                }
166:                return null;
167:            }
168:
169:            /**
170:             * Ritorna un vettore di children di nome childName
171:             * @param childName Nome del nodo figlio
172:             * @return Ritorna il nodo richiesto
173:             */
174:            public java.util.Vector getChilddren(java.lang.String childName) {
175:
176:                java.util.Vector result = new java.util.Vector();
177:                java.util.Enumeration enum_children = children.elements();
178:                while (enum_children.hasMoreElements()) {
179:                    FieldNode cn = (FieldNode) enum_children.nextElement();
180:                    if (cn.getName().equals(childName)) {
181:                        result.add(cn);
182:                    }
183:                }
184:                return result;
185:            }
186:
187:            /**
188:             * Ritorna il child specificato. Se il child non esiste, verra' restituito un FieldNode nuovo invece di null.
189:             * @param childName Nome del nodo figlio
190:             * @return Ritorna il nodo richiesto (non ritorna mai null)
191:             */
192:            public FieldNode getChild(java.lang.String childName) {
193:                return getChild(childName, true);
194:            }
195:
196:            /**
197:             * Ritorna il child specificato. Se il child non esiste, verra' restituito un FieldNode nuovo invece di null.
198:             * @param childName Nome del nodo figlio
199:             * @return Ritorna il nodo richiesto (non ritorna mai null)
200:             */
201:            public FieldNode getNextChild() {
202:
203:                if (this .getChildren().size() == 0) {
204:                    return new FieldNode("Unnamed");
205:                }
206:                if (childIndex < 0) {
207:                    childIndex = 0;
208:                }
209:                return (FieldNode) this .getChildren().elementAt(childIndex);
210:            }
211:
212:            /**
213:             * Restituisce il valore di questo attributo come stringa
214:             * @return Ritorna il valore come stringa. (Null se l'attributo richiesto non esiste)
215:             * @param attrName Nome dell'attributo da ritornare
216:             */
217:            public java.lang.String getAttribute(String attrName) {
218:                return attributes.getProperty(attrName);
219:            }
220:
221:            /**
222:             * Restituisce il valore di questo attributo come stringa
223:             * @return Ritorna il valore come stringa. (il valore di default specificato se l'attributo richiesto non esiste)
224:             * @param attrName Nome dell'attributo da ritornare
225:             * @param def Valore di default dell'attributo
226:             */
227:            public java.lang.String getAttribute(String attrName, String def) {
228:                return attributes.getProperty(attrName, def);
229:            }
230:
231:            /**
232:             * Restituisce il valore di questo attributo come booleano
233:             * @return Ritorna true se l'attributo e' uguale alla stringa "true" (case insensitive).
234:             * @param attrName Nome dell'attributo da ritornare
235:             */
236:            public boolean getAttributeAsBoolean(String attrName) {
237:                String val = attributes.getProperty(attrName);
238:                if (val != null && val.trim().equalsIgnoreCase("true"))
239:                    return true;
240:                return false;
241:            }
242:
243:            /**
244:             * Restituisce il valore di questo attributo come intero
245:             * @return 0 se l'attributo non e' parsabile come intero, altrimenti il valore intero.
246:             * @param attrName Nome dell'attributo da ritornare
247:             */
248:            public int getAttributeAsInteger(String attrName) {
249:                try {
250:                    String val = attributes.getProperty(attrName);
251:                    return Integer.parseInt(val + "");
252:                } catch (Exception ex) {
253:                    return 0;
254:                }
255:            }
256:
257:            /**
258:             * Getter for property children.
259:             * @return Value of property children.
260:             */
261:            public java.util.Vector getChildren() {
262:                return children;
263:            }
264:
265:            /**
266:             * Setter for property children.
267:             * @param children New value of property children.
268:             */
269:            public void setChildren(java.util.Vector children) {
270:                this .children = children;
271:            }
272:
273:            public boolean next(String xmlPath) {
274:                // Se sono una foglia ritorno false
275:
276:                //System.out.println(">>>" + xmlPath + " " + childIndex + "/" +);
277:                if (xmlPath.startsWith("/")) {
278:                    xmlPath = xmlPath.substring(1);
279:                }
280:
281:                if (xmlPath.indexOf("/") < 0) {
282:                    // I am a leaf!!!
283:                    if (!consumed) {
284:                        return consumed = true;
285:                    } else
286:                        return false;
287:                }
288:
289:                //xmlPath = xmlPath.substring(1);
290:                xmlPath = xmlPath.substring(xmlPath.indexOf("/"));
291:
292:                // The first time return ever true.
293:                if (childIndex == 0 && getChildren().size() == 0) {
294:                    if (!consumed) {
295:                        return consumed = true;
296:                    } else
297:                        return false;
298:                }
299:
300:                // See if our current child has other paths to explore...
301:                if (!getNextChild().next(xmlPath)) {
302:                    childIndex++;
303:                    // if they are other childs, return true
304:                    if (childIndex < getChildren().size())
305:                        return getNextChild().next(xmlPath);
306:                } else {
307:                    return true;
308:                }
309:                //for (; childIndex<getChildren().size(); ++childIndex)
310:
311:                return false;
312:            }
313:
314:            public String getChildsPath(String xmlPath) {
315:                if (xmlPath.indexOf("/") == xmlPath.lastIndexOf("/")) {
316:                    // I am a leaf!!!
317:                    return "";
318:                }
319:
320:                xmlPath = xmlPath.substring(xmlPath.indexOf("/") + 1);
321:                return this .getNextChild().getName() + "(" + childIndex + ")::"
322:                        + this.getNextChild().getChildsPath(xmlPath);
323:
324:            }
325:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.