Source Code Cross Referenced for WebPageTagPreferences.java in  » Workflow-Engines » JFolder » org » jfolder » common » function » 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.common.function 
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.common.function;
009:
010:        //base classes
011:        import java.util.ArrayList;
012:        import java.util.HashMap;
013:        import java.util.StringTokenizer;
014:        import javax.servlet.jsp.PageContext;
015:        import javax.xml.parsers.ParserConfigurationException;
016:        import org.w3c.dom.Attr;
017:        import org.w3c.dom.CDATASection;
018:        import org.w3c.dom.CharacterData;
019:        import org.w3c.dom.Comment;
020:        import org.w3c.dom.Document;
021:        import org.w3c.dom.Element;
022:        import org.w3c.dom.Node;
023:        import org.w3c.dom.NodeList;
024:        import org.w3c.dom.Text;
025:
026:        //project specific classes
027:        import org.jfolder.common.UnexpectedSystemException;
028:        import org.jfolder.common.tagging.BaseConceptTagPreferences;
029:        import org.jfolder.common.tagging.ConceptTag;
030:        import org.jfolder.common.tagging.ConceptTagCallContext;
031:        import org.jfolder.common.tagging.ConceptTagMenuBranch;
032:        import org.jfolder.common.tagging.ConceptTagMenuContext;
033:        import org.jfolder.common.tagging.ConceptTagPreferences;
034:        import org.jfolder.common.tagging.ConceptTagPreferencesHelper;
035:        import org.jfolder.common.tagging.ConceptTagSetContext;
036:        import org.jfolder.common.tagging.ConceptTagSetHolder;
037:        import org.jfolder.common.tagging.DetermineClassConceptTagContext;
038:        import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
039:        import org.jfolder.common.tagging.InitializeConceptTagContext;
040:        import org.jfolder.common.tagging.RootConceptTagHolder;
041:        import org.jfolder.common.utils.xml.XMLHelper;
042:        import org.jfolder.config.instance.ConfigInstance;
043:        import org.jfolder.platforms.stores.base.SystemStore;
044:        import org.jfolder.services.config.ConfigService;
045:        import org.jfolder.services.config.ConfigServiceCaller;
046:        import org.jfolder.services.config.ConfigServiceCallerFactory;
047:
048:        //other classes
049:
050:        public class WebPageTagPreferences extends BaseConceptTagPreferences {
051:
052:            //private final static String WT_BASE_NAMESPACE =
053:            //    "http://www.jfolder.org/dtds/apps/web/";
054:            //
055:            //private final static String WT_NAMESPACE_V1 =
056:            //    WT_BASE_NAMESPACE + "v1/";
057:            //private final static String WT_NAMESPACE_V1_BASE =
058:            //    WT_NAMESPACE_V1 + "base.dtd";
059:            //private final static String WT_NAMESPACE_V1_CORE =
060:            //    WT_NAMESPACE_V1 + "core.dtd";
061:            //private final static String WT_NAMESPACE_V1_RETURNABLE =
062:            //    WT_NAMESPACE_V1 + "returnable.dtd";
063:            //
064:            //private final static String WT_NAME_V1_TEXT = "text";
065:            //private final static String WT_NAME_V1_COMPOUND = "compound";
066:            //
067:            //protected final static String WT_ATTR_V1_CONSTRAINT = "constraint";
068:            //
069:            //private final static String WT_HANDLE_CONJUCTION = "$";
070:            //
071:            //private final static String UNCONSTRAINED_SYMBOL = "@";
072:            //
073:            //private final static String ROOT_CONSTRAINT = UNCONSTRAINED_SYMBOL;
074:
075:            //private AttributeSet as = null;
076:            //private TriggerData td = null;
077:            //private String applicationName = null;
078:            public final static String DEFAULT_ROOT_CONCEPT_TAG_CLASS_NAME = "org.jfolder.web.page.v1.RootV1WebPageTag";
079:            //
080:            //
081:            //
082:            private static ConceptTagSetHolder cachedCtsh = null;
083:            //
084:            //
085:            //
086:            private String rootConceptTagClassName = null;
087:            //
088:            private ConceptTagSetHolder ctsh = null;
089:            private ConceptTagMenuBranch ctmb = null;
090:            private ConceptTagMenuContext ctmc = null;
091:            //
092:            private boolean validateOnlyMode = false;
093:            //
094:            //private PageContext pc = null;
095:
096:            //
097:            private RootConceptTagHolder rcth = null;
098:
099:            public WebPageTagPreferences() {
100:                init();
101:            }
102:
103:            private void init() {
104:                this .rootConceptTagClassName = DEFAULT_ROOT_CONCEPT_TAG_CLASS_NAME;
105:                //
106:                ConceptTagSetContext ctsc = ConceptTagSetContext.newInstance();
107:                this .ctmc = ConceptTagMenuContext.newInstance();
108:                //
109:                ConfigService cs = ConfigServiceCallerFactory
110:                        .getConfigService();
111:                //ConfigLifecycle cm = ConfigLifecycleFactory.getConfigLifecycle();
112:                this .ctsh = cs.accessConceptTagSet(
113:                        ConceptTagPreferencesHelper.CTP_PREF_HANDLE__WEB_PAGE,
114:                        ctsc);
115:                this .ctmb = this .ctsh.getMenuBranch();
116:                //this.ctmq = cm.getConceptTagMenuQualifier(
117:                //    ConfigInstance.WEB_PAGE, this.ctsh);
118:                //cm.close();
119:                //
120:                this .validateOnlyMode = false;
121:
122:            }
123:
124:            //WebPageTagPreferences(ConceptTagSetContext inCtsc) {
125:            //    this(DEFAULT_ROOT_CONCEPT_TAG_CLASS_NAME, inCtsc, null);
126:            //}
127:            ////
128:            //WebPageTagPreferences(String inRctcn, ConceptTagSetContext inCtsc,
129:            //    PageContext inPc) {
130:            //    
131:            //    //this.as = inAs;
132:            //    //this.td = inTd;
133:            //    //this.applicationName = inApplicationName;
134:            //    this.rootConceptTagClassName = inRctcn;
135:            //    //
136:            //    this.ctmc = ConceptTagMenuContext.newInstance();
137:            //    //
138:            //    ConfigLifecycle cm = ConfigLifecycleFactory.getConfigLifecycle();
139:            //    this.ctsh = cm.getConceptTagSet(ConfigInstance.WEB_PAGE, inCtsc);
140:            //    this.ctmb = this.ctsh.getMenuBranch();
141:            //    //this.ctmq = cm.getConceptTagMenuQualifier(
142:            //    //    ConfigInstance.WEB_PAGE, this.ctsh);
143:            //    this.ctmq = this.ctsh.getMenuQualifier();
144:            //    cm.close();
145:            //    //
146:            //    //MiscHelper.println("this.ctsh = " + this.ctsh);
147:            //    //MiscHelper.println("this.ctmb = " + this.ctmb);
148:            //    //MiscHelper.println("this.ctmq = " + this.ctmq);
149:            //    //
150:            //    this.validateOnlyMode = false;
151:            //    //
152:            //    this.pc = inPc;
153:            //}
154:            //
155:            public void initialize(ConceptTagCallContext inCtcc) {
156:                throw UnexpectedSystemException.notImplemented();
157:            }
158:
159:            //
160:            //
161:            public void bubba() {
162:                throw UnexpectedSystemException.unknownState();
163:            }
164:
165:            //
166:            public void setRootHolder(RootConceptTagHolder inRcth) {
167:                if (this .rcth != null) {
168:                    throw new UnexpectedSystemException("Already set");
169:                } else {
170:                    this .rcth = inRcth;
171:                }
172:            }
173:
174:            public RootConceptTagHolder getRootHolder() {
175:                return this .rcth;
176:            }
177:
178:            //protected AttributeSet getAttributeSet() {
179:            //    return this.as;
180:            //}
181:            //protected TriggerData getTriggerData() {
182:            //    return this.td;
183:            //}
184:            //protected String getApplicationName() {
185:            //    return this.applicationName;
186:            //}
187:            //
188:            public boolean isStaticUsed() {
189:                return true;
190:            }
191:
192:            public String getStaticNamespace() {
193:                return ConceptTagPreferencesHelper.CTP_PREF_NS__COMMON_COMPONENTS__V1;
194:            }
195:
196:            public String getStaticName() {
197:                return ConceptTagPreferencesHelper.CTP_PREF_STATIC_LOCAL_NAME__COMMON;
198:            }
199:
200:            //
201:            public boolean isCompoundUsed() {
202:                return true;
203:            }
204:
205:            public String getCompoundNamespace() {
206:                return ConceptTagPreferencesHelper.CTP_PREF_NS__COMMON_COMPONENTS__V1;
207:            }
208:
209:            public String getCompoundName() {
210:                return ConceptTagPreferencesHelper.CTP_PREF_COMPOUND_LOCAL_NAME__COMMON;
211:            }
212:
213:            //
214:            public boolean isNonTerminalCharacterDataStripped() {
215:                return false;
216:            }
217:
218:            //
219:            public boolean isConstraintUsed() {
220:                return true;
221:            }
222:
223:            public String getConstraintNamespace() {
224:                return null;
225:                //return ST_NAMESPACE_V1_BASE;
226:            }
227:
228:            public String getConstraintName() {
229:                return ConceptTagPreferencesHelper.CTP_PREF_CONSTRAINT_LOCAL_NAME__COMMON;
230:            }
231:
232:            //
233:            public boolean isStyleUsed() {
234:                return true;
235:            }
236:
237:            public String getStyleNamespace() {
238:                return null;
239:            }
240:
241:            public String getStyleName() {
242:                return ConceptTagPreferencesHelper.CTP_PREF_STYLE_LOCAL_NAME__COMMON;
243:            }
244:
245:            //
246:            public boolean isUnconstrainedAllowed() {
247:                return true;
248:            }
249:
250:            public String getUnconstrainedSymbol() {
251:                return ConceptTagPreferencesHelper.CTP_PREF_UNCONSTRAINED_SYMBOL_COMMON;
252:            }
253:
254:            //
255:            public String getRootConstraint() {
256:                return getUnconstrainedSymbol();
257:            }
258:
259:            public String getRootHandle() {
260:                return (getRootConstraint() + getHandleConjunction() + "0");
261:            }
262:
263:            //
264:            public String getHandleConjunction() {
265:                return ConceptTagPreferencesHelper.CTP_PREF_HANDLE_CONJUNCTION__COMMON;
266:            }
267:
268:            //
269:            public ConceptTagSetHolder getSetHolder() {
270:
271:                ConceptTagSetHolder outValue = null;
272:
273:                outValue = getCachedSetHol();
274:
275:                return outValue;
276:            }
277:
278:            protected synchronized final static ConceptTagSetHolder getCachedSetHol() {
279:                //
280:                ConceptTagSetHolder outValue = null;
281:
282:                if (SystemStore.isPrivaledgedAccess()) {
283:                    if (WebPageTagPreferences.cachedCtsh != null) {
284:                    } else {
285:                        ConfigService cs = ConfigServiceCallerFactory
286:                                .getConfigService();
287:                        WebPageTagPreferences.cachedCtsh = cs
288:                                .accessConceptTagSet(
289:                                        ConceptTagPreferencesHelper.CTP_PREF_HANDLE__WEB_PAGE,
290:                                        ConceptTagSetContext.newInstance());
291:
292:                    }
293:                    outValue = WebPageTagPreferences.cachedCtsh;
294:                } else {
295:                    throw UnexpectedSystemException.notImplemented();
296:                }
297:
298:                return outValue;
299:            }
300:
301:            public ConceptTagMenuBranch getMenuBase() {
302:
303:                ConceptTagMenuBranch outValue = null;
304:
305:                outValue = this .ctmb;
306:
307:                return outValue;
308:            }
309:
310:            //
311:            public String getRootClassName() {
312:                return (this .rootConceptTagClassName);
313:            }
314:
315:            //
316:            public InitializeConceptTagContext getInitializeContext() {
317:                return new InitializeWebPageTagContext(this );
318:            }
319:
320:            public DetermineClassConceptTagContext getReturnClassContext() {
321:                return new ReturnClassForWebPageTagContext();
322:            }
323:
324:            public DetermineValueAndClassConceptTagContext getDetermineValueAndClassContext() {
325:                return new ReturnValueAndClassForWebPageTagContext(this , null);
326:            }
327:
328:            //
329:            public ConceptTag createUnknownConceptTag(String inNs, String inName) {
330:
331:                ConceptTag outValue = null;
332:
333:                outValue = new UnknownWebPageTag(inNs, inName);
334:
335:                return outValue;
336:            }
337:
338:            public HashMap getDefaultNamespaceAssignments() {
339:
340:                HashMap outValue = new HashMap();
341:
342:                //outValue.put("http://java.sun.com/JSP/Page", "jsp");
343:
344:                return outValue;
345:            }
346:
347:            public String getAttributeConstraintName() {
348:                return ConceptTagPreferencesHelper.CTP_PREF_ATTRIBUTE_LOCAL_NAME__COMMON;
349:            }
350:
351:            public String getStyleConstraintName() {
352:                return ConceptTagPreferencesHelper.CTP_PREF_STYLE_LOCAL_NAME__COMMON;
353:            }
354:
355:            //
356:            public void setValidateOnlyMode(boolean inMode) {
357:                this .validateOnlyMode = inMode;
358:            }
359:
360:            public boolean isValidateOnlyMode() {
361:                return this .validateOnlyMode;
362:            }
363:
364:            //
365:            public boolean isAttributeAndStyleForbidden() {
366:                return false;
367:            }
368:
369:            //public boolean isGeneralContentForbidden() {
370:            //    return false;
371:            //}
372:            //
373:            public void correctForSpecialCharactersAndElements(Document inDoc) {
374:                //correctForSpecialCharactersAndElements(inDoc, inDoc);
375:            }
376:
377:            private final void correctForSpecialCharactersAndElements(
378:                    Document inDoc, Node inParent) {
379:
380:                ArrayList childNodes = new ArrayList();
381:
382:                NodeList nl = inParent.getChildNodes();
383:                for (int i = 0; i < nl.getLength(); i++) {
384:                    childNodes.add(nl.item(i));
385:                }
386:
387:                for (int i = 0; i < childNodes.size(); i++) {
388:                    Node nextNode = (Node) childNodes.get(i);
389:                    if (nextNode instanceof  CharacterData) {
390:                        CharacterData nextCd = (CharacterData) nextNode;
391:                        if (!(nextCd instanceof  Comment)) {
392:                            String nextData = nextCd.getData();
393:                            //make sure Windows newline doesn't show up twice
394:                            nextData = nextData.replaceAll("\\r\\n", "\n");
395:
396:                            ArrayList futureData = new ArrayList();
397:                            StringTokenizer st = new StringTokenizer(nextData,
398:                                    "\r\n ", true);
399:                            while (st.hasMoreTokens()) {
400:                                futureData.add(st.nextToken());
401:                            }
402:                            Node referenceNode = nextNode;
403:                            for (int j = futureData.size() - 1; j >= 0; j--) {
404:                                Node updateNode = null;
405:                                String updateData = (String) futureData.get(j);
406:                                if (updateData.equals("\n")
407:                                        || updateData.equals("\r")) {
408:                                    updateNode = inDoc.createElement("br");
409:                                } else if (updateData.equals(" ")) {
410:                                    updateNode = inDoc
411:                                            .createTextNode(XMLHelper.NBSP_XML);
412:                                } else {
413:                                    updateNode = inDoc
414:                                            .createTextNode(updateData);
415:                                }
416:
417:                                if (j == (futureData.size() - 1)) {
418:                                    inParent.replaceChild(updateNode,
419:                                            referenceNode);
420:                                } else {
421:                                    inParent.insertBefore(updateNode,
422:                                            referenceNode);
423:                                }
424:                                referenceNode = updateNode;
425:                            }
426:                        }
427:                    } else if (nextNode instanceof  Element) {
428:
429:                        Element nextEle = (Element) nextNode;
430:                        if (!WebPageTagHelper.isConstrained(this , nextEle)) {
431:                            correctForSpecialCharactersAndElements(inDoc,
432:                                    nextNode);
433:                        }
434:                    }
435:                }
436:            }
437:
438:            //
439:            public boolean isFileSystemPresent() {
440:                return false;
441:            }
442:
443:            public String getPreferencesHandle() {
444:                return ConceptTagPreferencesHelper.CTP_PREF_HANDLE__WEB_PAGE;
445:            }
446:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.