KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > runtime > model > LibraryModel


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.core.runtime.model;
12
13 import org.eclipse.core.runtime.Assert;
14 import org.eclipse.core.runtime.ILibrary;
15
16 /**
17  * A runtime library declared in a plug-in. Libraries contribute elements to the search path.
18  * These contributions are specified as a path to a directory or Jar file. This path is always
19  * considered to be relative to the containing plug-in.
20  * <p>
21  * Libraries are typed. The type is used to determine to which search path the library's
22  * contribution should be added. The valid types are: <code>CODE</code> and
23  * <code>RESOURCE</code>.
24  * </p>
25  * <p>
26  * This class may be instantiated, or further subclassed.
27  * </p>
28  * @deprecated In Eclipse 3.0 the runtime was refactored and all
29  * non-essential elements removed. This class provides facilities primarily intended
30  * for tooling. As such it has been removed and no directly substitutable API provided.
31  */

32 public class LibraryModel extends PluginModelObject {
33
34     // DTD properties (included in plug-in manifest)
35
private String JavaDoc[] exports = null;
36     private String JavaDoc type = CODE;
37     private String JavaDoc[] packagePrefixes = null;
38
39     // transient properties (not included in plug-in manifest)
40
private boolean isExported = false;
41     private boolean isFullyExported = false;
42
43     /**
44      * Constant string (value "code") indicating the code library type.
45      */

46     public static final String JavaDoc CODE = "code"; //$NON-NLS-1$
47

48     /**
49      * Constant string (value "resource") indicating the resource library type.
50      */

51     public static final String JavaDoc RESOURCE = "resource"; //$NON-NLS-1$
52

53     /**
54      * Creates a new library model in which all fields
55      * are <code>null</code>.
56      */

57     public LibraryModel() {
58         super();
59     }
60
61     /**
62      * Returns this library's export mask.
63      *
64      * @return this library's export mask or <code>null</code>
65      */

66     public String JavaDoc[] getExports() {
67         return exports;
68     }
69
70     /**
71      * Returns this library's type.
72      *
73      * @return the type of this library. The valid types are: <code>CODE</code> and <code>RESOURCE</code>.
74      * @see #CODE
75      * @see #RESOURCE
76      */

77     public String JavaDoc getType() {
78         return type;
79     }
80
81     /**
82      * Returns whether or not any of the code in this library is exported.
83      *
84      * @return whether or not any of the code in this library represents is exported
85      */

86     public boolean isExported() {
87         return isExported;
88     }
89
90     /**
91      * Returns whether or not all of the code in this library is exported.
92      *
93      * @return whether or not all of the code in this library is exported
94      */

95     public boolean isFullyExported() {
96         return isFullyExported;
97     }
98
99     /**
100      * Sets this library's export mask.
101      * This object must not be read-only.
102      *
103      * @param value this library's export mask. May be <code>null</code>.
104      */

105     public void setExports(String JavaDoc[] value) {
106         assertIsWriteable();
107         exports = value;
108         if (value == null) {
109             isExported = false;
110             isFullyExported = false;
111         } else {
112             for (int i = 0; i < value.length; i++) {
113                 if (!value[i].equals("")) //$NON-NLS-1$
114
isExported = true;
115                 if (value[i].equals("*")) //$NON-NLS-1$
116
isFullyExported = true;
117             }
118         }
119     }
120
121     /**
122      * Sets this library's type. The valid types are: <code>CODE</code> and <code>RESOURCE</code>.
123      * The given type value is canonicalized before being set.
124      * This object must not be read-only.
125      *
126      * @param value the type of this library.
127      * @see #CODE
128      * @see #RESOURCE
129      */

130     public void setType(String JavaDoc value) {
131         assertIsWriteable();
132         String JavaDoc lcValue = value.toLowerCase();
133         Assert.isTrue(lcValue.equals(CODE) || lcValue.equals(RESOURCE));
134         type = lcValue;
135     }
136
137     /**
138      * @see ILibrary#getPackagePrefixes()
139      */

140     public String JavaDoc[] getPackagePrefixes() {
141         return packagePrefixes;
142     }
143
144     /**
145      * Sets this library's package prefixes to be the specified array or <code>null</code>.
146      *
147      * @param value the list of package prefixes for this library
148      */

149     public void setPackagePrefixes(String JavaDoc[] value) {
150         packagePrefixes = value;
151     }
152 }
153
Popular Tags