Source Code Cross Referenced for Xml2Config.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » config » 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 » Web Framework » rife 1.6.1 » com.uwyn.rife.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003:         * Distributed under the terms of either:
004:         * - the common development and distribution license (CDDL), v1.0; or
005:         * - the GNU Lesser General Public License, v2.1 or later
006:         * $Id: Xml2Config.java 3634 2007-01-08 21:42:24Z gbevin $
007:         */
008:        package com.uwyn.rife.config;
009:
010:        import com.uwyn.rife.config.exceptions.ConfigErrorException;
011:        import com.uwyn.rife.ioc.HierarchicalProperties;
012:        import com.uwyn.rife.ioc.exceptions.PropertyValueException;
013:        import com.uwyn.rife.rep.Rep;
014:        import com.uwyn.rife.xml.Xml2Data;
015:        import com.uwyn.rife.xml.exceptions.XmlErrorException;
016:        import java.util.ArrayList;
017:        import java.util.HashMap;
018:        import org.xml.sax.Attributes;
019:
020:        public class Xml2Config extends Xml2Data {
021:            private StringBuilder mCharacterDataStack = null;
022:
023:            private String mCurrentListName = null;
024:            private String mCurrentParameterName = null;
025:
026:            private HashMap<String, String> mParameters = null;
027:            private ArrayList<String> mFinalParameters = null;
028:            private HashMap<String, ArrayList<String>> mLists = null;
029:            private ArrayList<String> mFinalLists = null;
030:
031:            public Xml2Config() {
032:                this (null, null, null, null);
033:            }
034:
035:            public Xml2Config(HashMap<String, String> parameters,
036:                    ArrayList<String> finalParameters,
037:                    HashMap<String, ArrayList<String>> lists,
038:                    ArrayList<String> finalLists) {
039:                mParameters = parameters;
040:                mFinalParameters = finalParameters;
041:                mLists = lists;
042:                mFinalLists = finalLists;
043:
044:                if (null == mParameters) {
045:                    mParameters = new HashMap<String, String>();
046:                }
047:                if (null == mFinalParameters) {
048:                    mFinalParameters = new ArrayList<String>();
049:                }
050:                if (null == mLists) {
051:                    mLists = new HashMap<String, ArrayList<String>>();
052:                }
053:                if (null == mFinalLists) {
054:                    mFinalLists = new ArrayList<String>();
055:                }
056:            }
057:
058:            public HashMap<String, String> getParameters() {
059:                return mParameters;
060:            }
061:
062:            public ArrayList<String> getFinalParameters() {
063:                return mFinalParameters;
064:            }
065:
066:            public HashMap<String, ArrayList<String>> getLists() {
067:                return mLists;
068:            }
069:
070:            public ArrayList<String> getFinalLists() {
071:                return mFinalLists;
072:            }
073:
074:            public void startDocument() {
075:                mCharacterDataStack = null;
076:                mCurrentListName = null;
077:                mCurrentParameterName = null;
078:            }
079:
080:            public void endDocument() {
081:                mCharacterDataStack = null;
082:                mCurrentListName = null;
083:                mCurrentParameterName = null;
084:            }
085:
086:            public void startElement(String namespaceURI, String localName,
087:                    String qName, Attributes atts) {
088:                if (qName.equals("param") || qName.equals("item")) {
089:                    mCharacterDataStack = new StringBuilder();
090:                }
091:
092:                if (qName.equals("config")) {
093:                    // do nothing
094:                } else if (qName.equals("list")) {
095:                    String name = atts.getValue("name");
096:
097:                    if (!mFinalLists.contains(name)) {
098:                        mCurrentListName = name;
099:                        mLists.put(name, new ArrayList<String>());
100:
101:                        String final_attribute = atts.getValue("final");
102:                        if (final_attribute != null
103:                                && (final_attribute.equals("1")
104:                                        || final_attribute.equals("t") || final_attribute
105:                                        .equals("true"))) {
106:                            mFinalLists.add(name);
107:                        }
108:                    }
109:                } else if (qName.equals("param")) {
110:                    String name = atts.getValue("name");
111:
112:                    if (!mFinalParameters.contains(name)) {
113:                        mCurrentParameterName = name;
114:
115:                        String final_attribute = atts.getValue("final");
116:                        if (final_attribute != null
117:                                && (final_attribute.equals("1")
118:                                        || final_attribute.equals("t") || final_attribute
119:                                        .equals("true"))) {
120:                            mFinalParameters.add(name);
121:                        }
122:                    }
123:                } else if (qName.equals("item")) {
124:                } else if (qName.equals("value")) {
125:                    String parameter_name = atts.getValue("name");
126:
127:                    if (mParameters.containsKey(parameter_name)) {
128:                        mCharacterDataStack.append(mParameters
129:                                .get(parameter_name));
130:                    }
131:                } else if (qName.equals("property")) {
132:                    String property_name = atts.getValue("name");
133:
134:                    HierarchicalProperties properties = Rep.getProperties();
135:                    properties.contains(property_name);
136:
137:                    if (properties.contains(property_name)) {
138:                        try {
139:                            mCharacterDataStack.append(properties.get(
140:                                    property_name).getValueString());
141:                        } catch (PropertyValueException e) {
142:                            throw new XmlErrorException(
143:                                    "Error while obtain the String value of property '"
144:                                            + property_name + "'.", e);
145:                        }
146:                    }
147:                } else if (qName.equals("include")) {
148:                    String included_file = atts.getValue("file");
149:
150:                    try {
151:                        new Config(included_file, getResourceFinder(),
152:                                mParameters, mFinalParameters, mLists,
153:                                mFinalLists);
154:                    } catch (ConfigErrorException e) {
155:                        throw new XmlErrorException(
156:                                "Error while processing the included config file '"
157:                                        + included_file + "'.", e);
158:                    }
159:                } else {
160:                    throw new XmlErrorException("Unsupport element name '"
161:                            + qName + "'.");
162:                }
163:            }
164:
165:            public void endElement(String namespaceURI, String localName,
166:                    String qName) {
167:                if (qName.equals("config")) {
168:                } else if (qName.equals("param")) {
169:                    if (mCurrentParameterName != null) {
170:                        String parameter_name = mCurrentParameterName;
171:
172:                        mParameters.put(parameter_name, mCharacterDataStack
173:                                .toString());
174:
175:                        mCurrentParameterName = null;
176:                    }
177:
178:                    mCharacterDataStack = null;
179:                } else if (qName.equals("list")) {
180:                    mCurrentListName = null;
181:                } else if (qName.equals("item")) {
182:                    if (mCurrentListName != null) {
183:                        mLists.get(mCurrentListName).add(
184:                                mCharacterDataStack.toString());
185:                        mCharacterDataStack = null;
186:                    }
187:                } else if (qName.equals("value")) {
188:                }
189:            }
190:
191:            public void characters(char[] ch, int start, int length) {
192:                if (mCharacterDataStack != null && length > 0) {
193:                    mCharacterDataStack.append(String.copyValueOf(ch, start,
194:                            length));
195:                }
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.