01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.core;
11:
12: import org.eclipse.core.runtime.IPath;
13: import org.eclipse.core.runtime.Path;
14: import org.eclipse.jdt.core.IAccessRule;
15: import org.eclipse.jdt.core.compiler.IProblem;
16: import org.eclipse.jdt.internal.compiler.env.AccessRule;
17:
18: public class ClasspathAccessRule extends AccessRule implements
19: IAccessRule {
20:
21: public ClasspathAccessRule(IPath pattern, int kind) {
22: this (pattern.toString().toCharArray(), toProblemId(kind));
23: }
24:
25: public ClasspathAccessRule(char[] pattern, int problemId) {
26: super (pattern, problemId);
27: }
28:
29: private static int toProblemId(int kind) {
30: boolean ignoreIfBetter = (kind & IAccessRule.IGNORE_IF_BETTER) != 0;
31: switch (kind & ~IAccessRule.IGNORE_IF_BETTER) {
32: case K_NON_ACCESSIBLE:
33: return ignoreIfBetter ? IProblem.ForbiddenReference
34: | AccessRule.IgnoreIfBetter
35: : IProblem.ForbiddenReference;
36: case K_DISCOURAGED:
37: return ignoreIfBetter ? IProblem.DiscouragedReference
38: | AccessRule.IgnoreIfBetter
39: : IProblem.DiscouragedReference;
40: default:
41: return ignoreIfBetter ? AccessRule.IgnoreIfBetter : 0;
42: }
43: }
44:
45: public IPath getPattern() {
46: return new Path(new String(this .pattern));
47: }
48:
49: public int getKind() {
50: switch (getProblemId()) {
51: case IProblem.ForbiddenReference:
52: return K_NON_ACCESSIBLE;
53: case IProblem.DiscouragedReference:
54: return K_DISCOURAGED;
55: default:
56: return K_ACCESSIBLE;
57: }
58: }
59:
60: }
|