1 ProcessBuilder
Class Ax.lang.ProcessBuilder
Run a shell command
new Ax.lang.ProcessBuilder().command("bash", "-c", "ls /home/mkyong/");
Constructor Summary
Method | Description |
---|---|
JSProcessBuilder() |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
int | command(String[] args) | |
JSFile | directory() | |
JSProcessBuilder | directory(JSFile file) | |
JSProcessBuilder | directory(String file) | |
String | getStdErr() | |
String | getStdOut() | |
JSProcessBuilder | setTimeout(int seconds) |
Method Detail
JSProcessBuilder
-
JSProcessBuilder()
command
-
int command(String[] args)
- Parameters:
- args -
- Returns:
directory
-
JSFile directory()
- Returns:
directory
-
JSProcessBuilder directory(JSFile file)
- Parameters:
- file -
- Returns:
directory
-
JSProcessBuilder directory(String file)
- Parameters:
- file -
- Returns:
getStdErr
-
String getStdErr()
- Returns:
getStdOut
-
String getStdOut()
- Returns:
setTimeout
-
JSProcessBuilder setTimeout(int seconds)
- Parameters:
- seconds -
- Returns:
2 Exception
Class Ax.lang.Exception
Constructor Summary
Method | Description |
---|---|
JSException(String code) | |
JSException(String code, String message) |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
void | addSuppressed(Throwable arg0) | |
Throwable | fillInStackTrace() | |
Throwable | getCause() | |
int | getColumnNumber() | |
String | getErrorCode() | |
String | getFileName() | |
int | getLineNumber() | |
String | getLocalizedMessage() | |
String | getLocalizedMessage() | |
String | getMessage() | |
String | getMessage() | |
String | getMessage() | |
StackTraceElement[] | getStackTrace() | |
Throwable[] | getSuppressed() | |
Throwable | initCause(Throwable arg0) | |
void | printStackTrace() | |
void | printStackTrace(PrintStream arg0) | |
void | printStackTrace(PrintWriter arg0) | |
void | setCause(Throwable arg0) | |
void | setStackTrace(StackTraceElement[] arg0) | |
String | toString() |
Method Detail
JSException
-
JSException(String code)
- Parameters:
- code -
addSuppressed
-
void addSuppressed(Throwable arg0)
- Parameters:
- arg0 -
fillInStackTrace
-
Throwable fillInStackTrace()
- Returns:
getCause
-
Throwable getCause()
- Returns:
getColumnNumber
-
int getColumnNumber()
- Returns:
getErrorCode
-
String getErrorCode()
- Returns:
getFileName
-
String getFileName()
- Returns:
getLineNumber
-
int getLineNumber()
- Returns:
getLocalizedMessage
-
String getLocalizedMessage()
- Returns:
getLocalizedMessage
-
String getLocalizedMessage()
- Returns:
getMessage
-
String getMessage()
- Returns:
getMessage
-
String getMessage()
- Returns:
getMessage
-
String getMessage()
- Returns:
getStackTrace
-
StackTraceElement[] getStackTrace()
- Returns:
getSuppressed
-
Throwable[] getSuppressed()
- Returns:
printStackTrace
-
void printStackTrace()
printStackTrace
-
void printStackTrace(PrintStream arg0)
- Parameters:
- arg0 -
printStackTrace
-
void printStackTrace(PrintWriter arg0)
- Parameters:
- arg0 -
setCause
-
void setCause(Throwable arg0)
- Parameters:
- arg0 -
setStackTrace
-
void setStackTrace(StackTraceElement[] arg0)
- Parameters:
- arg0 -
toString
-
String toString()
- Returns:
3 String
Class Ax.lang.String
A String wrapper that directly mimics String in many methods
and implements others like lpad, rpad .. etc
Constructor Summary
Method | Description |
---|---|
JSString(String object) | |
JSString(byte[] object) | |
JSString(byte[] object, String encoding) |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
char | charAt(int index) | |
IntStream | chars() | |
IntStream | codePoints() | |
int | compare(CharSequence arg0, CharSequence arg1) | |
JSString | encodeXML() | |
boolean | equals(Object obj) | |
JSString | format(Object[] args) | |
String | format(String s, Object[] args) | As it's static it can not decode the object[] of args using the engine! so we can not properly decode Nashorn/Graal native objects. |
byte[] | getBytes(String charsetName) | |
int | hashCode() | |
boolean | isBlank() | Returns true if the string is empty or contains only white space codepoints, otherwise false. |
boolean | isEmpty() | Returns true if, and only if, length() is 0. |
int | length() | |
JSString | lpad(char c, int length) | |
JSString | ltrim() | |
String | ltrim(String s) | |
JSString | mask(String mask) | Mask the string with the provided mask |
JSString | replace(CharSequence target, CharSequence replacement) | |
JSString | replaceAll(String regex, String replacement) | |
JSString | rpad(char c, int length) | |
JSString | rtrim() | |
String | rtrim(String s) | |
CharSequence | subSequence(int start, int end) | |
String | toString() | Mimics String |
JSString | trim() | |
JSString | wrap(int wrapLength) | |
JSString | wrap(int wrapLength, String newLineStr) |
Method Detail
JSString
-
JSString(String object)
- Parameters:
- object -
JSString
-
JSString(byte[] object)
- Parameters:
- object -
JSString
-
JSString(byte[] object, String encoding)
- Parameters:
- object -
- encoding -
charAt
-
char charAt(int index)
- Parameters:
- index -
- Returns:
chars
-
IntStream chars()
- Returns:
codePoints
-
IntStream codePoints()
- Returns:
compare
-
int compare(CharSequence arg0, CharSequence arg1)
- Parameters:
- arg0 -
- arg1 -
- Returns:
encodeXML
-
JSString encodeXML()
- Returns:
equals
-
boolean equals(Object obj)
- Parameters:
- obj -
- Returns:
format
getBytes
-
byte[] getBytes(String charsetName)
- Parameters:
- charsetName -
- Returns:
hashCode
-
int hashCode()
- Returns:
isBlank
-
boolean isBlank()
- Info:
-
Returns true if the string is empty or contains only white space codepoints, otherwise false. - Returns:
- true if the string is empty or contains only white space codepoints, otherwise false
isEmpty
-
boolean isEmpty()
- Info:
-
Returns true if, and only if, length() is 0. - Returns:
- true if length() is 0, otherwise false
length
-
int length()
- Returns:
lpad
-
JSString lpad(char c, int length)
- Parameters:
- c -
- length -
- Returns:
ltrim
-
JSString ltrim()
- Returns:
mask
replace
-
JSString replace(CharSequence target, CharSequence replacement)
- Parameters:
- target -
- replacement -
- Returns:
replaceAll
rpad
-
JSString rpad(char c, int length)
- Parameters:
- c -
- length -
- Returns:
rtrim
-
JSString rtrim()
- Returns:
subSequence
-
CharSequence subSequence(int start, int end)
- Parameters:
- start -
- end -
- Returns:
toString
-
String toString()
- Info:
-
Mimics String - Returns:
trim
-
JSString trim()
- Returns:
wrap
-
JSString wrap(int wrapLength)
- Parameters:
- wrapLength -
- Returns:
4 System
Class Ax.lang.System
Method Summary
Modifier and Type | Method | Description |
---|---|---|
static boolean | getBooleanProperty(String key, boolean _default) | |
static Map | getEnv() | |
static String | getEnv(String key) | |
static int | getIntProperty(String key, int _default) | |
static String | getProperty(String key) | |
static String | getProperty(String key, String _default) | |
static boolean | isBatch() | |
static void | sleep(long millis) |
Method Detail
getBooleanProperty
-
static boolean getBooleanProperty(String key, boolean _default)
- Parameters:
- key -
- _default -
- Returns:
getEnv
-
static Map getEnv()
- Returns:
getIntProperty
-
static int getIntProperty(String key, int _default)
- Parameters:
- key -
- _default -
- Returns:
getProperty
isBatch
-
static boolean isBatch()
- Returns:
sleep
-
static void sleep(long millis)
- Parameters:
- millis -
5 Types
Class Ax.lang.Types
Class is static, method don't need to be static.
as it extends AScriptJavaClass it provides data conversion methods
toJava
toJavaArray
toJavascript
Method Summary
Modifier and Type | Method | Description |
---|---|---|
static Object | toJavascript(Object src) | Allows javascript convert Java objects to more suitable native objects |
Method Detail
toJavascript
-
static Object toJavascript(Object src)
- Info:
-
Allows javascript convert Java objects to more suitable native objects - Parameters:
- src -
- Returns:
Example
Copy
let fileList = new Ax.io.File("/tmp").list(); let jsArray = Ax.lang.Types.toJavascript(fileList) // sort is a method in native js arrays jsArray.sort();