public class Utils extends Object
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
bufferToString(ByteBuffer[] bufs,
Charset cs)
Like bufferToString, but read multiple buffers.
|
static String |
bufferToString(ByteBuffer buf,
Charset cs)
Using a CharsetDecoder, translate the ByteBuffer into a stream, updating the buffer's position as we go.
|
static ByteBuffer |
catBuffers(ByteBuffer b1,
ByteBuffer b2)
Concatenate two byte buffers into one, updating their position.
|
static ByteBuffer |
doubleBuffer(ByteBuffer b)
Double the capacity of the specified buffer so that more data may be added.
|
static CharBuffer |
doubleBuffer(CharBuffer b)
Double the capacity of the specified buffer so that more data may be added.
|
static ByteBuffer |
duplicateBuffer(ByteBuffer b)
Make a duplicate of a ByteBuffer.
|
static Method |
findMethod(Class<?> klass,
String name)
Given a class, find the first method named "name".
|
static org.mozilla.javascript.RhinoException |
makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
int code) |
static org.mozilla.javascript.RhinoException |
makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
NodeOSException e)
Create an exception that may be thrown from Java code, causing an exception and an Error object
to be thrown in JavaScript.
|
static org.mozilla.javascript.RhinoException |
makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
OSException e)
Create an exception that may be thrown from Java code, causing an exception and an Error object
to be thrown in JavaScript.
|
static org.mozilla.javascript.RhinoException |
makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message)
Create an exception that may be thrown from Java code, causing an exception and an Error object
to be thrown in JavaScript.
|
static org.mozilla.javascript.RhinoException |
makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
int code) |
static org.mozilla.javascript.RhinoException |
makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
int code,
String path) |
static org.mozilla.javascript.RhinoException |
makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
org.mozilla.javascript.RhinoException re)
Create an exception that may be thrown from Java code, causing an exception and an Error object
to be thrown in JavaScript.
|
static org.mozilla.javascript.RhinoException |
makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
String code)
Create an exception that may be thrown from Java code, causing an exception and an Error object
to be thrown in JavaScript.
|
static org.mozilla.javascript.Scriptable |
makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
int code) |
static org.mozilla.javascript.Scriptable |
makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
NodeOSException e)
Create a JavaScript Error object, which may be passed to a function that is expecting one.
|
static org.mozilla.javascript.Scriptable |
makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
OSException e)
Create a JavaScript Error object, which may be passed to a function that is expecting one.
|
static org.mozilla.javascript.Scriptable |
makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message)
Create a JavaScript Error object, which may be passed to a function that is expecting one.
|
static org.mozilla.javascript.Scriptable |
makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
int code) |
static org.mozilla.javascript.Scriptable |
makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
int code,
String path) |
static org.mozilla.javascript.Scriptable |
makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
org.mozilla.javascript.RhinoException re)
Create a JavaScript Error object, which may be passed to a function that is expecting one.
|
static org.mozilla.javascript.Scriptable |
makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
String code)
Create a JavaScript Error object, which may be passed to a function that is expecting one.
|
static org.mozilla.javascript.Scriptable |
makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
String code,
String path)
Create a JavaScript Error object, which may be passed to a function that is expecting one.
|
static org.mozilla.javascript.RhinoException |
makeRangeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message)
Create a JavaScript RangeError object, which may be passed to a function that is expecting one.
|
static org.mozilla.javascript.RhinoException |
makeTypeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message)
Create a JavaScript TypeError object, which may be passed to a function that is expecting one.
|
static String |
readFile(File f)
Read an entire file into a single string, and interpret it as UTF-8.
|
static String |
readStream(InputStream in)
Read an entire input stream into a single string, and interpret it as UTF-8.
|
static ByteBuffer |
stringToBuffer(String str,
Charset cs)
Using a CharsetEncoder, translate a string to a ByteBuffer, allocating a new buffer
as necessary.
|
static List<String> |
toStringList(org.mozilla.javascript.Scriptable o)
Convert each value in the JavaScript object to a string array element.
|
static String |
unquote(String s)
Remove leading and trailing strings from a quoted string that has both leading and trailing quotes on it.
|
static void |
zeroBuffer(ByteBuffer b)
Fill a ByteBuffer with zeros, useful if it has been used to store a password or something.
|
public static String readStream(InputStream in) throws IOException
IOExceptionpublic static String readFile(File f) throws IOException
IOExceptionpublic static Method findMethod(Class<?> klass, String name)
public static String bufferToString(ByteBuffer buf, Charset cs)
public static String bufferToString(ByteBuffer[] bufs, Charset cs)
public static ByteBuffer stringToBuffer(String str, Charset cs)
public static org.mozilla.javascript.Scriptable makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message)
public static org.mozilla.javascript.Scriptable makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
org.mozilla.javascript.RhinoException re)
public static org.mozilla.javascript.RhinoException makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message)
public static org.mozilla.javascript.RhinoException makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
org.mozilla.javascript.RhinoException re)
public static org.mozilla.javascript.Scriptable makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
String code)
public static org.mozilla.javascript.Scriptable makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
String code,
String path)
code - this will be used to set the "code" property of the new object.
"errno" will also be set if the code is a known error code from the "ErrorCodes" class.path - this will be used to set the "path" property of the new objectpublic static org.mozilla.javascript.Scriptable makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
int code,
String path)
public static org.mozilla.javascript.RhinoException makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
int code,
String path)
public static org.mozilla.javascript.Scriptable makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
int code)
public static org.mozilla.javascript.RhinoException makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
int code)
public static org.mozilla.javascript.Scriptable makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
int code)
public static org.mozilla.javascript.RhinoException makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
int code)
public static org.mozilla.javascript.RhinoException makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message,
String code)
public static org.mozilla.javascript.RhinoException makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
NodeOSException e)
public static org.mozilla.javascript.RhinoException makeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
OSException e)
public static org.mozilla.javascript.Scriptable makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
NodeOSException e)
public static org.mozilla.javascript.Scriptable makeErrorObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
OSException e)
public static org.mozilla.javascript.RhinoException makeRangeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message)
public static org.mozilla.javascript.RhinoException makeTypeError(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
String message)
public static List<String> toStringList(org.mozilla.javascript.Scriptable o)
public static ByteBuffer catBuffers(ByteBuffer b1, ByteBuffer b2)
public static CharBuffer doubleBuffer(CharBuffer b)
public static ByteBuffer doubleBuffer(ByteBuffer b)
public static void zeroBuffer(ByteBuffer b)
public static ByteBuffer duplicateBuffer(ByteBuffer b)
Copyright © 2016 Apigee Corporation. All Rights Reserved.