Source Code Cross Referenced for DataRuleCollection.java in  » Portal » Open-Portal » com » sun » portal » rewriter » rom » 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 
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;
006:
007:        import com.sun.portal.rewriter.rom.common.AttributeRule;
008:        import com.sun.portal.rewriter.util.Debug;
009:        import com.sun.portal.rewriter.util.collections.ListSet;
010:        import com.sun.portal.rewriter.util.xml.Node;
011:
012:        import java.lang.reflect.Constructor;
013:        import java.util.Collections;
014:        import java.util.List;
015:
016:        /**
017:         * This is Type collection which can contain any single kind of DataRule
018:         * Objects
019:         *
020:         * @version 1.0 12/15/2001
021:         * @author Raja Nagendra Kumar, Nagendra.Raja@sun.com
022:         */
023:        public final class DataRuleCollection extends RuleCollection {
024:            private List collection = new ListSet();
025:
026:            private DataRuleCollection(final String aCollectionID) {
027:                super (aCollectionID);
028:            }//constructor
029:
030:            public DataRuleCollection(final String aCollectionID,
031:                    final DataRule[] aDataRuleArray) {
032:                this (aCollectionID);
033:                add(aDataRuleArray);
034:                collection = Collections.unmodifiableList(collection);
035:            }//constructor
036:
037:            private boolean add(final DataRule aDataRule)
038:                    throws InvalidCollectionIDException {
039:                if (aDataRule == null) {
040:                    return false;
041:                }
042:
043:                if (getCollectionID().equals(aDataRule.getCollectionID())) {
044:                    if (aDataRule.isValid()) {
045:                        return collection.add(aDataRule);
046:                    }
047:
048:                    if (Debug.isWarningEnabled()) {
049:                        //Debug.recordRuleSetWarning( "Ignoring the Invalid Rule: " + aDataRule.toXML() );
050:                        Object[] param = { aDataRule.toXML() };
051:                        Debug.recordRuleSetWarning("PSRW_CSPR_0023", param);
052:                    }
053:                    return false;
054:                } else {
055:                    throw new InvalidCollectionIDException(
056:                            "Error: Collection ID Expected '"
057:                                    + getCollectionID() + "' and not of type '"
058:                                    + aDataRule.getCollectionID() + "'");
059:                }
060:            }//add()
061:
062:            public List getCollection() {
063:                return collection;
064:            }//getCollection()
065:
066:            /**
067:             *Once this object is exposed, outside then this become mutable object
068:             */
069:            private boolean add(final DataRule[] aDataRuleArray)
070:                    throws InvalidCollectionIDException {
071:                boolean lBool = true;
072:                if (aDataRuleArray == null) {
073:                    return false;
074:                }
075:
076:                for (int i = 0; i < aDataRuleArray.length; i++) {
077:                    try {
078:                        add(aDataRuleArray[i]);
079:                    } catch (InvalidCollectionIDException e) {
080:                        lBool = false;
081:                        //Debug.warning( "Invalid Collection ID", e );
082:                        Debug.warning("PSRW_CSPR_0024", e);
083:                        continue;
084:                    }
085:                }
086:
087:                return lBool;
088:            }//add()
089:
090:            public DataRule findMatch(final Data aObject) {
091:                if ((null == aObject) || (collection.size() <= 0)) {
092:                    return null;
093:                }
094:
095:                int collectionLength = collection.size();
096:                for (int i = 0; i < collectionLength; i++) {
097:                    DataRule lRule = (DataRule) collection.get(i);
098:                    if (lRule.matches(aObject)) {
099:                        if (Debug.isMessageEnabled()) {
100:                            //BugNo:4899057
101:                            Object[] param0 = { lRule.toXML() };
102:                            Object[] param1 = { aObject.toXML() };
103:                            /*Debug.message( "\nMatch Happend : " +
104:                            	   "\nRule Object:" + lRule.toXML() +
105:                            	   "\nContent Object: " + aObject.toXML() );*/
106:                            Debug.message("PSRW_CSPR_0025");
107:                            Debug.message("PSRW_CSPR_0026", param0);
108:                            Debug.message("PSRW_CSPR_0027", param1);
109:                        }
110:
111:                        return lRule;
112:                    }
113:                }
114:
115:                return null;
116:            }//findMatch()
117:
118:            public final int size() {
119:                return collection.size();
120:            }//size()
121:
122:            public boolean contains(final Data aObject) {
123:                if (findMatch(aObject) == null) {
124:                    return false;
125:                } else {
126:                    return true;
127:                }
128:            }//contains()
129:
130:            public String toXML() {
131:                final StringBuffer sb = new StringBuffer();
132:                for (int i = 0; i < collection.size(); i++) {
133:                    Rule lValue = (Rule) collection.get(i);
134:                    sb.append(lValue.toXML());
135:                }
136:
137:                return sb.toString();
138:            }//toXML()
139:
140:            public static DataRuleCollection create(final Class aClassRef,
141:                    final Node[] lArray) {
142:                DataRuleCollection lCollection = null;
143:                DataRule lDataRule;
144:                try {
145:                    Constructor constructor = aClassRef
146:                            .getConstructor(new Class[] { Node.class });
147:
148:                    /*
149:                    Get the collection ID by creating a dummy object
150:                     */
151:                    lDataRule = (DataRule) constructor
152:                            .newInstance(new Object[] { new Node(null) });
153:                    lCollection = new DataRuleCollection(lDataRule
154:                            .getCollectionID());
155:                    for (int i = 0; i < lArray.length; i++) {
156:                        try {
157:                            lDataRule = (DataRule) constructor
158:                                    .newInstance(new Object[] { lArray[i] });
159:                            lCollection.add(lDataRule);
160:                        } catch (Exception e) {
161:                            //Debug.error( "Exception in create of DataRuleCollection:", e );
162:                            Debug.error("PSRW_CSPR_0028", e);
163:                            continue;
164:                        }//try/catch
165:                    }//for loop
166:                } catch (Exception me) {
167:                    me.printStackTrace();
168:                }//try/catch
169:                return lCollection;
170:            }//create()
171:
172:            public static void main(String[] args) {
173:                AttributeRule[] attributes = com.sun.portal.rewriter.test.util.SampleRuleObjects.defaultHTMLAttributes;
174:                DataRuleCollection lCollection = new DataRuleCollection(
175:                        ATTRIBUTE, attributes);
176:                Debug.println("DataRuleCollection : "
177:                        + lCollection.contains(attributes[0].getData()));
178:                Debug.println("DataRuleCollection : "
179:                        + lCollection.contains(null));
180:            }//main()
181:        }//class DataRuleCollection
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.