PageRenderTime 411ms CodeModel.GetById 9ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  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. Most often the printed value of an object will simply be the Java
  7. toString() of the object. However if the argument is an array the contents
  8. of the array will be (recursively) listed in a verbose way.
  9. <p>
  10. Note that you are always free to use System.out.println()
  11. instead of print().
  12. */
  13. bsh.help.print = "usage: print( value )";
  14. void print( arg ) {
  15. if ( arg == null )
  16. arg = "null";
  17. if ( arg instanceof Object [] ) {
  18. len = arg.length;
  19. print( "Array: "+arg +" {");
  20. for( int i=0; i< len; i++ ) {
  21. this.interpreter.print(" ");
  22. print( arg[i] );
  23. }
  24. print ( "}");
  25. } else
  26. this.interpreter.println(String.valueOf(arg));
  27. }