Source Code Cross Referenced for WSP.java in  » Content-Management-System » webman » de » webman » template » jsp » 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 » Content Management System » webman » de.webman.template.jsp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package de.webman.template.jsp;
002:
003:        import org.w3c.dom.*;
004:        import org.w3c.dom.traversal.*;
005:
006:        /** 
007:         * Diese Klasse stellt Methoden zum Umgang mit Java Server Pages 
008:         * in Webman bereit.
009:         * Ein Objekt WSP representiert einen dom.w3c.node 
010:         * @author  $Author: alex $
011:         * @version $Revision: 1.3 $
012:         */
013:        public class WSP {
014:
015:            protected Node root;
016:
017:            /** Erstellt ein WSP-Objekt aus einem gegebenen NODE */
018:            public WSP(Node root) {
019:                this .root = root;
020:            }
021:
022:            /** Erstellt ein WSP-Objekt aus obj */
023:            public WSP(WSP obj) {
024:                this .root = obj.root;
025:            }
026:
027:            /** gibt den representierten Node zurück
028:             */
029:            public Node getNode() {
030:                return (root);
031:            }
032:
033:            /** erwartet Attributnamen und gibt dessen Value oder null zurück
034:            
035:             *  Attribute sind zum Bsp. NAME, REF (bei einer Webman-REF) oder
036:             *  die bekannten Content-Attribute
037:             @param Name des Attributes
038:             @return Wert des Attributes
039:             */
040:            public String getAttribute(String attrname) {
041:                try {
042:                    return (root.getAttributes().getNamedItem(attrname)
043:                            .getNodeValue());
044:                } catch (NullPointerException e) {
045:                    return (null);
046:                }
047:            }
048:
049:            /** erwartet Attributnamen und gibt dessen Value oder value zurück
050:            
051:             *  Attribute sind zum Bsp. NAME, REF (bei einer Webman-REF) oder
052:             *  die bekannten Content-Attribute
053:             @param Name des Attributes
054:             @param value was er zurueckgeben soll, wenn es das Attribut nicht gibt
055:             @return Wert des Attributes
056:             */
057:            public String getAttribute(String attrname, String value) {
058:                try {
059:                    String v = root.getAttributes().getNamedItem(attrname)
060:                            .getNodeValue();
061:                    if (v == null)
062:                        return value;
063:                    return v;
064:                } catch (NullPointerException e) {
065:                    return (value);
066:                }
067:            }
068:
069:            /** gibt den Pfad zum Upload aus 
070:            
071:             * (das aktuelle WSP-Objekt muss somit ein Webman-Upload sein)
072:             @return Pfad zum Upload
073:             */
074:            public String getUploadPath() {
075:                if (root.hasChildNodes())
076:                    return (root.getChildNodes().item(0).getNodeValue());
077:                return (null);
078:            }
079:
080:            /** gibt den Namen des Unterknotens Item oder null aus
081:            
082:            	sinnvoll für die meisten Formularelemente 	
083:            	der Wert eines Webman-textfeldes liegt z.b. im Unterknoten ITEM
084:            	
085:            	@return Wert von ITEM
086:             */
087:            public String getItem() {
088:                if (root.hasChildNodes()) {
089:                    if (root.getChildNodes().item(0).hasChildNodes())
090:                        return (root.getChildNodes().item(0).getChildNodes()
091:                                .item(0).getNodeValue());
092:                }
093:                return (null);
094:            }
095:
096:            /** gibt false def. den Wert des x-ten Unterknotens Item aus (x = number) sonst null
097:            
098:             * sinnvoll für einfache Listen z.b. Auswahlliste
099:              @param Position von ITEM
100:              @return Wert von ITEM
101:             */
102:            public String getItem(int number) {
103:                if (root.hasChildNodes()) {
104:                    if (root.getChildNodes().getLength() > number) {
105:                        if (root.getChildNodes().item(number).hasChildNodes())
106:                            return (root.getChildNodes().item(number)
107:                                    .getChildNodes().item(0).getNodeValue());
108:                    }
109:                }
110:                return (null);
111:            }
112:
113:            /** gibt den Kinderknoten number oder null zurück
114:              @param Position des Kindes
115:              @return das Kind
116:             */
117:            public WSP getChild(int number) {
118:                if (root.getChildNodes().getLength() > number) {
119:                    WSP help = new WSP(root.getChildNodes().item(number));
120:                    return (help);
121:                }
122:                return (null);
123:
124:            }
125:
126:            /** gibt den ersten Knoten des aktuellen Objektes zurück dessen
127:             * Attribut 'attrname' den Wert 'attrvalue' hat oder null zurück
128:              @param Attributname und Value
129:              @return der erste Knoten mit Attributname=Attributvalue
130:             */
131:            public WSP getNodeByAttr(String attrname, String attrvalue) {
132:
133:                // aktueller Knoten ,
134:                if (this  == null)
135:                    return (this );
136:
137:                if (this .getAttribute(attrname) != null) {
138:                    if (this .getAttribute(attrname).equals(attrvalue))
139:                        return (this );
140:                }
141:
142:                // oder seine Kinder ?
143:                for (int i = 0; this .getChild(i) != null; i++) {
144:                    WSP help = this .getChild(i).getNodeByAttr(attrname,
145:                            attrvalue);
146:                    if (help != null)
147:                        return (help);
148:                }
149:
150:                return (null);
151:            }
152:
153:            /** gibt den ersten Knoten mit dem Namen name oder null zurück
154:             @param Name des Knotens
155:             @return den ersten Knoten mit Name=name
156:             */
157:            public WSP getNodeByName(String name) {
158:                return (this .getNodeByAttr("NAME", name));
159:            }
160:
161:            // zum auslesen eines Pfades
162:            private static String getNextNode(String path) {
163:                if (path == null)
164:                    return (null);
165:
166:                int index = path.indexOf('.');
167:
168:                if (index == -1)
169:                    return (path);
170:                return (path.substring(0, index));
171:            }
172:
173:            // zur Bestimmung des verbleibenden Pfades
174:            private static String getNextPath(String path) {
175:                String Node = getNextNode(path);
176:
177:                if (Node == null)
178:                    return (null);
179:
180:                if (Node.length() + 1 <= path.length())
181:                    return (path.substring(Node.length() + 1, path.length()));
182:
183:                return (null);
184:            }
185:
186:            /** gibt den Knoten zurück der im Pfad path liegt
187:                der Pfad besteht aus den werten der Name-Attribute getrennt durch einen Punkt	
188:            	z.b. : NAME1.NAME2
189:            	@param genauer Pfad der Name-Attribute
190:            	@return den Knoten
191:             */
192:            public WSP getNodeByPath(String path) {
193:                String node = null;
194:                WSP back = new WSP(this );
195:                int i;
196:
197:                while ((back != null) && (path != null)) {
198:                    node = getNextNode(path);
199:                    path = getNextPath(path);
200:
201:                    if (node == null)
202:                        break;
203:
204:                    for (i = 0; (back.getChild(i) != null); i++) {
205:                        if (back.getChild(i).getAttribute("NAME") != null) {
206:                            if (back.getChild(i).getAttribute("NAME").equals(
207:                                    node))
208:                                break;
209:                        }
210:                    }
211:                    back = back.getChild(i);
212:                }
213:                return (back);
214:            }
215:
216:            /** wie getNodeByPath, nur das hier nach den Namen der representierten 
217:            	Nodes durchgegangen wird
218:            	
219:            	@param genauer Pfad der Nodenamen
220:            	@return erster Knoten mit diesem Pfad
221:             */
222:            public WSP getNodeByNodePath(String path) {
223:                return (getNodeByNodePath(path, 0));
224:            }
225:
226:            /** wie getNodeByNodePath,gibt allerdings x-ten Knoten mit diesem Pfad aus
227:            
228:              @param genauer Pfad des Nodenamen und die Position
229:              @return den x-ten Knoten des Pfades
230:             */
231:            public WSP getNodeByNodePath(String path, int index) {
232:                String node = null;
233:                WSP back = new WSP(this );
234:                int i, treffer;
235:                treffer = 0;
236:                while ((back != null) && (path != null)) {
237:                    node = getNextNode(path);
238:                    path = getNextPath(path);
239:
240:                    if (node == null)
241:                        break;
242:
243:                    for (i = 0; (back.getChild(i) != null); i++) {
244:
245:                        if (back.getChild(i).getNode().getNodeName() != null) {
246:                            if (back.getChild(i).getNode().getNodeName()
247:                                    .equals(node)) {
248:
249:                                if (path == null) {
250:                                    if (treffer == index)
251:                                        break;
252:                                    treffer++;
253:                                } else
254:                                    break;
255:                            }
256:                        }
257:                    }
258:                    back = back.getChild(i);
259:                }
260:                return (back);
261:            }
262:
263:            /** gibt das x-te Element einer FEW bel. Elemente in folge mit dem 
264:             * Namen name aus
265:              @param Name der FEW und die Stelle an der sie zu finden ist
266:              @return die x-te FEW mit Namen Name (x=Element) */
267:            public WSP getElement_FEW_BEL_EL_IN_F(String name, int Element) {
268:
269:                if (root != null) {
270:                    int z = 0;
271:
272:                    for (int i = 0; this .getNodeByNodePath("FEW-BEL_ELE_IN_F",
273:                            i) != null; i++) {
274:
275:                        WSP help = this 
276:                                .getNodeByNodePath("FEW-BEL_ELE_IN_F", i);
277:
278:                        if (help.getAttribute("NAME") != null) {
279:                            if (help.getAttribute("NAME").equals(name)) {
280:                                if (z == Element)
281:                                    return (help);
282:                                z++;
283:                            }
284:                        }
285:                    }
286:                }
287:
288:                return (null);
289:            }
290:
291:            /** gibt die Länge des FEW bel. Elemente in Folge mit dem namen name aus
292:               @param Name der FEW
293:               @return Länge der FEW
294:             */
295:            public String getLength_FEW_BEL_EL_IN_F(String name) {
296:
297:                WSP help = this .getElement_FEW_BEL_EL_IN_F(name, 0);
298:
299:                if (help != null)
300:                    return (help.getAttribute("LENGTH"));
301:
302:                return (null);
303:            }
304:
305:            /** gibt die Zelle (row,col) der Tabelle des pfades zurück
306:              @param Pfad der Tabelle; Zeile,Spalte der Zelle
307:              @return Zelle
308:             */
309:            public WSP getTableCell(String pfad, int row, int col) {
310:                WSP table = this .getNodeByPath(pfad);
311:                if (table == null)
312:                    return (null);
313:                WSP row1 = table.getChild(row);
314:                if (row1 == null)
315:                    return (null);
316:                return (row1.getChild(col));
317:            }
318:
319:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.