Source Code Cross Referenced for TagTextRule.java in  » Portal » Open-Portal » com » sun » portal » rewriter » rom » common » 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 » Portal » Open Portal » com.sun.portal.rewriter.rom.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:        package com.sun.portal.rewriter.rom.common;
006:
007:        import com.sun.portal.rewriter.rom.Data;
008:        import com.sun.portal.rewriter.rom.DataRule;
009:        import com.sun.portal.rewriter.util.Constants;
010:        import com.sun.portal.rewriter.util.Debug;
011:        import com.sun.portal.rewriter.util.collections.ListMap;
012:        import com.sun.portal.rewriter.util.re.Pattern;
013:        import com.sun.portal.rewriter.util.xml.Node;
014:
015:        import java.util.List;
016:
017:        /**
018:         * Represents TagText Rule of RuleSet, used to by XMLRewriter
019:         *
020:         * @version 1.0 12/15/2001
021:         * @author Raja Nagendra Kumar, Nagendra.Raja@sun.com
022:         */
023:        public final class TagTextRule extends DataRule {
024:            private final TagText tagText;
025:            private final Pattern[] tagSpec;
026:            private final Pattern[][] tagAttributeSpec;
027:            private final boolean isStarAttributeValue;
028:
029:            public TagTextRule(final TagText aTagText) {
030:                this (aTagText, true);
031:            }//constructor
032:
033:            public TagTextRule(final TagText aTagText, final boolean aIgnoreCase)
034:
035:            {
036:                super (aTagText);
037:                tagText = aTagText;
038:
039:                tagSpec = createAttributeSpec(tagText.getTag(), aIgnoreCase);
040:                tagAttributeSpec = new Pattern[aTagText.getAttributeMap()
041:                        .size()][2];
042:
043:                fillTagAttributeSpec(aIgnoreCase);
044:
045:                if (aTagText.getAttributePatterns().equals(
046:                        Constants.DEFAULT_REGULAR_EXPRESSION)) {
047:                    isStarAttributeValue = true;
048:                } else {
049:                    isStarAttributeValue = false;
050:                }
051:            }//constructor
052:
053:            public TagTextRule(final Node aNode, final boolean aIgnoreCase) {
054:                this (new TagText(aNode.getAttributeValue(TAG), aNode
055:                        .getAttributeValue(ATTRIBUTE_PATTERNS), aNode
056:                        .getAttributeValue(SOURCE)), aIgnoreCase);
057:            }//constructor
058:
059:            private void fillTagAttributeSpec(final boolean aIgnoreCase) {
060:                ListMap cAttMap = tagText.getAttributeMap();
061:                List cAttNames = cAttMap.keyList();
062:                for (int i = 0; i < cAttNames.size(); i++) {
063:                    String bAttName = (String) cAttNames.get(i);
064:                    tagAttributeSpec[i][0] = new Pattern(bAttName, aIgnoreCase);
065:                    tagAttributeSpec[i][1] = new Pattern((String) cAttMap
066:                            .get(bAttName), aIgnoreCase);
067:                }
068:            }//fillTagAttributeSpec()
069:
070:            public boolean plugableMatch(final Data aMache) {
071:                if (!(aMache instanceof  TagText)) {
072:                    return false;
073:                }
074:
075:                TagText valueObject = (TagText) aMache;
076:                if (match(tagSpec, valueObject.getTag())) {
077:                    //BugNo:4892729
078:                    if (isStarAttributeValue) {
079:                        return true;
080:                    }
081:
082:                    ListMap valueMap = valueObject.getAttributeMap();
083:                    List valueKeyList = valueMap.keyList();
084:                    for (int i = 0; i < valueKeyList.size(); i++) {
085:                        String valueKey = valueKeyList.get(i).toString();
086:                        Pattern valueRule2Match = findValueRule2Match(valueKey);
087:
088:                        if (valueRule2Match == null) {
089:                            return false;
090:                        } else if (!match(valueRule2Match, valueMap.get(
091:                                valueKey).toString())) {
092:                            return false;
093:                        }
094:                    }
095:
096:                    if (valueMap.size() >= tagAttributeSpec.length) {
097:                        return true;
098:                    }
099:
100:                    return false;
101:                }//if
102:
103:                return false;
104:            }//matchs()
105:
106:            public boolean isValid() {
107:                return doBasicValidation(new String[] { tagText.getTag() });
108:            }//isValid()
109:
110:            private Pattern findValueRule2Match(final String aKey) {
111:                for (int i = 0; i < tagAttributeSpec.length; i++) {
112:                    if (match(tagAttributeSpec[i][0], aKey)) {
113:                        return tagAttributeSpec[i][1];
114:                    }
115:                }//for loop
116:                return null;
117:            }//findValueRule2Match()
118:
119:            public static final TagTextRule[] createTagTextRules(
120:                    final Node[] aNodeList, final boolean aIgnoreCase) {
121:                TagTextRule[] lResult = new TagTextRule[aNodeList.length];
122:                for (int i = 0; i < aNodeList.length; i++) {
123:                    lResult[i] = new TagTextRule(aNodeList[i], aIgnoreCase);
124:                }
125:
126:                return lResult;
127:            }//createTagTextRules()
128:
129:            public static void main(String[] args) {
130:                TagTextRule[] textStrings = com.sun.portal.rewriter.test.util.SampleRuleObjects.defaultXMLTextStrings;
131:                for (int i = 0; i < textStrings.length; i++) {
132:                    Debug.println(textStrings[i].toXML());
133:                }//for loop
134:            }//main()
135:
136:        }//class TagText
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.