*
Metamerge logo
Search

Advanced Search
*
*
*
* HOME DOCUMENTS & RESOURCES DOWNLOADS EARLY TECH ACCESS SUPPORT FAQ KNOWN ISSUES OLD VERSIONS
*

com.architech.function
Class userFunctions2

java.lang.Object
  |
  +--com.architech.function.userFunctions2

public class userFunctions2
extends java.lang.Object

This class contains a number of convenience methods widely used by the scripting environment. The scripting name for this class is known as system. This class is registered by default in the scripting environment by it's presence in the Java Libraries configuration page.


Field Summary
 java.lang.Exception lastError
          The Exception object set by the last call in this library.
 
Constructor Summary
userFunctions2()
           
 
Method Summary
 void abortAssemblyLine(java.lang.String reason)
          Throws a rseAbortAL exception to tell the assembly line to terminate the assembly line.
 int charCode(char ch)
          Returns a character's numeric value using the Character.digit method.
 int charCode(java.lang.String str, int index)
          Returns the numeric value for a character.
 boolean chdir(java.lang.String directory)
          Change Java runtime working directory (Sets the "user.dir" property which not always works!!).
 boolean copyFile(java.lang.String fromPath, java.lang.String toPath, boolean overwrite)
          Copy file.
 java.lang.String dtSeconds()
          Returns the number of milliseconds since Jan 1 1970 as a string.
 void dumpEntry(Entry e)
          Dumps an entry to the console log.
 boolean dumpJavaClass(java.lang.String className)
          Dumps the public methods for a Java class.
 java.lang.String entry2LDIF(Entry e)
          Converts an Entry object to an LDIF string.
 com.architech.connector.rscConnectorInterface getConnector(java.lang.String name)
          Load a connector.
 java.lang.String getcwd()
          Returns the current working directory.
 com.architech.protocols.FTPBean getFTP()
          Returns an instance of the FTP object.
 java.lang.String getJavaProperty(java.lang.String prop)
          Returns the value for a system property.
 java.lang.String getOSName()
          Returns the name of the operating system./
 com.architech.parser.rspParserInterface getParser(java.lang.String name)
          Load a parser.
 java.lang.String getScriptText(java.lang.String name)
          Returns the text from the Script Library.
 java.lang.String getX400Attribute(java.lang.String x400, java.lang.String sep, java.lang.String attribute)
          Returns an attribute value from an X.400 address.
 org.apache.xpath.XPathAPI getXPathAPI()
          Returns the Apache XPathAPI
 void ignoreEntry()
          Throws a rseEntryIgnore exception to tell the assembly line to skip the current connector and continue with the next connector in the assembly line.
 boolean isValidInt(java.lang.String str)
          Returns true if a string holds a valid Integer.
 com.architech.connector.rscConnectorInterface loadConnector(java.lang.String connectorName)
          Load a connector.
 java.lang.String mapString(java.lang.String source, java.lang.String fromSet, java.lang.String toSet)
          Translates characters in a string.
 Attribute newAttribute(java.lang.String name)
          Creates a new Attribute object.
 Entry newEntry()
          Creates a new Entry object.
 java.lang.Object newObject(java.lang.String className)
          Creates a new object.
 rscSearchCriteria newSearchCriteria()
          Creates a new rscSearchCriteira object.
 java.lang.String normalizeX400(java.lang.String value, java.lang.String cursep, java.lang.String newsep)
          Converts an X.400 address to a string using short form attribute names.
 java.io.BufferedWriter openFileForAppend(java.lang.String path)
          Opens a file in append mode and returns the associated BufferedWriter object.
 java.io.BufferedReader openFileForInput(java.lang.String path)
          Opens a file for input and returns the associated BufferedReader object.
 java.io.BufferedWriter openFileForOutput(java.lang.String path)
          Opens a file in output mode and returns the associated BufferedWriter object.
 java.util.Date parseDate(java.lang.String value, java.lang.String format)
          Converts a String to a java.util.Date object.
 Entry parseObject(java.lang.String parser, java.lang.Object data)
          Use a parser to interpret data.
 java.lang.String remove(java.lang.String s, java.lang.String source)
          Remove occurrences of a character from a string.
 java.lang.String removeStringChars(java.lang.String source, java.lang.String fromSet)
          Removes occurrences of characters from a string.
 void restartEntry()
          Throws a rseRestartEntry exception to tell the assembly line to skip all connectors and start with first connector in the assembly line using the current work object.
 com.architech.function.NodeIterator selectNodeIterator(com.architech.function.Node contextNode, java.lang.String str)
          Selects nodes using an XPath expression from an XML node.
 com.architech.function.NodeList selectNodeList(com.architech.function.Node contextNode, java.lang.String str)
          Selects nodes using an XPath expression from an XML node.
 com.architech.function.Node selectSingleNode(com.architech.function.Node contextNode, java.lang.String str)
          Selects a single node using an XPath expression from an XML node.
 java.lang.String sendMail(java.lang.String from, java.lang.String recipient, java.lang.String subject, java.lang.String body, java.lang.String attachment)
          Sends an email message.
 void setJavaProperty(java.lang.String prop, java.lang.String value)
          Sets the value of a property name.
 com.architech.function.executeCommand shellCommand(java.lang.String command)
          Executes a shell command.
 void skipEntry()
          Throws a rseEntrySkipped exception to tell the assembly line to skip the current entry.
 java.lang.InterruptedException sleep(int seconds)
          Causes the current thread (e.g. assembly line, event handler etc..) to sleep for a number of seconds.
 boolean snmpTrap(java.lang.String host, int port, java.lang.String oid, java.lang.String value)
          Sends an SNMP trap.
 java.lang.String[] splitString(java.lang.String source, java.lang.String separators)
          Splits a string into an array of strings.
 void throwException(java.lang.String message)
          Throws a generic java.lang.Exception.
 java.lang.String toHex(java.lang.String str)
          Converts a string to a hexadecimal string where each character is converted to a two-byte hex value.
 java.lang.Integer toInt(java.lang.String str)
          Convert a string to an java.lang.Integer object.
 java.lang.String translateString(java.lang.String str, java.lang.String fromCharset, java.lang.String toCharset)
          Translate a string from one character set to another.
 java.lang.String trim(java.lang.String str)
          Trims leading/traing white-space from a string.
 void writeln(java.io.Writer w, java.lang.String str)
          Writes a string plus a CRLF using a Writer object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastError

public java.lang.Exception lastError
The Exception object set by the last call in this library.
Constructor Detail

userFunctions2

public userFunctions2()
Method Detail

remove

public java.lang.String remove(java.lang.String s,
                               java.lang.String source)
                        throws java.lang.Exception
Remove occurrences of a character from a string. For example, if you want to remove all blanks from the string "J O P" then you would use remove (" ", "J O P"). The returned value would then be "JOP".
 var a = "A string with blanks";
 var b = system.remove (" ", a);
 task.logmsg ("Result: " + b);      // "Astringwithblanks"
 
Parameters:
s - The character to be removed
source - The string from which characters are removed

trim

public java.lang.String trim(java.lang.String str)
Trims leading/traing white-space from a string.
Parameters:
str - The string to trim
Returns:
The trimmed string

toInt

public java.lang.Integer toInt(java.lang.String str)
                        throws java.lang.Exception
Convert a string to an java.lang.Integer object.
Parameters:
str - The string with a number
Returns:
The Integer object

isValidInt

public boolean isValidInt(java.lang.String str)
Returns true if a string holds a valid Integer.
Parameters:
str - The string to test
Returns:
True if string can be converted to an Integer

openFileForAppend

public java.io.BufferedWriter openFileForAppend(java.lang.String path)
                                         throws java.lang.Exception
Opens a file in append mode and returns the associated BufferedWriter object.
Parameters:
path - The file path to open
Returns:
The BufferedWriter object

openFileForOutput

public java.io.BufferedWriter openFileForOutput(java.lang.String path)
                                         throws java.lang.Exception
Opens a file in output mode and returns the associated BufferedWriter object.
Parameters:
path - The file path to open (overwrites existing file)
Returns:
The BufferedWriter object

openFileForInput

public java.io.BufferedReader openFileForInput(java.lang.String path)
                                        throws java.lang.Exception
Opens a file for input and returns the associated BufferedReader object.
Parameters:
path - The file path to open
Returns:
The BufferedReader object

writeln

public void writeln(java.io.Writer w,
                    java.lang.String str)
             throws java.lang.Exception
Writes a string plus a CRLF using a Writer object.
Parameters:
w - The writer object
str - The string to write

sendMail

public java.lang.String sendMail(java.lang.String from,
                                 java.lang.String recipient,
                                 java.lang.String subject,
                                 java.lang.String body,
                                 java.lang.String attachment)
                          throws java.lang.Exception
Sends an email message. Make sure the mail.smtp.host property is configured with the hostname of a valid SMTP server.
Parameters:
from - The From field
recipient - A comma separated list of recipient addresses
subject - The Subject field
body - The message text
attachment - If specified a file-path that will be attached to the message

copyFile

public boolean copyFile(java.lang.String fromPath,
                        java.lang.String toPath,
                        boolean overwrite)
                 throws java.lang.Exception
Copy file. This method copies fromPath to toPath. The overwrite flag specifies whether the destination file should be overwritten.
Parameters:
fromPath - The source file
toPath - The destination file
overwrite - Specify true if destination should be overwritten.
Returns:
true if file was copied, false if toPath exists and overwrite=false.

newAttribute

public Attribute newAttribute(java.lang.String name)
Creates a new Attribute object.
Parameters:
name - The attribute name
Returns:
The Attribute object

newSearchCriteria

public rscSearchCriteria newSearchCriteria()
Creates a new rscSearchCriteira object.
Returns:
The rscSearchCriteria object

newEntry

public Entry newEntry()
Creates a new Entry object.
Returns:
The Entry object

newObject

public java.lang.Object newObject(java.lang.String className)
Creates a new object. This method only works for Java objects that have empty constructors. It is a convenience method for scripting languages that cannot create Java objects directly.
Parameters:
className - The java class name
Returns:
The rscSearchCriteria object

skipEntry

public void skipEntry()
               throws com.architech.exceptions.rseEntrySkipped
Throws a rseEntrySkipped exception to tell the assembly line to skip the current entry.

ignoreEntry

public void ignoreEntry()
                 throws com.architech.exceptions.rseEntryIgnore
Throws a rseEntryIgnore exception to tell the assembly line to skip the current connector and continue with the next connector in the assembly line.

restartEntry

public void restartEntry()
                  throws com.architech.exceptions.rseRestartEntry
Throws a rseRestartEntry exception to tell the assembly line to skip all connectors and start with first connector in the assembly line using the current work object.

abortAssemblyLine

public void abortAssemblyLine(java.lang.String reason)
                       throws com.architech.exceptions.rseAbortAL
Throws a rseAbortAL exception to tell the assembly line to terminate the assembly line.
Parameters:
reason - Descriptive text why the AL is terminated

throwException

public void throwException(java.lang.String message)
                    throws java.lang.Exception
Throws a generic java.lang.Exception.
Parameters:
message - The exception's message text

loadConnector

public com.architech.connector.rscConnectorInterface loadConnector(java.lang.String connectorName)
Load a connector. This method loads a connector from the current config file.
Parameters:
connectorName - The connector name as it appears in the configuration file
Returns:
The connector object

dtSeconds

public java.lang.String dtSeconds()
Returns the number of milliseconds since Jan 1 1970 as a string.
Returns:
Number of milliseconds

sleep

public java.lang.InterruptedException sleep(int seconds)
Causes the current thread (e.g. assembly line, event handler etc..) to sleep for a number of seconds. If the sleep is interrupted the InterruptedException value is returned. If not, null is returned.
Parameters:
seconds - Number of seconds to sleep
Returns:
null if successful, excpetion object otherwise

removeStringChars

public java.lang.String removeStringChars(java.lang.String source,
                                          java.lang.String fromSet)
Removes occurrences of characters from a string.
Parameters:
source - The source string
fromSet - A string specifying characters to be removed from source
Returns:
The resulting string

mapString

public java.lang.String mapString(java.lang.String source,
                                  java.lang.String fromSet,
                                  java.lang.String toSet)
Translates characters in a string. The fromSet and toSet contains the characters used to perform substitution. The first character in fromSet is replace with the first character in toSet etc.
Parameters:
source - The source string
fromSet - The characters to be replaced
toSet - The characters to replace characters in fromSet
Returns:
The substituted string

translateString

public java.lang.String translateString(java.lang.String str,
                                        java.lang.String fromCharset,
                                        java.lang.String toCharset)
Translate a string from one character set to another.
Parameters:
str - The source string
fromCharset - The source character set
toCharset - The target character set
Returns:
The translated string

toHex

public java.lang.String toHex(java.lang.String str)
Converts a string to a hexadecimal string where each character is converted to a two-byte hex value.
Parameters:
str - The source string
Returns:
The hexadecimal string

charCode

public int charCode(java.lang.String str,
                    int index)
Returns the numeric value for a character.
Parameters:
str - The source string
index - The position of the character in str
Returns:
The numeric value

charCode

public int charCode(char ch)
Returns a character's numeric value using the Character.digit method.
Parameters:
ch - The character
Returns:
The numeric value

getX400Attribute

public java.lang.String getX400Attribute(java.lang.String x400,
                                         java.lang.String sep,
                                         java.lang.String attribute)
Returns an attribute value from an X.400 address.
Parameters:
x400 - The X.400 address
sep - The separator used in the address ( typically "/" or ";" )
attribute - The X.400 attribute
Returns:
The value or null if no attribute was found

normalizeX400

public java.lang.String normalizeX400(java.lang.String value,
                                      java.lang.String cursep,
                                      java.lang.String newsep)
Converts an X.400 address to a string using short form attribute names. Attributes are sorted in order of significance.
Parameters:
value - The X.400 address
cursep - The separator used in value
newsep - The separator to be used in the result
Returns:
The reformatted X.400 address

parseDate

public java.util.Date parseDate(java.lang.String value,
                                java.lang.String format)
Converts a String to a java.util.Date object.
Parameters:
value - The date in string form
format - The format of value (e.g. "YYYY.MM.DD", "MM/DD/YY" etc ...)
Returns:
The Date object or null if an error occurred
See Also:
lastError

splitString

public java.lang.String[] splitString(java.lang.String source,
                                      java.lang.String separators)
Splits a string into an array of strings.
Parameters:
source - The source string
separators - The word-separating characters
Returns:
Array of strings

getConnector

public com.architech.connector.rscConnectorInterface getConnector(java.lang.String name)
Load a connector. This method loads a connector from the current config file.
Parameters:
name - The connector name as it appears in the configuration file
Returns:
The connector object

getParser

public com.architech.parser.rspParserInterface getParser(java.lang.String name)
Load a parser. This method loads a parser from the current config file.
Parameters:
name - The parser name as it appears in the configuration file
Returns:
The parser object

parseObject

public Entry parseObject(java.lang.String parser,
                         java.lang.Object data)
Use a parser to interpret data. This method will either use the data object as-is if it is a reader or inputstream class, or it will create a StringReader from the string representation of the data obect and pass it to the parser. The parser will be called to interpret the byte stream and return an Entry. If the parse fails a null is returned.
Parameters:
parser - The parser name
data - Any object of type Reader, InputStream or object that has a toString method
Returns:
The parsed entry
See Also:
lastError

shellCommand

public com.architech.function.executeCommand shellCommand(java.lang.String command)
Executes a shell command.
Parameters:
command - The shell command to execute
Returns:
An executeCommand object
See Also:
executeCommand

getOSName

public java.lang.String getOSName()
Returns the name of the operating system./
Returns:
The OS name

getJavaProperty

public java.lang.String getJavaProperty(java.lang.String prop)
Returns the value for a system property.
Parameters:
prop - The property name
Returns:
The property value or null if no such property exists

setJavaProperty

public void setJavaProperty(java.lang.String prop,
                            java.lang.String value)
Sets the value of a property name.
Parameters:
prop - The property name
value - The property value

entry2LDIF

public java.lang.String entry2LDIF(Entry e)
Converts an Entry object to an LDIF string.
Parameters:
e - The entry
Returns:
The LDIF string

getFTP

public com.architech.protocols.FTPBean getFTP()
Returns an instance of the FTP object.
Returns:
The FTP object
See Also:
FTPBean

dumpEntry

public void dumpEntry(Entry e)
Dumps an entry to the console log.
Parameters:
e - The entry

getXPathAPI

public org.apache.xpath.XPathAPI getXPathAPI()
Returns the Apache XPathAPI
Returns:
XPathAPI object

selectSingleNode

public com.architech.function.Node selectSingleNode(com.architech.function.Node contextNode,
                                                    java.lang.String str)
Selects a single node using an XPath expression from an XML node.
Parameters:
contextNode - The XML document node
str - The XPath search string
Returns:
XML Document node

selectNodeList

public com.architech.function.NodeList selectNodeList(com.architech.function.Node contextNode,
                                                      java.lang.String str)
Selects nodes using an XPath expression from an XML node.
Parameters:
contextNode - The XML document node
str - The XPath search string
Returns:
A NodeList object

selectNodeIterator

public com.architech.function.NodeIterator selectNodeIterator(com.architech.function.Node contextNode,
                                                              java.lang.String str)
Selects nodes using an XPath expression from an XML node.
Parameters:
contextNode - The XML document node
str - The XPath search string
Returns:
A NodeIterator object

dumpJavaClass

public boolean dumpJavaClass(java.lang.String className)
Dumps the public methods for a Java class.
Parameters:
className - The java class name
Returns:
True if dump succeeded
See Also:
lastError

chdir

public boolean chdir(java.lang.String directory)
Change Java runtime working directory (Sets the "user.dir" property which not always works!!).
Parameters:
directory - File system directory
Returns:
True if directory exists, false if directory is not valid

getcwd

public java.lang.String getcwd()
Returns the current working directory.
Returns:
Working directory

getScriptText

public java.lang.String getScriptText(java.lang.String name)
Returns the text from the Script Library.
Parameters:
name - The script name as it appears in the configuration.
Returns:
The script text or null if not found

snmpTrap

public boolean snmpTrap(java.lang.String host,
                        int port,
                        java.lang.String oid,
                        java.lang.String value)
Sends an SNMP trap.
Parameters:
host - The IP host
port - The TCP port
oid - The OID
value - The value
Returns:
True if Trap was sent
See Also:
lastError


*
  Metamerge Integrator version 4.5 ©Copyright Metamerge AS 2000-2002 Last edited 2002-04-30 contact us