|
|
The System ObjectThe system object is available as a scriptable object in all scripting contexts and provides a basic set of functions. The Java object itself is called java object com.architech.function.userFunctions2, but linked to the Script object System (see Accessing Your Own Java Classes) Methodsremove ( s1, s2 ) Remove occurrences of string s1 from string s2.
trim ( str ) Removes white space from str toInt ( str ) Returns a java.lang.Integer object from the string str. isValidInt ( str ) Returns true if str can be converted to an integer openFileForAppend ( file ) Opens a file in append mode and returns a BufferedWriter object. Use the returned object to write data to the file. var out = openFileForAppend("out.txt"); out.write ("Hello world!"); out.newLine (); out.close (); openFileForOutput ( file ) Opens a file for output and returns a BufferedWriter object. Use the returned object to write data to the file. var out = openFileForOutput("out.txt"); out.write ("Hello world!"); out.newLine (); out.close (); openFileForInput ( file ) Opens a file for input and returns a BufferedReader object for the file. Refer to the Java documenation for a complete description of this object. var inp = openFileForInput ("inp.txt"); var str = inp.readLine(); if ( str == null ) task.logmsg ("End of file"); inp.close (); sendMail (from, recipients, subject, message, attachment) Sends an email to the comma separated list of recipients in recip using from as the sender address. subject and message is inserted as the subject and main text body. attachment specifies a filename that will be attached to the message. var error = system.sendMail ( "sender@somewhere.com", "r2@dot.com, d2@solar.net", "This is the subject", "Here is the text.\nLine 2", "c:\\attachment.doc" ); if ( error == null ) { task.logmsg ("Message sent"); } else { task.logmsg ("Error: " + error); } Make sure you have set the mail.smtp.host Java property before using this function. copyFile (fromPath, toPath, overwrite) Copies one file to another. If overwrite is false then copy will not overwrite destination file. newAttribute (name) Creates a new Attribute newEntry () Creates a new instance of the Entry object newObject (className) Create a new instance of the Java class className. var f = system.newObject ("java.io.File"); This function is mostly for scripting engines that cannot access the java runtime. If you are using Javascript you can create the object like this: var f = new java.io.File (); skipEntry Tells the AssemblyLine to skip the current entry and continue with the next entry from the iterator. ignoreEntry Tells the AssemblyLine to ignore the Connector from which this function is called and continue with the next Connector in the AssemblyLine. Attribute mapping for this Connector is also ignored. restartEntry Tells the AssemblyLine to start over from the first Connector after the current Iterator without touching the work entry.abortAssemblyLine ( reason ) Tells the AssemblyLine to abort with the message reason. loadConnector ( name ) / getConnector ( name ) Loads an instance of the Connector name, where name refers to a Connector template or a Connector in the Connector library. In order to use the Connector you must also call the initialize function. Refer to the Connector object for more details. var ldap = system.loadConnector ("myldap"); var entry = ldap.findEntry ("cn", "John Doe"); if ( entry != null ) { task.logmsg ("John's email: " + entry.getString("mail")); } sleep ( seconds ) Pause current thread for seconds seconds. removeStringChars ( source, set ) Returns a string where all occurrences of characters in set are removed the string source var str = removeStringChars("Testing", "et"); // --> Tsing mapString ( source, set1, set2) Returns a string where all occurrences of characters in set1 have been mapped to the corresponding character in set2. var str = mapString ("Testing", "et", "ET"); // --> TEsTing translateString ( str, fromCharset, toCharset) Translates a string from one character set to another. If either character set is specified as null then Unicode is assumed. var str = "Unicode String"; var cp12 = system.translateString ( str, null, "Cp1252" ); toHex ( str ) Returns a string where each character in str has been converted to a hexadecimal value. var str = system.toHex ("1998"); // --> 31393938 parseDate ( date, format ) Parses the string date according to the format given by format. Returns a java.util.Date object on success. // July 1st 2000 dt = system.parseDate ("2000.01.07", "yyyy.MM.dd"); if (dt == null) { task.logmsg ("Cannot parse date"); }Format Pattern Result -------------- ------- "yyyy.MM.dd G 'at' hh:mm:ss z" ->> 1996.07.10 AD at 15:08:56 PDT "EEE, MMM d, ''yy" ->> Wed, July 10, '96 "h:mm a" ->> 12:08 PM "hh 'o''clock' a, zzzz" ->> 12 o'clock PM, Pacific Daylight Time "K:mm a, z" ->> 0:00 PM, PST "yyyyy.MMMMM.dd GGG hh:mm aaa" ->> 1996.July.10 AD 12:08 PM splitString ( str, split ) Splits a string str into an array of strings. var str = system.splitString ("my name", " "); // --> ["my", "name"] getParser ( name ) Loads an instance of the Parser name, where name refers to a Parser template or a Parser in the Parser library. var ldif = system.getParser ("metamerge.LDIF"); var f = new java.io.FileInputStream ("mydata.ldif"); ldif.setInputStream ( f ); var entry = f.readEntry(); task.dumpEntry ( entry ); parseObject ( parser, object ) Loads an instance of the Parser parser and initializes the Parser with object. The object may be a string, java.io.InputStream or a java.io.Reader object. var f = new java.io.FileInputStream ("mydata.ldif"); var entry = system.parseObject ( "metamerge.LDIF", f ); shellCommand ( commandLine ) Executes commandLine in a shell. The returned object contains input, output and error stream results as well as exit codes. Refer to the shellCommand object for a complete description. var f = system.shellCommand ("/bin/ls -l /etc/passwd"); task.logmsg ( f.getOutputBuffer() ); getOSName() Returns the operating system name on which Metamerge is running. if ( system.getOSName().indexOf ("Windows") ) { task.logmsg ( "Running on the Windows platform" ); } getJavaProperty ( prop ) Returns the Java runtime property named prop setJavaProperty ( prop, value ) Sets the Java runtime property named prop to value. system.setJavaProperty ( "mail.smtp.host", "mailserver.dot.com" ); getFTP () Returns an FTP object. selectSingleNode ( node, xpath ) Calls the XPathAPI to find a single node matching the XPath query. The function returns a Node object. selectNodeList ( node, xpath ) Calls the XPathAPI to find a list of nodes matching the XPath query. The function returns a NodeList object. selectNodeIterator ( node, xpath ) Calls the XPathAPI to find a list of nodes matching the XPath query. The function returns a NodeIterator object. |
|
|