Source Code Cross Referenced for PersonEvaluatorFactory.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » layout » dlm » providers » 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 » uPortal_rel 2 6 1 GA » org.jasig.portal.layout.dlm.providers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2005 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.layout.dlm.providers;
007:
008:        import org.jasig.portal.layout.dlm.Evaluator;
009:        import org.jasig.portal.layout.dlm.EvaluatorFactory;
010:        import org.jasig.portal.utils.XML;
011:        import org.w3c.dom.NamedNodeMap;
012:        import org.w3c.dom.Node;
013:        import org.w3c.dom.NodeList;
014:
015:        /**
016:         * Implementation of the Evaluator Factory interface that creates evaluators
017:         * of string attributes in implementations of IPerson to determine if a user
018:         * gets a layout fragment.
019:         *   
020:         * @author mboyd@sungardsct.com
021:         * @version $Revision: 35711 $ $Date: 2005-05-02 22:55:35 -0700 (Mon, 02 May 2005) $
022:         * @since uPortal 2.5
023:         */
024:        public class PersonEvaluatorFactory implements  EvaluatorFactory {
025:            public static final String RCS_ID = "@(#) $Header$";
026:
027:            private static final int OR = 0;
028:            private static final int AND = 1;
029:            private static final int NOT = 2;
030:
031:            public Evaluator getEvaluator(Node audience) {
032:                return getGroupEvaluator(OR, audience);
033:            }
034:
035:            private Evaluator getGroupEvaluator(int type, Node node) {
036:                NodeList nodes = node.getChildNodes();
037:                Evaluator container = null;
038:
039:                if (nodes == null
040:                        || nodes.getLength() == 0
041:                        || (container = createGroupEvaluator(type, nodes)) == null) {
042:                    throw new RuntimeException(
043:                            "Invalid content. Expected one to many "
044:                                    + "<paren>, <NOT>, or <attribute> in '"
045:                                    + XML.serializeNode(node) + "'");
046:                }
047:                return container;
048:            }
049:
050:            private Evaluator createGroupEvaluator(int type, NodeList nodes) {
051:                // if only one child skip wrapping in container for AND and OR
052:                if (nodes.getLength() == 1 && (type == OR || type == AND))
053:                    return createEvaluator(nodes.item(0));
054:
055:                Paren container = null;
056:
057:                if (type == NOT)
058:                    container = new Paren(Paren.NOT);
059:                else if (type == OR)
060:                    container = new Paren(Paren.OR);
061:                else if (type == AND)
062:                    container = new Paren(Paren.AND);
063:
064:                boolean validContentAdded = false;
065:
066:                for (int i = 0; i < nodes.getLength(); i++) {
067:                    if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
068:                        Evaluator e = createEvaluator(nodes.item(i));
069:
070:                        if (e != null) {
071:                            validContentAdded = true;
072:                            container.addEvaluator(e);
073:                        }
074:                    }
075:                }
076:                if (validContentAdded)
077:                    return container;
078:                return null;
079:            }
080:
081:            private Evaluator createEvaluator(Node node) {
082:                String nodeName = node.getNodeName();
083:
084:                if (nodeName.equals("paren"))
085:                    return createParen(node);
086:                else if (nodeName.equals("attribute"))
087:                    return createAttributeEvaluator(node);
088:                throw new RuntimeException("Unrecognized element '" + nodeName
089:                        + "' in '" + XML.serializeNode(node) + "'");
090:            }
091:
092:            private Evaluator createParen(Node n) {
093:                NamedNodeMap attribs = n.getAttributes();
094:                Node opNode = attribs.getNamedItem("mode");
095:
096:                if (opNode == null)
097:                    throw new RuntimeException(
098:                            "Invalid mode. Expected 'AND','OR', or 'NOT'"
099:                                    + " in '" + XML.serializeNode(n) + "'");
100:                else if (opNode.getNodeValue().equals("OR"))
101:                    return getGroupEvaluator(OR, n);
102:                else if (opNode.getNodeValue().equals("NOT"))
103:                    return getGroupEvaluator(NOT, n);
104:                else if (opNode.getNodeValue().equals("AND"))
105:                    return getGroupEvaluator(AND, n);
106:                else
107:                    throw new RuntimeException(
108:                            "Invalid mode. Expected 'AND','OR', or 'NOT'"
109:                                    + " in '" + XML.serializeNode(n) + "'");
110:            }
111:
112:            private Evaluator createAttributeEvaluator(Node n) {
113:                NamedNodeMap attribs = n.getAttributes();
114:                Node attribNode = attribs.getNamedItem("name");
115:
116:                if (attribNode == null || attribNode.getNodeValue().equals(""))
117:                    throw new RuntimeException(
118:                            "Missing or empty name attribute in '"
119:                                    + XML.serializeNode(n) + "'");
120:                String name = attribNode.getNodeValue();
121:                String value = null;
122:                attribNode = attribs.getNamedItem("value");
123:
124:                if (attribNode != null)
125:                    value = attribNode.getNodeValue();
126:
127:                attribNode = attribs.getNamedItem("mode");
128:
129:                if (attribNode == null || attribNode.getNodeValue().equals(""))
130:                    throw new RuntimeException(
131:                            "Missing or empty mode attribute in '"
132:                                    + XML.serializeNode(n) + "'");
133:                String mode = attribNode.getNodeValue();
134:                Evaluator eval = null;
135:
136:                try {
137:                    eval = getAttributeEvaluator(name, mode, value);
138:                } catch (Exception e) {
139:                    throw new RuntimeException(e.getMessage() + " in '"
140:                            + XML.serializeNode(n));
141:                }
142:                return eval;
143:            }
144:
145:            /**
146:             * returns an Evaluator unique to the type of attribute being
147:             * evaluated.  subclasses can override this method to return the
148:             * Evaluator that's appropriate to their implementation.
149:             *
150:             * @param name  the attribute's name.
151:             * @param mode  the attribute's mode. (i.e. 'equals')
152:             * @param value the attribute's value.
153:             *
154:             * @return an Evaluator for evaluating attributes
155:             */
156:            public Evaluator getAttributeEvaluator(String name, String mode,
157:                    String value) throws Exception {
158:                return new AttributeEvaluator(name, mode, value);
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.