String manipulations operations - script to Java migration
For the String operations, not all of the script operations from the Script API are implemented in the Java™ API. Alternative Java code is provided for those script operations that are not implemented in the Java API.
The following string manipulation Java methods
can be achieved by using native Java.
- buildCSV
- buildDelim
- buildFixedWidth
- checkString
- escapeForCSV
- escapeForHTML
- escapeForJS
- getNameFromPath
- getParentPath
- getRidOfRootName
| Script operation | Alternative Java code |
|---|---|
| checkDouble | Double.,parseDouble(); |
| checkInt | Integer.parseInt(sArg); |
| concat | StringBuffer.append() |
| contains | new Boolean(s.indexOf(sMatch)>= 0); |
| encodeUsingCharset | new
String(stringToEncode.getBytes (charset)) |
| endsWith | Boolean
(stringTobeMatched.endsWith (sMatch)); |
| escapeWithHTMLEntities | int ch = (int)stringtoEscape.charAt(i);
if (ch < beg || ch > end) StringBuffer sbResult.append("&#" + ch + ";"); else sbResult.append(s.charAt(i)); |
| indexOf | stringToMatch.indexOf(sMatch) |
| isLowerCase | Use Character.isLowerCase() |
| isUpperCase | Use Character.isUpperCase() |
| isStringSingleByte | int iUnicode = (int)c; return (iUnicode < 128) || (iUnicode > = 0xFF60 && iUnicode <= 0xFF9F); |