View Javadoc

1   /*
2    * $Id: KazukiContainer.java,v 1.7 2004/09/20 03:51:50 jlerner Exp $
3    *
4    * Copyright (c) 1999-2004, BBN Technologies, LLC.
5    * All rights reserved.
6    * http://www.daml.org/legal/opensource/bbn_license.html
7    */
8   package com.bbn.swede.library.kazuki;
9   
10  import org.eclipse.core.runtime.IPath;
11  import org.eclipse.core.runtime.Path;
12  import org.eclipse.jdt.core.IClasspathContainer;
13  import org.eclipse.jdt.core.IClasspathEntry;
14  import org.eclipse.jdt.core.JavaCore;
15  
16  /***
17   * A JDT classpath container for the Kazuki library.  This is necessary for APIs 
18   * generated by the Kazuki code generator to compile against the copy of 
19   * kazuki.jar
20   * that is distributed with SWeDE.
21   * @author jlerner
22   */
23  public class KazukiContainer implements IClasspathContainer
24  {
25     private IPath _path;
26     private static IClasspathEntry[] _classpathEntries;
27     
28     /***
29      * Creates a new instance of Kazuki classpath container that returns a 
30      * specified IPath as the container path.
31      * @param path The IPath to use as the container path
32      */
33     public KazukiContainer(IPath path)
34     {
35        _path = path;
36        computeClasspathEntries();
37     }
38  
39     /***
40      * Populates <code>_classpathEntries</code> with a list of all the jar
41      * files that are included in the Kazuki classpath container.
42      */
43     private void computeClasspathEntries()
44     {
45        if (_classpathEntries != null)
46        {
47           return;
48        }
49        String[] jars =
50           KazukiPlugin.getKazukiPlugin().getKazukiLibraryLocations();
51        _classpathEntries = new IClasspathEntry[jars.length];
52        for (int i = 0; i < jars.length; i++)
53        {
54           String sJarLoc = jars[i];
55           _classpathEntries[i] =
56              JavaCore.newLibraryEntry(new Path(sJarLoc), null, null);
57        }
58     }
59  
60     /*
61      *  (non-Javadoc)
62      * @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries()
63      */
64     public IClasspathEntry[] getClasspathEntries()
65     {
66        return _classpathEntries;
67     }
68  
69     /*
70      *  (non-Javadoc)
71      * @see org.eclipse.jdt.core.IClasspathContainer#getDescription()
72      */
73     public String getDescription()
74     {
75        return "Kazuki Library";
76     }
77  
78     /*
79      *  (non-Javadoc)
80      * @see org.eclipse.jdt.core.IClasspathContainer#getKind()
81      */
82     public int getKind()
83     {
84        return IClasspathContainer.K_APPLICATION;
85     }
86  
87     /*
88      *  (non-Javadoc)
89      * @see org.eclipse.jdt.core.IClasspathContainer#getPath()
90      */
91     public IPath getPath()
92     {
93        return _path;
94     }
95  
96  }