PageRenderTime 15ms CodeModel.GetById 8ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-1-pre5/bsh/commands/reloadClasses.bsh

#
Unknown | 55 lines | 46 code | 9 blank | 0 comment | 0 complexity | 48a21a9ddf511573ab0e4b07a8150029 MD5 | raw file
 1/**
 2	Reload the specified class, package name, or all classes if no name is 
 3	given.  e.g.
 4	<p>
 5
 6	<pre>
 7		reloadClasses();
 8		reloadClasses("mypackage.*");
 9		reloadClasses(".*")  // reload unpackaged classes
10		reloadClasses("mypackage.MyClass") 
11	</pre>
12	<p>
13	See <a href="classpath.html">Class Path Management</a>
14
15	@method void reloadClasses( [ package name ] )
16*/
17
18bsh.help.reloadClasses= 
19	"usage: reloadClasses( String class | String package | String [] classes )";
20
21import bsh.BshClassManager;
22import bsh.ClassPathException;
23
24void reloadClasses( item ) 
25{
26	bcm = BshClassManager.getClassManager();
27
28	try {
29		if ( item instanceof String [] )
30			bcm.reloadClasses( item );
31		else {
32			name = item;
33
34			if ( name.endsWith(".*" ) ) {
35				if ( name.equals(".*" ) )
36					pack = "<unpackaged>";
37				else
38					pack = name.substring( 0, name.length()-2 );
39				
40				bcm.reloadPackage( pack );
41			} else
42				bcm.reloadClasses( new String[] { name } );
43		}
44	} catch ( ClassPathException e ) {
45		error( e.getMessage() );
46	}
47}
48
49/**
50	Reload all classes
51*/
52void reloadClasses() 
53{
54	BshClassManager.getClassManager().reloadAllClasses();
55}