PageRenderTime 81ms CodeModel.GetById 40ms app.highlight 1ms RepoModel.GetById 39ms app.codeStats 0ms

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

#
Unknown | 32 lines | 27 code | 5 blank | 0 comment | 0 complexity | 76be8bfc771222d9db01c4c36eee90dc MD5 | raw file
 1/**
 2	Print the string value of the argument, which may be of any type.
 3	If beanshell is running interactively, the output will always go to the 
 4	command line, otherwise it will go to System.out.
 5	<p>
 6
 7	Most often the printed value of an object will simply be the Java 
 8	toString() of the object.  However if the argument is an array the contents 
 9	of the array will be (recursively) listed in a verbose way.
10	<p>
11
12	Note that you are always free to use System.out.println() 
13	instead of print().
14*/
15bsh.help.print = "usage: print( value )";
16
17void print( arg ) {
18	if ( arg == null )
19		arg = "null";
20
21	if ( arg instanceof Object [] ) {
22		len = arg.length;
23		print( "Array: "+arg +" {");
24		for( int i=0; i< len; i++ ) {
25			this.interpreter.print("   ");
26			print( arg[i] );
27		}
28		print ( "}");
29	} else
30		this.interpreter.println(String.valueOf(arg));
31}
32