KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > batch > ClasspathLocation


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.internal.compiler.batch;
12
13 import java.io.File JavaDoc;
14
15 import org.eclipse.jdt.core.compiler.CharOperation;
16 import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
17 import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
18 import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
19
20 public abstract class ClasspathLocation implements FileSystem.Classpath,
21         SuffixConstants {
22
23     public static final int SOURCE = 1;
24     public static final int BINARY = 2;
25     
26     public AccessRuleSet accessRuleSet;
27
28     public String JavaDoc destinationPath;
29         // destination path for compilation units that are reached through this
30
// classpath location; the coding is consistent with the one of
31
// Main.destinationPath:
32
// == null: unspecified, use whatever value is set by the enclosing
33
// context, id est Main;
34
// == Main.NONE: absorbent element, do not output class files;
35
// else: use as the path of the directory into which class files must
36
// be written.
37
// potentially carried by any entry that contains to be compiled files
38

39     protected ClasspathLocation(AccessRuleSet accessRuleSet,
40             String JavaDoc destinationPath) {
41         this.accessRuleSet = accessRuleSet;
42         this.destinationPath = destinationPath;
43     }
44
45     /**
46      * Return the first access rule which is violated when accessing a given
47      * type, or null if no 'non accessible' access rule applies.
48      *
49      * @param qualifiedBinaryFileName
50      * tested type specification, formed as:
51      * "org/eclipse/jdt/core/JavaCore.class"; on systems that
52      * use \ as File.separator, the
53      * "org\eclipse\jdt\core\JavaCore.class" is accepted as well
54      * @return the first access rule which is violated when accessing a given
55      * type, or null if none applies
56      */

57     protected AccessRestriction fetchAccessRestriction(String JavaDoc qualifiedBinaryFileName) {
58         if (this.accessRuleSet == null)
59             return null;
60         char [] qualifiedTypeName = qualifiedBinaryFileName.
61             substring(0, qualifiedBinaryFileName.length() - SUFFIX_CLASS.length)
62             .toCharArray();
63         if (File.separatorChar == '\\') {
64             CharOperation.replace(qualifiedTypeName, File.separatorChar, '/');
65         }
66         return this.accessRuleSet.getViolatedRestriction(qualifiedTypeName);
67     }
68 }
69
Popular Tags