Spec-Zone .ru
спецификации, руководства, описания, API
Documentation Contents
jrunscript JavaScript built-ins

Class GLOBALS

Object
   |
   +--GLOBALS

class GLOBALS

 
Method Summary
<static> void cat(obj, pattern)
           Shows the content of a file, URL or InputStream
<static> void cd(target)
           Changes the present working directory to the given directory
<static> void cp(from, to)
           Copies a file, URL, or stream to another file or stream
<static> void date()
           Prints the current date using the current locale
<static> void del(pathname)
           A synonym for 'rm'
<static> void dir(d, filter)
           A synonym for 'ls'.
<static> Object dirname(pathname)
           Returns the directory part of a filename
<static> void echo(x)
           Echoes the given string arguments
<static> void exec(cmd)
           Execs a child process, waits for completion & returns exit code
<static> void exit(code)
           Exit the shell program.
<static> void find(dir, pattern, callback)
           Find in files.
<static> void grep(pattern, files )
           Unix-like grep, but accepts JavaScript regex patterns
<static> void ip(name)
           Prints the IP addresses of a given domain name
<static> void load(str)
           Loads and evaluates JavaScript code from a stream, file, or URL
<static> void ls(dir, filter)
           Lists the files in a directory
<static> void mkdir(dir)
           Creates a new directory of a given name
<static> void mkdirs(dir)
           Creates a directory, including any necessary but nonexistent parent directories.
<static> void mv(from, to)
           Moves a file to another
<static> Object printf(format, args)
           A C-like printf
<static> void pwd()
           Print the working directory
<static> void quit(code)
           synonym for exit
<static> Object read(prompt, multiline)
           Reads one or more lines from stdin after printing a prompt
<static> void ren(from, to)
           A synonym for 'mv'.
<static> Object rm(pathname)
           Removes a given file
<static> void rmdir(pathname)
           Removes a given directory
<static> void which(cmd)
           Prints which command is selected from PATH
<static> Object XMLDocument(inp)
           Converts input to DOM Document object
<static> Object XMLResult(out)
           Converts an arbitrary stream, file to an XMLResult
<static> Object XMLSource(inp)
           Converts an arbitrary stream, file, URL to an XMLSource
<static> void XSLTransform(inp, style, out)
           Perform XSLT transform


Method Detail

cat

<static> void cat(obj, pattern)
Shows the content of a file, URL, or InputStream
Examples:
 
    cat('test.txt'); // show test.txt file contents
    cat('http://java.net'); // show the contents from the URL http://java.net 
 
 
Parameters:
obj - input to show
pattern - optional. Show only the lines matching the pattern

cd

<static> void cd(target)
Changes the present working directory to the given directory
Parameters:
target - the directory to change to. optional, defaults to user's HOME

cp

<static> void cp(from, to)
Copies a file, URL, or stream to another file or stream
Parameters:
from - the input file, URL, or stream
to - the output stream or file

date

<static> void date()
Prints the current date using the current locale

del

<static> void del(pathname)
A synonym for 'rm'

dir

<static> void dir(d, filter)
A synonym for 'ls'.

dirname

<static> Object dirname(pathname)
Returns the directory part of a filename
Parameters:
pathname - the input path name
Returns:
the directory part of the given file name

echo

<static> void echo(x)
Echoes the given string arguments

exec

<static> void exec(cmd)
Execs a child process, waits for completion & returns the exit code
Parameters:
cmd - the command to execute in child process

exit

<static> void exit(exitCode)
Exit the shell program.
Parameters:
exitCode - the integer code to be returned to the OS shell. Optional, defaults to 0

find

<static> void find(dir, pattern, callback)
Find in files. Calls a specified callback function for each matching file.
Examples:
 
    find('.') 
    find('.', '.*\.class', rm);  // remove all .class files 
    find('.', '.*\.java');       // print fullpath of each .java file 
    find('.', '.*\.java', cat);  // print all .java files 
 
 
Parameters:
dir - the directory of files to search
pattern - the pattern to search for
callback - the function to call for matching files

grep

<static> void grep(pattern, files )
Unix-like grep, but accepts JavaScript regex patterns
Parameters:
pattern - the pattern to search for
files - one or more files to be searched

ip

<static> void ip(name)
Prints the IP addresses of given domain name
Parameters:
name - the domain name

load

<static> void load(str)
Loads and evaluates JavaScript code from a stream, file, or URL
Examples:
 
    load('test.js'); // load script file 'test.js'
    load('http://java.sun.com/foo.js'); // load from a URL
 
 
Parameters:
str - the input from which the script is loaded and evaluated

ls

<static> void ls(dir, filter)
Lists the files in a directory
Parameters:
dir - the directory from which to list the files. Optional, default to pwd
filter - a pattern to filter the files listed. Optional, default is '.'

mkdir

<static> void mkdir(dir)
Creates a new directory
Parameters:
dir - the name of the new directory

mkdirs

<static> void mkdirs(dir)
Creates a directory, including any necessary but nonexistent parent directories.
Parameters:
dir - the pathname of the directory to be created

mv

<static> void mv(from, to)
Moves a file to another
Parameters:
from - the original name of the file
to - the new name for the file

printf

<static> Object printf(format, args)
A C-like printf
Parameters:
format - the string to format the rest of the print items
args - the variadic argument list

pwd

<static> void pwd()
Print the working directory

quit

<static> void quit(code)
A synonym for exit

read

<static> Object read(prompt, multiline)
Reads one or more lines from stdin after printing a prompt
Parameters:
prompt - the prompt. Optional, default is '>'
multiline - if 0, read a single line, else read multiple lines

ren

<static> void ren(from, to)
A synonym for 'mv'.

rm

<static> Object rm(pathname)
Removes a given file
Parameters:
pathname - the name of the file

rmdir

<static> void rmdir(pathname)
Removes a given directory
Parameters:
pathname - the name of the directory

which

<static> void which(cmd)
Print the pathname of a command located on PATH
Parameters:
cmd - the name of the command searched from PATH

XMLDocument

<static> Object XMLDocument(inp)
Converts input to a DOM Document object
Parameters:
inp - a file or reader. Optional, If missing a new DOM Document is returned.
Returns:
returns a DOM Document object

XMLResult

<static> Object XMLResult(out)
Convert an arbitrary stream or file to an XMLResult
Parameters:
inp - the input stream or file
Returns:
XMLResult object

XMLSource

<static> Object XMLSource(inp)
Converts an arbitrary stream, file, or URL to an XMLSource
Parameters:
inp - the input stream, file, or URL
Returns:
XMLSource object

XSLTransform

<static> void XSLTransform(inp, style, out)
Perform an XSLT transform
Parameters:
inp - the input XML to transform (URL, File or InputStream)
style - the XSL Stylesheet to be used (URL, File or InputStream). Optional.
out - the output XML (File or OutputStream)


Oracle and/or its affiliates Copyright © 1993, 2012, Oracle and/or its affiliates. All rights reserved.
Contact Us