|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Utils
This interface describes the methods available in the "utils" context of the MIB Explorer scripting programming interface. The Utils context provides utility services to temporarily cease script execution, stop script execution, create random integers, and to create an empty Vector (e.g., to collect response PDUs).
Method Summary | |
---|---|
java.lang.Integer |
asInteger(java.lang.String integerString)
Returns the Integer representation of the supplied number string. |
java.util.List |
asList(byte[] array)
Converts the supplied byte array to a List. |
java.util.List |
asList(char[] array)
Converts the supplied character array to a List. |
java.util.List |
asList(double[] array)
Converts the supplied double array to a List. |
java.util.List |
asList(int[] array)
Converts the supplied integer array to a List. |
java.util.List |
asList(long[] array)
Converts the supplied long array to a List. |
java.util.List |
asList(java.lang.Object[] array)
Converts the supplied object array to a List. |
java.util.List |
asList(short[] array)
Converts the supplied short array to a List. |
void |
clearOutput()
Clears the script's output buffer. |
java.util.Vector |
createVector()
Creates an empty Vector . |
java.lang.String |
downloadFile(java.lang.String url,
java.lang.String targetFileName)
Downloads the file specified by the supplied URL to the given file name on the local system. |
java.lang.String |
downloadString(java.lang.String url)
Downloads the content from the specified URL using the default character set in MIB Explorer's locale. |
java.util.Vector |
exec(java.util.List cmdarray)
Executes the specified command and arguments in a separate process. |
java.util.Vector |
exec(java.util.List cmdarray,
java.util.List envp)
Executes the specified command arguments in a separate process with the specified environment. |
java.lang.String |
getCharacter(int uniCode)
Gets the character with the specified unicode. |
LoopCondition |
loopCondition()
Creates a loop condition which can be used in a VTL #foreach
statement to control loop termination by a boolean expression. |
java.lang.Integer |
rand(int n)
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence. |
boolean |
saveOutput(java.lang.String fileName)
Saves the content of the current script's output buffer to the supplied file. |
boolean |
sendEmail(java.lang.String smtpHost,
java.lang.String fromAddress,
java.lang.String to,
java.lang.String charSet,
java.lang.String subject,
java.lang.String contentType,
java.lang.String body)
Sends a text email to a given list of receipiens using unauthenticated SMTP. |
boolean |
sendEmail(java.lang.String smtpHost,
java.lang.String smtpUser,
java.lang.String smtpPassword,
java.lang.String fromAddress,
java.lang.String to,
java.lang.String charSet,
java.lang.String subject,
java.lang.String contentType,
java.lang.String body)
Sends a text email to a given list of receipiens using authenticated SMTP. |
void |
sleep(int millis)
Causes the currently executing script to sleep (temporarily cease execution) for the specified number of milliseconds. |
void |
stop()
Stop the execution of the script. |
java.lang.String[] |
toStringArray(java.util.List list)
Converts a List (i.e. |
Method Detail |
---|
java.util.Vector createVector()
Vector
. This vector can be used to collect
any data for further script processing.
Vector
.java.lang.String[] toStringArray(java.util.List list)
List
(i.e. Vector) to a String
array.
list
- a List
of arbitrary objects.
toString()
method of
each object in list
.java.lang.String getCharacter(int uniCode)
uniCode
- a value between 0 and 65535 (two bytes).
String
representing the specified character.void sleep(int millis)
millis
- the length of time to sleep in milliseconds.void stop()
java.lang.Integer rand(int n)
n
- the bound on the random number to be returned. Must be positive.
java.util.Vector exec(java.util.List cmdarray, java.util.List envp)
Given a list of strings cmdarray
, representing the tokens of a
command line, and a list of strings envp
, representing
"environment" variable settings, this method creates a new process in
which to execute the specified command.
If envp
is null
, the subprocess inherits the
environment settings of MIB Explorer.
The exec methods may not work well for special processes on certain native platforms, such as native windowing processes, daemon processes, Win16/DOS processes on Win32, or shell scripts. The created subprocess does not have its own terminal or console.
cmdarray
- a list of strings containing the command to call and its arguments.envp
- a list of strings, each element of which has environment variable
settings in format name=value
.
List
of an Integer
value followed by two strings:
The first element is an integer value represents the exit code of the
process.
The second element is a string containing the output of the started
process and third is a string containing the error output of the process.
If the command could not be executed, null
is returned.java.util.Vector exec(java.util.List cmdarray)
The command specified by the tokens in cmdarray is executed as a
command in a separate process. This has exactly the same effect as
exec(cmdarray, null)
.
cmdarray
- a list of strings containing the command to call and its arguments.
List
of an Integer
value followed by two strings:
The first element is an integer value represents the exit code of the
process.
The second element is a string containing the output of the started
process and third is a string containing the error output of the process.
If the command could not be executed, null
is returned.boolean sendEmail(java.lang.String smtpHost, java.lang.String smtpUser, java.lang.String smtpPassword, java.lang.String fromAddress, java.lang.String to, java.lang.String charSet, java.lang.String subject, java.lang.String contentType, java.lang.String body)
smtpHost
- the SMTP host to use, for example "mailserv.my-company.com".smtpUser
- the user at the SMTP host.smtpPassword
- the password for the above user.fromAddress
- the from address to be used, for example "myname@my-company.com".to
- a comma separated list of destination email addresses.charSet
- the character set to be used to encode the subject and the body.
If charSet
is null
or the empty string "",
then the default character set for the current locale is used.subject
- the subject to be used. It will be encoded using the specified
character set.contentType
- the content ID of the message body. If this parameter is null
or the zero length string, plain text is used as the content type.
Other possible values are for example "text/html" for a HTML body.body
- the body text. used. It will be encoded using the specified
character set.
true
if the email has been sent, otherwise false
is returned and a detailed error message is logged.boolean sendEmail(java.lang.String smtpHost, java.lang.String fromAddress, java.lang.String to, java.lang.String charSet, java.lang.String subject, java.lang.String contentType, java.lang.String body)
smtpHost
- the SMTP host to use, for example "mailserv.my-company.com".fromAddress
- the from address to be used, for example "myname@my-company.com".to
- a comma separated list of destination email addresses.charSet
- the character set to be used to encode the subject and the body.
If charSet
is null
or the empty string "",
then the default character set for the current locale is used.subject
- the subject to be used. It will be encoded using the specified
character set.contentType
- the content ID of the message body. If this parameter is null
or the zero length string, plain text is used as the content type.
Other possible values are for example "text/html" for a HTML body.body
- the body text. used. It will be encoded using the specified
character set.
true
if the email has been sent, otherwise false
is returned and a detailed error message is logged.void clearOutput()
boolean saveOutput(java.lang.String fileName)
fileName
- the path of a writable file. If the file does not exist it will be
created.
true
if the output could be saved, false
otherwise.java.util.List asList(java.lang.Object[] array)
array
- an Object array.
java.util.List asList(int[] array)
array
- an integer array.
java.util.List asList(byte[] array)
array
- a byte array.
java.util.List asList(long[] array)
array
- a long array.
java.util.List asList(double[] array)
array
- a double array.
java.util.List asList(short[] array)
array
- a short array.
java.util.List asList(char[] array)
array
- a character array.
java.lang.Integer asInteger(java.lang.String integerString)
integerString
- the integer String (must represent a valid int value).
java.lang.String downloadString(java.lang.String url)
url
- a HTTP URL of the form http://www.myserver.com/myfile.txt
.
java.lang.String downloadFile(java.lang.String url, java.lang.String targetFileName)
url
- a HTTP URL of the form http://www.myserver.com/myfile.gif
.targetFileName
- the file name of the file where the contents of url
should
be written
null
if the operation was successful, or an error text
if it failed.LoopCondition loopCondition()
#foreach
statement to control loop termination by a boolean expression.
|
Copyright 2003-2011, Frank Fock, All Rights Reserved. http://www.mibexplorer.com | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |