KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > IAccessRule


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.core;
12
13 import org.eclipse.core.runtime.IPath;
14
15 /**
16  * Describes an access rule to source and class files on a classpath entry.
17  * An access rule is composed of a file pattern and a kind (accessible,
18  * non accessible, or discouraged).
19  * <p>
20  * On a given classpath entry, the access rules are considered in the order given
21  * when the entry was created. When a source or class file matches an access
22  * rule's pattern, the access rule's kind define whether the file is considered
23  * accessible, non accessible, or its access is discouraged. If the source or class
24  * file doesn't match any accessible rule, it is considered accessible. A source or class
25  * file that is not accessible or discouraged can still be refered to but it is tagged as being not
26  * accessible - the Java builder will create a problem marker for example.
27  * The severity of the marker created from a non accessible rule is controled through
28  * the {@link JavaCore#COMPILER_PB_FORBIDDEN_REFERENCE} compiler option.
29  * The severity of the marker created from a discouraged rule is controled through
30  * the {@link JavaCore#COMPILER_PB_DISCOURAGED_REFERENCE} compiler option.
31  * Note this is different from inclusion and exclusion patterns on source classpath entries,
32  * where a source file that is excluded is not even compiled.
33  * Files patterns look like relative file paths with wildcards and are interpreted relative
34  * to each entry's path.
35  * File patterns are case-sensitive and they can contain '**', '*' or '?' wildcards (see
36  * {@link IClasspathEntry#getExclusionPatterns()} for the full description
37  * of their syntax and semantics).
38  * Note that file patterns must not include the file extension.
39  * <code>com/xyz/tests/MyClass</code> is a valid file pattern, whereas
40  * <code>com/xyz/tests/MyClass.class</code> is not valid.
41  * </p>
42  * <p>
43  * For example, if one of the entry path is <code>/Project/someLib.jar</code>,
44  * there are no accessible rules, and there is one non accessible rule whith pattern
45  * <code>com/xyz/tests/&#42;&#42;</code>, then class files
46  * like <code>/Project/someLib.jar/com/xyz/Foo.class</code>
47  * and <code>/Project/someLib.jar/com/xyz/utils/Bar.class</code> would be accessible,
48  * whereas <code>/Project/someLib.jar/com/xyz/tests/T1.class</code>
49  * and <code>/Project/someLib.jar/com/xyz/tests/quick/T2.class</code> would not be
50  * accessible.
51  * </p>
52  *
53  * @since 3.1
54  */

55 public interface IAccessRule {
56     
57     /**
58      * Constant indicating that files matching the rule's pattern are accessible.
59      */

60     int K_ACCESSIBLE = 0;
61     
62     /**
63      * Constant indicating that files matching the rule's pattern are non accessible.
64      */

65     int K_NON_ACCESSIBLE = 1;
66
67     /**
68      * Constant indicating that access to the files matching the rule's pattern is discouraged.
69      */

70     int K_DISCOURAGED = 2;
71
72     /**
73      * <p>Flag indicating that whether a type matching this rule should be ignored iff a type with
74      * the same qualified name can be found on a later classpath entry with a better
75      * accessibility.</p>
76      * <p>E.g. if a type p.X matches a rule K_NON_ACCESSIBLE | IGNORE_IF_BETTER
77      * on a library entry 'lib1' and another type p.X also matches a rule
78      * K_DISCOURAGED on library entry 'lib2' ('lib2' being after 'lib1' on the
79      * classpath), then p.X from 'lib2' will be used and reported as
80      * discouraged.</p>
81      *
82      * @since 3.2
83      */

84     int IGNORE_IF_BETTER = 0x100;
85
86     /**
87      * Returns the file pattern for this access rule.
88      *
89      * @return the file pattern for this access rule
90      */

91     IPath getPattern();
92     
93     /**
94      * Returns the kind of this access rule (one of {@link #K_ACCESSIBLE}, {@link #K_NON_ACCESSIBLE}
95      * or {@link #K_DISCOURAGED}).
96      *
97      * @return the kind of this access rule
98      */

99     int getKind();
100     
101     /**
102      * <p>Returns whether a type matching this rule should be ignored iff a type with
103      * the same qualified name can be found on a later classpath entry with a better
104      * accessibility.</p>
105      * <p>E.g. if a type p.X matches a rule K_NON_ACCESSIBLE | IGNORE_IF_BETTER
106      * on a library entry 'lib1' and another type p.X also matches a rule
107      * K_DISCOURAGED on library entry 'lib2' ('lib2' being after 'lib1' on the
108      * classpath), then p.X from 'lib2' will be used and reported as
109      * discouraged.</p>
110      *
111      * @return whether a type matching this rule should be ignored iff a type
112      * with the same qualified name can be found on a later classpath
113      * entry with a better accessibility
114      * @since 3.2
115      */

116     boolean ignoreIfBetter();
117
118 }
119
Popular Tags