Source Code Cross Referenced for ConfigInstanceConfig.java in  » Workflow-Engines » JFolder » org » jfolder » config » instance » 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 » Workflow Engines » JFolder » org.jfolder.config.instance 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JFolder, Copyright 2001-2006 Gary Steinmetz
003:         *
004:         * Distributable under LGPL license.
005:         * See terms of license at gnu.org.
006:         */
007:
008:        package org.jfolder.config.instance;
009:
010:        //base classes
011:        import java.io.IOException;
012:        import java.util.HashMap;
013:        import javax.xml.parsers.ParserConfigurationException;
014:        import org.w3c.dom.Document;
015:        import org.w3c.dom.Element;
016:        import org.w3c.dom.Node;
017:        import org.w3c.dom.NodeList;
018:        import org.xml.sax.SAXException;
019:
020:        //project specific classes
021:        import org.jfolder.common.UnexpectedSystemException;
022:        import org.jfolder.common.utils.misc.MiscHelper;
023:        import org.jfolder.common.utils.xml.LinearXPath;
024:        import org.jfolder.common.utils.xml.LinearXPathHelper;
025:        import org.jfolder.common.utils.xml.XMLHelper;
026:
027:        //other classes
028:
029:        public class ConfigInstanceConfig {
030:
031:            //
032:            private String content = null;
033:            private String customContent = null;
034:
035:            //
036:            private transient Document contentDoc = null;
037:            private transient Document customContentDoc = null;
038:            //
039:            private transient HashMap cachedContentDoc = null;
040:            private transient HashMap cachedCustomContentDoc = null;
041:
042:            protected ConfigInstanceConfig(String inContent,
043:                    String inCustomContent) {
044:                this .content = inContent;
045:                this .customContent = inCustomContent;
046:            }
047:
048:            public final static ConfigInstanceConfig newInstance(
049:                    String inContent, String inCustomContent) {
050:
051:                ConfigInstanceConfig outValue = null;
052:
053:                outValue = new ConfigInstanceConfig(inContent, inCustomContent);
054:
055:                return outValue;
056:            }
057:
058:            private void init() {
059:                try {
060:                    MiscHelper.println("ConInstCon conD = " + this .content);
061:                    MiscHelper.println("ConInstCon cusConD = "
062:                            + this .customContent);
063:                    if (this .contentDoc == null) {
064:                        this .contentDoc = XMLHelper.loadDocument(this .content);
065:                    }
066:                    if (this .customContentDoc == null) {
067:                        this .customContentDoc = XMLHelper
068:                                .loadDocument(this .customContent);
069:                    }
070:                    if (this .cachedContentDoc == null) {
071:                        this .cachedContentDoc = new HashMap();
072:                    }
073:                    if (this .cachedCustomContentDoc == null) {
074:                        this .cachedCustomContentDoc = new HashMap();
075:                    }
076:                } catch (SAXException saxe) {
077:                    throw new UnexpectedSystemException(saxe);
078:                } catch (IOException ioe) {
079:                    throw new UnexpectedSystemException(ioe);
080:                } catch (ParserConfigurationException pce) {
081:                    throw new UnexpectedSystemException(pce);
082:                }
083:            }
084:
085:            //
086:            public String getMandatoryProperty(boolean inCustom,
087:                    LinearXPath inProp) {
088:
089:                String outValue = null;
090:                init();
091:                Element e = getCachedElement(inCustom, inProp);
092:
093:                if (e == null) {
094:                    throw new UnexpectedSystemException("Property '" + inProp
095:                            + "' is not present");
096:                }
097:
098:                outValue = XMLHelper.getText(e);
099:                return outValue;
100:            }
101:
102:            public String getMandatoryPropertyAttribute(boolean inCustom,
103:                    LinearXPath inProp, String inAttr) {
104:
105:                String outValue = null;
106:                init();
107:                Element e = getCachedElement(inCustom, inProp);
108:
109:                if (e == null) {
110:                    throw new UnexpectedSystemException("Property '" + inProp
111:                            + "' is not present");
112:                }
113:
114:                if (e.getAttributeNode(inAttr) == null) {
115:                    throw new UnexpectedSystemException("Attr '" + inAttr
116:                            + "' of prop '" + inAttr + "' is not present");
117:                }
118:
119:                outValue = e.getAttribute(inAttr);
120:                return outValue;
121:            }
122:
123:            public int getMandatoryPropertyCount(boolean inCustom,
124:                    LinearXPath inProp, String inName) {
125:
126:                int outValue = 0;
127:                init();
128:                Element e = getCachedElement(inCustom, inProp);
129:
130:                if (e == null) {
131:                    throw new UnexpectedSystemException("Property '" + inProp
132:                            + "' is not present");
133:                }
134:
135:                NodeList nl = e.getChildNodes();
136:
137:                for (int i = 0; i < nl.getLength(); i++) {
138:                    Node nextNode = nl.item(i);
139:                    if (nextNode instanceof  Element) {
140:                        Element nextElement = (Element) nextNode;
141:                        if (nextElement.getTagName().equals(inName)) {
142:                            outValue++;
143:                        }
144:                    }
145:                }
146:                return outValue;
147:            }
148:
149:            //
150:            public String getProperty(boolean inCustom, LinearXPath inProp,
151:                    String inDefault) {
152:
153:                String outValue = inDefault;
154:                init();
155:                Element e = getCachedElement(inCustom, inProp);
156:
157:                if (e == null) {
158:                } else {
159:                    outValue = XMLHelper.getText(e);
160:                }
161:                return outValue;
162:            }
163:
164:            public String getPropertyAttribute(boolean inCustom,
165:                    LinearXPath inProp, String inAttr, String inDefault) {
166:
167:                String outValue = inDefault;
168:                init();
169:                Element e = getCachedElement(inCustom, inProp);
170:
171:                if (e == null) {
172:                } else {
173:                    if (e.getAttributeNode(inAttr) == null) {
174:                    } else {
175:                        outValue = e.getAttribute(inAttr);
176:                    }
177:                }
178:                return outValue;
179:            }
180:
181:            public int getPropertyCount(boolean inCustom, LinearXPath inProp,
182:                    String inName, int inDefault) {
183:
184:                int outValue = inDefault;
185:                init();
186:                Element e = getCachedElement(inCustom, inProp);
187:
188:                if (e == null) {
189:                } else {
190:                    NodeList nl = e.getChildNodes();
191:                    outValue = 0;
192:                    for (int i = 0; i < nl.getLength(); i++) {
193:                        Node nextNode = nl.item(i);
194:                        if (nextNode instanceof  Element) {
195:                            Element nextElement = (Element) nextNode;
196:                            if (nextElement.getTagName().equals(inName)) {
197:                                outValue++;
198:                            }
199:                        }
200:                    }
201:                }
202:                return outValue;
203:            }
204:
205:            //
206:            public boolean isPropertyPresent(boolean inCustom,
207:                    LinearXPath inProp) {
208:
209:                boolean outValue = false;
210:                init();
211:                Element e = getCachedElement(inCustom, inProp);
212:                outValue = (e != null);
213:                return outValue;
214:            }
215:
216:            private Element getCachedElement(boolean inCustom,
217:                    LinearXPath inProp) {
218:
219:                Element outValue = null;
220:
221:                String propName = inProp.toString();
222:
223:                Document doc = null;
224:                HashMap props = null;
225:
226:                if (inCustom) {
227:                    doc = this .customContentDoc;
228:                    props = this .cachedCustomContentDoc;
229:                } else {
230:                    doc = this .contentDoc;
231:                    props = this .cachedContentDoc;
232:                }
233:
234:                if (props.containsKey(inProp)) {
235:                    outValue = (Element) props.get(propName);
236:                } else {
237:                    outValue = LinearXPathHelper.getXPathElement(doc, inProp);
238:                    props.put(propName, outValue);
239:                }
240:
241:                //MiscHelper.println("<!---------- ConfigInstanceConfig ---------->");
242:                //MiscHelper.println("outValue = " + outValue);
243:                //MiscHelper.println("doc = " + doc);
244:                //MiscHelper.println("inProp = " + inProp);
245:                //MiscHelper.println("inCustom = " + inCustom);
246:                //MiscHelper.println("content = " + this.content);
247:                //MiscHelper.println("customContent = " + this.customContent);
248:                //MiscHelper.println("<!------------------------------------------>");
249:
250:                return outValue;
251:            }
252:
253:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.