Source Code Cross Referenced for AccessRuleSet.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » compiler » env » 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 » IDE Eclipse » jdt » org.eclipse.jdt.internal.compiler.env 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdt.internal.compiler.env;
011:
012:        import org.eclipse.jdt.core.compiler.CharOperation;
013:        import org.eclipse.jdt.core.compiler.IProblem;
014:
015:        /**
016:         * Definition of a set of access rules used to flag forbidden references to non API code.
017:         */
018:        public class AccessRuleSet {
019:
020:            private AccessRule[] accessRules;
021:            public String[] messageTemplates;
022:            public static final int MESSAGE_TEMPLATES_LENGTH = 4;
023:
024:            /**
025:             * Make a new set of access rules.
026:             * @param accessRules the access rules to be contained by the new set
027:             * @param messageTemplates a Sting[4] array specifying the messages for type, 
028:             * constructor, method and field access violation; each should contain as many
029:             * placeholders as expected by the respective access violation message (that is,
030:             * one for type and constructor, two for method and field); replaced by a
031:             * default value if null.
032:             */
033:            public AccessRuleSet(AccessRule[] accessRules,
034:                    String[] messageTemplates) {
035:                this .accessRules = accessRules;
036:                if (messageTemplates != null
037:                        && messageTemplates.length == MESSAGE_TEMPLATES_LENGTH)
038:                    this .messageTemplates = messageTemplates;
039:                else
040:                    this .messageTemplates = new String[] {
041:                            "{0}", "{0}", "{0} {1}", "{0} {1}" }; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
042:            }
043:
044:            /**
045:             * @see java.lang.Object#equals(java.lang.Object)
046:             */
047:            public boolean equals(Object object) {
048:                if (this  == object)
049:                    return true;
050:                if (!(object instanceof  AccessRuleSet))
051:                    return false;
052:                AccessRuleSet otherRuleSet = (AccessRuleSet) object;
053:                if (this .messageTemplates.length != MESSAGE_TEMPLATES_LENGTH
054:                        || otherRuleSet.messageTemplates.length != MESSAGE_TEMPLATES_LENGTH)
055:                    return false; // guard
056:                for (int i = 0; i < MESSAGE_TEMPLATES_LENGTH; i++)
057:                    if (!this .messageTemplates[i]
058:                            .equals(otherRuleSet.messageTemplates[i]))
059:                        return false;
060:                int rulesLength = this .accessRules.length;
061:                if (rulesLength != otherRuleSet.accessRules.length)
062:                    return false;
063:                for (int i = 0; i < rulesLength; i++)
064:                    if (!this .accessRules[i]
065:                            .equals(otherRuleSet.accessRules[i]))
066:                        return false;
067:                return true;
068:            }
069:
070:            public AccessRule[] getAccessRules() {
071:                return this .accessRules;
072:            }
073:
074:            /**
075:             * Select the first access rule which is violated when accessing a given type, 
076:             * or null if no 'non accessible' access rule applies.
077:             * @param targetTypeFilePath the target type file path, formed as: 
078:             * "org/eclipse/jdt/core/JavaCore"
079:             * @return the first access restriction that applies if any, null else
080:             */
081:            public AccessRestriction getViolatedRestriction(
082:                    char[] targetTypeFilePath) {
083:                for (int i = 0, length = this .accessRules.length; i < length; i++) {
084:                    AccessRule accessRule = this .accessRules[i];
085:                    if (CharOperation.pathMatch(accessRule.pattern,
086:                            targetTypeFilePath, true/*case sensitive*/, '/')) {
087:                        switch (accessRule.getProblemId()) {
088:                        case IProblem.ForbiddenReference:
089:                        case IProblem.DiscouragedReference:
090:                            return new AccessRestriction(accessRule,
091:                                    this .messageTemplates);
092:                        default:
093:                            return null;
094:                        }
095:                    }
096:                }
097:                return null;
098:            }
099:
100:            public String toString() {
101:                return toString(true/*wrap lines*/);
102:            }
103:
104:            public String toString(boolean wrap) {
105:                StringBuffer buffer = new StringBuffer(200);
106:                buffer.append("AccessRuleSet {"); //$NON-NLS-1$
107:                if (wrap)
108:                    buffer.append('\n');
109:                for (int i = 0, length = this .accessRules.length; i < length; i++) {
110:                    if (wrap)
111:                        buffer.append('\t');
112:                    AccessRule accessRule = this .accessRules[i];
113:                    buffer.append(accessRule);
114:                    if (wrap)
115:                        buffer.append('\n');
116:                    else if (i < length - 1)
117:                        buffer.append(", "); //$NON-NLS-1$
118:                }
119:                buffer.append("} [templates:\""); //$NON-NLS-1$
120:                for (int i = 0; i < messageTemplates.length; i++)
121:                    buffer.append(this .messageTemplates[i]);
122:                buffer.append("\"]"); //$NON-NLS-1$
123:                return buffer.toString();
124:            }
125:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.