org.mmbase.module
Class INFO

java.lang.Object
  extended by org.mmbase.util.functions.FunctionProvider
      extended by org.mmbase.util.functions.DescribedFunctionProvider
          extended by org.mmbase.module.Module
              extended by org.mmbase.module.ProcessorModule
                  extended by org.mmbase.module.INFO
All Implemented Interfaces:
Descriptor

public class INFO
extends ProcessorModule

The INFO module provides access to the environment on which the mmbase system resides. It can retrieve information on the file system, system memory, time, current user or browser, and miscellaneous information that is not directly related to the object cloud. Most functions in this module are specific for SCAN - other scripting languages generally have their own ways of obtaining this data.

Version:
$Id: INFO.java 35335 2009-05-21 08:14:41Z michiel $ .
Author:
Daniel Ockeloen, Eduard Witteveen, Pierre van Rooden
Application:
SCAN
Rename:
Info

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mmbase.module.ProcessorModule
ProcessorModule.GetNodeListFunction, ProcessorModule.ProcessFunction, ProcessorModule.ReplaceFunction
 
Field Summary
(package private)  Hashtable<String,SortedVector> DirCache
           
(package private)  String documentroot
           
static int Dutch
           
static int English
           
static int Not
           
(package private)  Random rnd
           
 
Fields inherited from class org.mmbase.module.ProcessorModule
PARAM_PAGEINFO, PARAMS_PAGEINFO
 
Fields inherited from class org.mmbase.module.Module
configurationPath, getMaintainerFunction, getVersionFunction, properties, STATE_START_TIME
 
Fields inherited from class org.mmbase.util.functions.DescribedFunctionProvider
description, guiName, name
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions, getFunctions
 
Constructor Summary
INFO()
          Constructor for
 
Method Summary
(package private)  String doBrowser(PageInfo sp, StringTokenizer tok)
          Returns data about the user's browser.
Valid options are:
OS : returns the operating system.
(package private)  Vector doColor(StringTokenizer tok)
          Returns a list of color names and their RGB values.
(package private)  Vector doColor16()
          Returns a list of the 16 windows color names and their RGB values.
(package private)  Vector doColorBasic()
          Returns a list of basic color names and their RGB values.
(package private)  Vector doColorSpectrum()
          Returns a list of primary and secondary color names and their RGB values.
(package private)  String doEscape(PageInfo sp, StringTokenizer tok)
          Converts a string into a string with 'escaped' quotes.
The argument for this command is the string to 'escape'.
protected  String doExists(PageInfo sp, StringTokenizer tok)
          Tests whether a given filename exists either as a directory, as a file, or as a path (depending on the subcommand given).
(package private)  String doMemory(StringTokenizer tok)
          This method is used to retrieve the amount of FREE MEMORY in either the JVM or the SYSTEM.
Valid options are:
GETJVM (default) : returns free memory of the Java Virtual Machine GETSYS : return the free memory on the system B(default) :return memory in bytes KB: :return memory in kilo bytes MB: :return memory in mega bytes
(package private)  String doOs(PageInfo sp, StringTokenizer tok)
          Retrieve the name of the user's operating system.
(package private)  String doParamDecode(PageInfo sp, StringTokenizer tok)
          Converts an URL-encoded string into a ASCII string.
The argument for this command is the string to decode.
(package private)  String doParamEncode(PageInfo sp, StringTokenizer tok)
          Converts an ASCII string into a URL-encoded string.
The argument for this command is the string to encode.
(package private)  String doParseTime(StringTokenizer tok)
          takes a time in several formats and creates a time from it
(package private)  String doRandom(PageInfo sp, StringTokenizer tok)
          Returns a random number in a specified range.
(package private)  Vector doRange(StringTokenizer tok)
          Returns a continues range of values with two set numerical boundaries and a step-increase, or the range of characters of the alphabet.
(package private)  String doRelTime(StringTokenizer tok)
          This method is used to retrieve time related info from a relative time value.
(package private)  Vector doScanDate(PageInfo sp, StringTagger tagger)
          Deprecated. hereditary code. Should be dropped or adapted.
(package private)  String doString(StringTokenizer tok)
          Performs tests on strings.
(package private)  String doTime(StringTokenizer tok)
          Formats either the current or a given timevalue according to a specified format.
(package private)  String doTimeFormat(StringTokenizer tok, boolean inSec)
          Formats either the current or a given timevalue according to a specified format.
(package private)  String doUser(PageInfo sp, StringTokenizer tok)
          Returns information on the user Valid options are:
NAME, which returns the username in SCAN
HOSTNAME, which returns the name of the remote host (visiting) in SCAN
IPNUMBER, which returns the ipnumber of the remote host(visiting) in SCAN
SECLEVEL, which returns current security level in SCAN
REQUEST_URI, which returns the path of the file requested in SCAN
BACK, which returns the name of the page visted befote the current page, notice not supported by all browsers
COUNTRY, which returns the country name of the remote host ( mmbase.nl -> nl; mmbase.org-> org )
DOMAIN, which returns the domain name of the remote host
INDOMAIN, which returns YES when remote host has the same domain as us otherwise it returns NO in SCAN
(package private)  SortedVector getDirTimes(File scanfile)
          Retrieves the creation times of all directories under a specific path whose names are 10 characters long.
 List<String> getList(PageInfo sp, StringTagger tagger, String value)
          Generate a list of values from a command to the processor.
 String getModuleInfo()
          Returns a description of the module.
protected  Map getProperties(String propertytable)
          Returns the properties to the subclass.
protected  String getProperty(String name, String var)
          Returns one propertyvalue to the subclass (original in Module).
 void init()
          Initializes the module.
 boolean process(PageInfo sp, Hashtable cmds, Hashtable vars)
          Execute the commands provided in the form values.
 String replace(PageInfo sp, String cmds)
          Handle a $MOD command.
(package private)  SortedVector revertVector(SortedVector src)
          Reverse the order of a list of values
 
Methods inherited from class org.mmbase.module.ProcessorModule
getListBuilder, getNodeList, onload, reload, replace, unload
 
Methods inherited from class org.mmbase.module.Module
addInitParameters, checkModules, getInitParameter, getInitParameter, getInitParameter, getInitParameters, getInitParameters, getMaintainer, getModule, getModule, getModule, getModule, getModuleLoader, getModuleReader, getModuleReader, getModules, getState, getStates, getVersion, hasModule, hasStarted, loadInitParameters, loadInitParameters, maintainance, setInitParameter, setMaintainer, setState, setVersion, shutdown, shutdownModules, startModule, startModules
 
Methods inherited from class org.mmbase.util.functions.DescribedFunctionProvider
getDefaultLocale, getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName, setLocalizedDescription, setLocalizedGUIName, setName
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue, newFunctionInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Not

public static final int Not
See Also:
Constant Field Values
Rename:
NOT

Dutch

public static final int Dutch
See Also:
Constant Field Values

English

public static final int English
See Also:
Constant Field Values

rnd

Random rnd
Scope:
private

documentroot

String documentroot
Scope:
private

DirCache

Hashtable<String,SortedVector> DirCache
Scope:
private
Constructor Detail

INFO

public INFO()
Constructor for

Method Detail

init

public void init()
Initializes the module. Determines the document root by reading system properties.

Overrides:
init in class ProcessorModule

getProperty

protected String getProperty(String name,
                             String var)
Returns one propertyvalue to the subclass (original in Module).


getList

public List<String> getList(PageInfo sp,
                            StringTagger tagger,
                            String value)
Generate a list of values from a command to the processor. The commands processed are :
COLOR-BASIC : returns a list of (system) color names and their RGB values
RANGE-X-Y-Z : returns a list of values in the numeric range X to Y, using Z as the increment factor (step) i.e RANGE-0-12-3 returns the values 0, 3 ,6 ,9, 12
The default values of X, Y and Z are 1, 10 and 1.
RANGE-ALPHA : returns the values 'A' thru 'Z'
SCANDATE :returns a list of dates (date, month, day, day-of-week) of all directories in a given path with a file length of 10 characters. No, I don't get it either.

Overrides:
getList in class ProcessorModule
Parameters:
sp - the current page context
tagger - the parameters (name-value pairs) belonging to the command to process
value - the command to process
Returns:
a Vector containing the requested values.
Throws:
ParseException

process

public boolean process(PageInfo sp,
                       Hashtable cmds,
                       Hashtable vars)
Execute the commands provided in the form values. Does not do anything except output debug code.

Overrides:
process in class ProcessorModule
Parameters:
sp - the current page context
cmds - the command to process
vars - the variables to process
Returns:
alwyas false

replace

public String replace(PageInfo sp,
                      String cmds)
Handle a $MOD command. This generally replaces the command in the SCAN page with the value returned by the command. Commands include:
BROWSER : returns browser or host name
DECODE : decodes a URL-encodes stringvalue
ENCODE : URL-encodes a strignvalue
ESCAPE : escapes the single quotes in a stringvalue
EXISTS : test if a file exists MEMORY : returns free meory
MOVE : Move a file on the system OS : retrieve the name of the user's Operating System RANDOM : returns a random number RELTIME : convert (relative) time values TIME : return a specific time value TIMEFORMAT/TIMEFORMATSEC : format a timevalue PARSETIME : parse time to seconds STRING : USER :

Overrides:
replace in class ProcessorModule
Parameters:
sp - the current page context
cmds - the command to process
Returns:
a String with the command's result value

doParseTime

String doParseTime(StringTokenizer tok)
takes a time in several formats and creates a time from it

Parameters:
tok - the processing command's arguments

doTimeFormat

String doTimeFormat(StringTokenizer tok,
                    boolean inSec)
Formats either the current or a given timevalue according to a specified format. Cmd arguments are an optional timevalue and a format (default HH:MM:ss).

Parameters:
tok - the processing command's arguments
inSec - if true, the timevalue is in seconds instead of milliseconds
Returns:
a String containing the time in the specified format

doString

String doString(StringTokenizer tok)
Performs tests on strings. Cmd arguments are: EQUALS-val-compareVal : checks whether two strings are the same STARTSWITH-val-compareVal(-toffset) or LEFTSTRING : checks whether one strings starts with another ENDSWITH-val-compareVal or RIGHTSTRING : checks whether one strings ends with another INDEXOF-val-compareVal or CONTAINS : checks whether one string contains another

Parameters:
tok - StringTokenizer with the rest of the cmd.
Returns:
A string conmtaining the value true if the test succeeds

doEscape

String doEscape(PageInfo sp,
                StringTokenizer tok)
Converts a string into a string with 'escaped' quotes.
The argument for this command is the string to 'escape'.

Parameters:
sp - the current page context
tok - the StringTokenizer containing the subsequent cmd argument tokens.
Returns:
a String which is the converted value

doParamEncode

String doParamEncode(PageInfo sp,
                     StringTokenizer tok)
Converts an ASCII string into a URL-encoded string.
The argument for this command is the string to encode.

Parameters:
sp - the current page context
tok - the StringTokenizer containing the subsequent cmd argument tokens.
Returns:
a String which is the converted value

doParamDecode

String doParamDecode(PageInfo sp,
                     StringTokenizer tok)
Converts an URL-encoded string into a ASCII string.
The argument for this command is the string to decode.

Parameters:
sp - the current page context
tok - the StringTokenizer containing the subsequent cmd argument tokens.
Returns:
a String which is the converted value

doOs

String doOs(PageInfo sp,
            StringTokenizer tok)
Retrieve the name of the user's operating system. This command takes no arguments

Parameters:
sp - the current page context
tok - the StringTokenizer containing the subsequent cmd argument tokens.
Returns:
a String which is the converted value

doRandom

String doRandom(PageInfo sp,
                StringTokenizer tok)
Returns a random number in a specified range. The command arguments are the start and end of the numerical range in which the random number should fall.

Parameters:
sp - the current page context param tok the StringTokenizer containing the subsequent cmd argument tokens.
Returns:
a String containing a random number

doBrowser

String doBrowser(PageInfo sp,
                 StringTokenizer tok)
Returns data about the user's browser.
Valid options are:
OS : returns the operating system. HTTP : returns the requested HTTP-header. WANTEDHOST : returns the host name. NAME : returns the name of the current browser NETSCAPE : returns YES is the current browser is netscape navigator, NO otherwise MSIE : returns YES is the current browser is internet explorer, NO otherwise

Parameters:
sp - the current page context
tok - The StringTokenizer containing the subsequent cmd argument tokens.
Returns:
a String containing the result

doUser

String doUser(PageInfo sp,
              StringTokenizer tok)
Returns information on the user Valid options are:
NAME, which returns the username in SCAN
HOSTNAME, which returns the name of the remote host (visiting) in SCAN
IPNUMBER, which returns the ipnumber of the remote host(visiting) in SCAN
SECLEVEL, which returns current security level in SCAN
REQUEST_URI, which returns the path of the file requested in SCAN
BACK, which returns the name of the page visted befote the current page, notice not supported by all browsers
COUNTRY, which returns the country name of the remote host ( mmbase.nl -> nl; mmbase.org-> org )
DOMAIN, which returns the domain name of the remote host
INDOMAIN, which returns YES when remote host has the same domain as us otherwise it returns NO in SCAN

Parameters:
tok - StringTokenizer with the rest of the cmd.
sp - the scanpage
Returns:
a String containing cmd result.

getProperties

protected Map getProperties(String propertytable)
Returns the properties to the subclass.


doRange

Vector doRange(StringTokenizer tok)
Returns a continues range of values with two set numerical boundaries and a step-increase, or the range of characters of the alphabet.
i.e. RANGE-60-100-10 returns 60,70,80,90,100
RANGE-ALPHA returns A,B,C,....Y.Z

Parameters:
tok - The StringTokenizer containing the subsequent cmd argument tokens.
Returns:
a String containing the result

doColor

Vector doColor(StringTokenizer tok)
Returns a list of color names and their RGB values.
COLOR-BASIC returns a list of basic colors.
COLOR-PRIMARY returns a list of primary colors.
No other options are yet implemented

Parameters:
tok - The commands to be executed
Returns:
a Vector containing color names and RGB values

doColorBasic

Vector doColorBasic()
Returns a list of basic color names and their RGB values.
These include the basic RGB colors, as well as mint-blue and mint-green.

Returns:
a Vector containing color names and RGB values

doColorSpectrum

Vector doColorSpectrum()
Returns a list of primary and secondary color names and their RGB values.

Returns:
a Vector containing color names and RGB values

doColor16

Vector doColor16()
Returns a list of the 16 windows color names and their RGB values.

Returns:
a Vector containing color names and RGB values

doTime

String doTime(StringTokenizer tok)
Formats either the current or a given timevalue according to a specified format. Cmd arguments are an optional timevalue, a format, and the timepart to return.

Parameters:
tok - the processing command's arguments
inSec - if true, the timevalue is in seconds instead of milliseconds
Returns:
a String containing the time in the specified format

getModuleInfo

public String getModuleInfo()
Returns a description of the module.

Overrides:
getModuleInfo in class Module
Returns:
a String describing the module's function.

doRelTime

String doRelTime(StringTokenizer tok)
This method is used to retrieve time related info from a relative time value. Valid commands are : GET/GETTIME-timeValueInMillis : time passed since the indicated time GETHOURS-timeValueInMillis : hours passed since the indicated time GETMINUTES-timeValueInMillis : minutes passed since the indicated time GETSECONDS-timeValueInMillis : seconds passed since the indicated time GETMILLIS-timeValueInMillis : milliseconds passed since the indicated time COUNTMILLIS-hourValue-minuteValue-secondValue-milliValue : milisecodms past siunce the indicated time

Parameters:
tok - The StringTokenizer containing the subsequent cmd argument tokens.
Returns:
A String containing cmd result.

doMemory

String doMemory(StringTokenizer tok)
This method is used to retrieve the amount of FREE MEMORY in either the JVM or the SYSTEM.
Valid options are:
GETJVM (default) : returns free memory of the Java Virtual Machine GETSYS : return the free memory on the system B(default) :return memory in bytes KB: :return memory in kilo bytes MB: :return memory in mega bytes

Parameters:
tok - The StringTokenizer containing the subsequent cmd argument tokens.
Returns:
A String containing the available memory.

doScanDate

Vector doScanDate(PageInfo sp,
                  StringTagger tagger)
Deprecated. hereditary code. Should be dropped or adapted.

Returns a list of dates (date, month,day, day-of-week) of all directories in a given path with a file length of 10 characters. Requires tags are base (path) and start (date) Optional tags are end (date), STARTINCLUDED, ENDINCLUDED and REVERS (booleans)

Parameters:
sp - the current page context
tok - the commands to be executed
Returns:
a Vector containing color names and RGB values

revertVector

SortedVector revertVector(SortedVector src)
Reverse the order of a list of values

Parameters:
src - the source of values to reverse
Returns:
a Vector containing the reverse ordered list

getDirTimes

SortedVector getDirTimes(File scanfile)
Retrieves the creation times of all directories under a specific path whose names are 10 characters long.

Parameters:
scanfile - the path to search
Returns:
a Vector containing the times

doExists

protected String doExists(PageInfo sp,
                          StringTokenizer tok)
Tests whether a given filename exists either as a directory, as a file, or as a path (depending on the subcommand given). Subcommands are DIR, FILE, and PATH. This subcommand need be followed by a filename.

Parameters:
sp - the current page context
tok - the commands to be executed
Returns:
a String withe the value 'YES' if the check succeeded, 'NO' if it failed.


MMBase 2.0-SNAPSHOT - null