Вызовы set StringValue заменены на set String в MapValue

This commit is contained in:
Victor 2016-07-30 10:40:46 +03:00
parent faba36e1c5
commit 1c0686c03a
5 changed files with 230 additions and 230 deletions

View File

@ -105,61 +105,61 @@ public final class canvasfx implements Module {
final MapValue arcType = new MapValue(ArcType.values().length);
for (ArcType value : ArcType.values()) {
arcType.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
arcType.set(value.name(), NumberValue.of(value.ordinal()));
}
Variables.define("ArcType", arcType);
final MapValue fillRule = new MapValue(FillRule.values().length);
for (FillRule value : FillRule.values()) {
fillRule.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
fillRule.set(value.name(), NumberValue.of(value.ordinal()));
}
Variables.define("FillRule", fillRule);
final MapValue blendMode = new MapValue(BlendMode.values().length);
for (BlendMode value : BlendMode.values()) {
blendMode.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
blendMode.set(value.name(), NumberValue.of(value.ordinal()));
}
Variables.define("BlendMode", blendMode);
final MapValue lineCap = new MapValue(StrokeLineCap.values().length);
for (StrokeLineCap value : StrokeLineCap.values()) {
lineCap.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
lineCap.set(value.name(), NumberValue.of(value.ordinal()));
}
Variables.define("StrokeLineCap", lineCap);
final MapValue lineJoin = new MapValue(StrokeLineJoin.values().length);
for (StrokeLineJoin value : StrokeLineJoin.values()) {
lineJoin.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
lineJoin.set(value.name(), NumberValue.of(value.ordinal()));
}
Variables.define("StrokeLineJoin", lineJoin);
final MapValue textAlignment = new MapValue(TextAlignment.values().length);
for (TextAlignment value : TextAlignment.values()) {
textAlignment.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
textAlignment.set(value.name(), NumberValue.of(value.ordinal()));
}
Variables.define("TextAlignment", textAlignment);
final MapValue vPos = new MapValue(VPos.values().length);
for (VPos value : VPos.values()) {
vPos.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
vPos.set(value.name(), NumberValue.of(value.ordinal()));
}
Variables.define("VPos", vPos);
final MapValue events = new MapValue(Events.values().length);
for (Events value : Events.values()) {
events.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
events.set(value.name(), NumberValue.of(value.ordinal()));
}
Variables.define("Events", events);
final MapValue mouseButton = new MapValue(MouseButton.values().length);
for (MouseButton value : MouseButton.values()) {
mouseButton.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
mouseButton.set(value.name(), NumberValue.of(value.ordinal()));
}
Variables.define("MouseButton", mouseButton);
final MapValue keyCodes = new MapValue(KeyCode.values().length);
for (KeyCode value : KeyCode.values()) {
keyCodes.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
keyCodes.set(value.name(), NumberValue.of(value.ordinal()));
}
Variables.define("KeyCode", keyCodes);
}
@ -594,11 +594,11 @@ public final class canvasfx implements Module {
}
private void init() {
set(new StringValue("width"), NumberValue.of(image.getWidth()));
set(new StringValue("height"), NumberValue.of(image.getHeight()));
set(new StringValue("preserveRatio"), NumberValue.fromBoolean(image.isPreserveRatio()));
set(new StringValue("smooth"), NumberValue.fromBoolean(image.isSmooth()));
set(new StringValue("getPixels"), new FunctionValue(this::getPixels));
set("width", NumberValue.of(image.getWidth()));
set("height", NumberValue.of(image.getHeight()));
set("preserveRatio", NumberValue.fromBoolean(image.isPreserveRatio()));
set("smooth", NumberValue.fromBoolean(image.isSmooth()));
set("getPixels", new FunctionValue(this::getPixels));
}
private Value getPixels(Value... args) {
@ -737,7 +737,7 @@ public final class canvasfx implements Module {
functions.put("translate", this::translate);
for (Map.Entry<String, Function> entry : functions.entrySet()) {
set(new StringValue(entry.getKey()), new FunctionValue(entry.getValue()));
set(entry.getKey(), new FunctionValue(entry.getValue()));
}
}
@ -1226,57 +1226,57 @@ public final class canvasfx implements Module {
private static void handleMouseEvent(MouseEvent e, final Function handler) {
final MapValue map = new MapValue(25);
map.set(new StringValue("button"), NumberValue.of(e.getButton().ordinal()));
map.set(new StringValue("clickCount"), NumberValue.of(e.getClickCount()));
map.set(new StringValue("sceneX"), NumberValue.of(e.getSceneX()));
map.set(new StringValue("sceneY"), NumberValue.of(e.getSceneY()));
map.set(new StringValue("screenX"), NumberValue.of(e.getScreenX()));
map.set(new StringValue("screenY"), NumberValue.of(e.getScreenY()));
map.set(new StringValue("x"), NumberValue.of(e.getX()));
map.set(new StringValue("y"), NumberValue.of(e.getY()));
map.set(new StringValue("z"), NumberValue.of(e.getZ()));
map.set(new StringValue("isAltDown"), NumberValue.fromBoolean(e.isAltDown()));
map.set(new StringValue("isConsumed"), NumberValue.fromBoolean(e.isConsumed()));
map.set(new StringValue("isControlDown"), NumberValue.fromBoolean(e.isControlDown()));
map.set(new StringValue("isDragDetect"), NumberValue.fromBoolean(e.isDragDetect()));
map.set(new StringValue("isMetaDown"), NumberValue.fromBoolean(e.isMetaDown()));
map.set(new StringValue("isMiddleButtonDown"), NumberValue.fromBoolean(e.isMiddleButtonDown()));
map.set(new StringValue("isPopupTrigger"), NumberValue.fromBoolean(e.isPopupTrigger()));
map.set(new StringValue("isPrimaryButtonDown"), NumberValue.fromBoolean(e.isPrimaryButtonDown()));
map.set(new StringValue("isSecondaryButtonDown"), NumberValue.fromBoolean(e.isSecondaryButtonDown()));
map.set(new StringValue("isShiftDown"), NumberValue.fromBoolean(e.isShiftDown()));
map.set(new StringValue("isShortcutDown"), NumberValue.fromBoolean(e.isShortcutDown()));
map.set(new StringValue("isStillSincePress"), NumberValue.fromBoolean(e.isStillSincePress()));
map.set(new StringValue("isSynthesized"), NumberValue.fromBoolean(e.isSynthesized()));
map.set("button", NumberValue.of(e.getButton().ordinal()));
map.set("clickCount", NumberValue.of(e.getClickCount()));
map.set("sceneX", NumberValue.of(e.getSceneX()));
map.set("sceneY", NumberValue.of(e.getSceneY()));
map.set("screenX", NumberValue.of(e.getScreenX()));
map.set("screenY", NumberValue.of(e.getScreenY()));
map.set("x", NumberValue.of(e.getX()));
map.set("y", NumberValue.of(e.getY()));
map.set("z", NumberValue.of(e.getZ()));
map.set("isAltDown", NumberValue.fromBoolean(e.isAltDown()));
map.set("isConsumed", NumberValue.fromBoolean(e.isConsumed()));
map.set("isControlDown", NumberValue.fromBoolean(e.isControlDown()));
map.set("isDragDetect", NumberValue.fromBoolean(e.isDragDetect()));
map.set("isMetaDown", NumberValue.fromBoolean(e.isMetaDown()));
map.set("isMiddleButtonDown", NumberValue.fromBoolean(e.isMiddleButtonDown()));
map.set("isPopupTrigger", NumberValue.fromBoolean(e.isPopupTrigger()));
map.set("isPrimaryButtonDown", NumberValue.fromBoolean(e.isPrimaryButtonDown()));
map.set("isSecondaryButtonDown", NumberValue.fromBoolean(e.isSecondaryButtonDown()));
map.set("isShiftDown", NumberValue.fromBoolean(e.isShiftDown()));
map.set("isShortcutDown", NumberValue.fromBoolean(e.isShortcutDown()));
map.set("isStillSincePress", NumberValue.fromBoolean(e.isStillSincePress()));
map.set("isSynthesized", NumberValue.fromBoolean(e.isSynthesized()));
handler.execute(map);
}
private static void handleKeyEvent(final KeyEvent e, final Function handler) {
final MapValue map = new MapValue(10);
map.set(new StringValue("code"), NumberValue.of(e.getCode().ordinal()));
map.set(new StringValue("character"), new StringValue(e.getCharacter()));
map.set(new StringValue("text"), new StringValue(e.getText()));
map.set(new StringValue("isAltDown"), NumberValue.fromBoolean(e.isAltDown()));
map.set(new StringValue("isConsumed"), NumberValue.fromBoolean(e.isConsumed()));
map.set(new StringValue("isControlDown"), NumberValue.fromBoolean(e.isControlDown()));
map.set(new StringValue("isMetaDown"), NumberValue.fromBoolean(e.isMetaDown()));
map.set(new StringValue("isShiftDown"), NumberValue.fromBoolean(e.isShiftDown()));
map.set(new StringValue("isShortcutDown"), NumberValue.fromBoolean(e.isShortcutDown()));
map.set("code", NumberValue.of(e.getCode().ordinal()));
map.set("character", new StringValue(e.getCharacter()));
map.set("text", new StringValue(e.getText()));
map.set("isAltDown", NumberValue.fromBoolean(e.isAltDown()));
map.set("isConsumed", NumberValue.fromBoolean(e.isConsumed()));
map.set("isControlDown", NumberValue.fromBoolean(e.isControlDown()));
map.set("isMetaDown", NumberValue.fromBoolean(e.isMetaDown()));
map.set("isShiftDown", NumberValue.fromBoolean(e.isShiftDown()));
map.set("isShortcutDown", NumberValue.fromBoolean(e.isShortcutDown()));
handler.execute(map);
}
private static void handleDragEvent(final DragEvent e, final Function handler) {
final MapValue map = new MapValue(10);
map.set(new StringValue("sceneX"), NumberValue.of(e.getSceneX()));
map.set(new StringValue("sceneY"), NumberValue.of(e.getSceneY()));
map.set(new StringValue("screenX"), NumberValue.of(e.getScreenX()));
map.set(new StringValue("screenY"), NumberValue.of(e.getScreenY()));
map.set(new StringValue("x"), NumberValue.of(e.getX()));
map.set(new StringValue("y"), NumberValue.of(e.getY()));
map.set(new StringValue("z"), NumberValue.of(e.getZ()));
map.set(new StringValue("isAccepted"), NumberValue.fromBoolean(e.isAccepted()));
map.set(new StringValue("isConsumed"), NumberValue.fromBoolean(e.isConsumed()));
map.set(new StringValue("isDropCompleted"), NumberValue.fromBoolean(e.isDropCompleted()));
map.set("sceneX", NumberValue.of(e.getSceneX()));
map.set("sceneY", NumberValue.of(e.getSceneY()));
map.set("screenX", NumberValue.of(e.getScreenX()));
map.set("screenY", NumberValue.of(e.getScreenY()));
map.set("x", NumberValue.of(e.getX()));
map.set("y", NumberValue.of(e.getY()));
map.set("z", NumberValue.of(e.getZ()));
map.set("isAccepted", NumberValue.fromBoolean(e.isAccepted()));
map.set("isConsumed", NumberValue.fromBoolean(e.isConsumed()));
map.set("isDropCompleted", NumberValue.fromBoolean(e.isDropCompleted()));
handler.execute(map);
}

View File

@ -104,9 +104,9 @@ public final class http_http implements Function {
private Value getResult(Response response, MapValue options) throws IOException {
if (options.containsKey(EXTENDED_RESULT)) {
final MapValue map = new MapValue(10);
map.set(new StringValue("text"), new StringValue(response.body().string()));
map.set(new StringValue("message"), new StringValue(response.message()));
map.set(new StringValue("code"), NumberValue.of(response.code()));
map.set("text", new StringValue(response.body().string()));
map.set("message", new StringValue(response.message()));
map.set("code", NumberValue.of(response.code()));
final MapValue headers = new MapValue(response.headers().size());
for (Map.Entry<String, List<String>> entry : response.headers().toMultimap().entrySet()) {
final int valuesSize = entry.getValue().size();
@ -114,10 +114,10 @@ public final class http_http implements Function {
for (int i = 0; i < valuesSize; i++) {
values.set(i, new StringValue(entry.getValue().get(i)));
}
headers.set(new StringValue(entry.getKey()), values);
headers.set(entry.getKey(), values);
}
map.set(new StringValue("headers"), headers);
map.set(new StringValue("content_length"), NumberValue.of(response.body().contentLength()));
map.set("headers", headers);
map.set("content_length", NumberValue.of(response.body().contentLength()));
map.set(CONTENT_TYPE, new StringValue(response.body().contentType().toString()));
return map;
}

View File

@ -119,37 +119,37 @@ public final class java implements Module {
}
private void init(Class<?> clazz) {
set(new StringValue("isAnnotation"), NumberValue.fromBoolean(clazz.isAnnotation()));
set(new StringValue("isAnonymousClass"), NumberValue.fromBoolean(clazz.isAnonymousClass()));
set(new StringValue("isArray"), NumberValue.fromBoolean(clazz.isArray()));
set(new StringValue("isEnum"), NumberValue.fromBoolean(clazz.isEnum()));
set(new StringValue("isInterface"), NumberValue.fromBoolean(clazz.isInterface()));
set(new StringValue("isLocalClass"), NumberValue.fromBoolean(clazz.isLocalClass()));
set(new StringValue("isMemberClass"), NumberValue.fromBoolean(clazz.isMemberClass()));
set(new StringValue("isPrimitive"), NumberValue.fromBoolean(clazz.isPrimitive()));
set(new StringValue("isSynthetic"), NumberValue.fromBoolean(clazz.isSynthetic()));
set("isAnnotation", NumberValue.fromBoolean(clazz.isAnnotation()));
set("isAnonymousClass", NumberValue.fromBoolean(clazz.isAnonymousClass()));
set("isArray", NumberValue.fromBoolean(clazz.isArray()));
set("isEnum", NumberValue.fromBoolean(clazz.isEnum()));
set("isInterface", NumberValue.fromBoolean(clazz.isInterface()));
set("isLocalClass", NumberValue.fromBoolean(clazz.isLocalClass()));
set("isMemberClass", NumberValue.fromBoolean(clazz.isMemberClass()));
set("isPrimitive", NumberValue.fromBoolean(clazz.isPrimitive()));
set("isSynthetic", NumberValue.fromBoolean(clazz.isSynthetic()));
set(new StringValue("modifiers"), NumberValue.of(clazz.getModifiers()));
set("modifiers", NumberValue.of(clazz.getModifiers()));
set(new StringValue("canonicalName"), new StringValue(clazz.getCanonicalName()));
set(new StringValue("name"), new StringValue(clazz.getName()));
set(new StringValue("simpleName"), new StringValue(clazz.getSimpleName()));
set(new StringValue("typeName"), new StringValue(clazz.getTypeName()));
set(new StringValue("genericString"), new StringValue(clazz.toGenericString()));
set("canonicalName", new StringValue(clazz.getCanonicalName()));
set("name", new StringValue(clazz.getName()));
set("simpleName", new StringValue(clazz.getSimpleName()));
set("typeName", new StringValue(clazz.getTypeName()));
set("genericString", new StringValue(clazz.toGenericString()));
set(new StringValue("getComponentType"), new FunctionValue(v -> classOrNull(clazz.getComponentType()) ));
set(new StringValue("getDeclaringClass"), new FunctionValue(v -> classOrNull(clazz.getDeclaringClass()) ));
set(new StringValue("getEnclosingClass"), new FunctionValue(v -> classOrNull(clazz.getEnclosingClass()) ));
set(new StringValue("getSuperclass"), new FunctionValue(v -> new ClassValue(clazz.getSuperclass()) ));
set("getComponentType", new FunctionValue(v -> classOrNull(clazz.getComponentType()) ));
set("getDeclaringClass", new FunctionValue(v -> classOrNull(clazz.getDeclaringClass()) ));
set("getEnclosingClass", new FunctionValue(v -> classOrNull(clazz.getEnclosingClass()) ));
set("getSuperclass", new FunctionValue(v -> new ClassValue(clazz.getSuperclass()) ));
set(new StringValue("getClasses"), new FunctionValue(v -> array(clazz.getClasses()) ));
set(new StringValue("getDeclaredClasses"), new FunctionValue(v -> array(clazz.getDeclaredClasses()) ));
set(new StringValue("getInterfaces"), new FunctionValue(v -> array(clazz.getInterfaces()) ));
set("getClasses", new FunctionValue(v -> array(clazz.getClasses()) ));
set("getDeclaredClasses", new FunctionValue(v -> array(clazz.getDeclaredClasses()) ));
set("getInterfaces", new FunctionValue(v -> array(clazz.getInterfaces()) ));
set(new StringValue("asSubclass"), new FunctionValue(this::asSubclass));
set(new StringValue("isAssignableFrom"), new FunctionValue(this::isAssignableFrom));
set(new StringValue("new"), new FunctionValue(this::newInstance));
set(new StringValue("cast"), new FunctionValue(this::cast));
set("asSubclass", new FunctionValue(this::asSubclass));
set("isAssignableFrom", new FunctionValue(this::isAssignableFrom));
set("new", new FunctionValue(this::newInstance));
set("cast", new FunctionValue(this::cast));
}
private Value asSubclass(Value... args) {

View File

@ -128,29 +128,29 @@ public final class jdbc implements Module {
}
private void init() {
set(new StringValue("createStatement"), new FunctionValue(this::createStatement));
set(new StringValue("prepareStatement"), new FunctionValue(this::prepareStatement));
set(new StringValue("close"), new FunctionValue(this::close));
set("createStatement", new FunctionValue(this::createStatement));
set("prepareStatement", new FunctionValue(this::prepareStatement));
set("close", new FunctionValue(this::close));
set(new StringValue("clearWarnings"), voidFunction(connection::clearWarnings));
set(new StringValue("close"), voidFunction(connection::close));
set(new StringValue("commit"), voidFunction(connection::commit));
set(new StringValue("rollback"), voidFunction(connection::rollback));
set("clearWarnings", voidFunction(connection::clearWarnings));
set("close", voidFunction(connection::close));
set("commit", voidFunction(connection::commit));
set("rollback", voidFunction(connection::rollback));
set(new StringValue("setHoldability"), voidIntFunction(connection::setHoldability));
set(new StringValue("setTransactionIsolation"), voidIntFunction(connection::setTransactionIsolation));
set("setHoldability", voidIntFunction(connection::setHoldability));
set("setTransactionIsolation", voidIntFunction(connection::setTransactionIsolation));
set(new StringValue("getAutoCommit"), booleanFunction(connection::getAutoCommit));
set(new StringValue("isClosed"), booleanFunction(connection::isClosed));
set(new StringValue("isReadOnly"), booleanFunction(connection::isReadOnly));
set("getAutoCommit", booleanFunction(connection::getAutoCommit));
set("isClosed", booleanFunction(connection::isClosed));
set("isReadOnly", booleanFunction(connection::isReadOnly));
set(new StringValue("getHoldability"), intFunction(connection::getHoldability));
set(new StringValue("getNetworkTimeout"), intFunction(connection::getNetworkTimeout));
set(new StringValue("getTransactionIsolation"), intFunction(connection::getTransactionIsolation));
set(new StringValue("getUpdateCount"), intFunction(connection::getHoldability));
set("getHoldability", intFunction(connection::getHoldability));
set("getNetworkTimeout", intFunction(connection::getNetworkTimeout));
set("getTransactionIsolation", intFunction(connection::getTransactionIsolation));
set("getUpdateCount", intFunction(connection::getHoldability));
set(new StringValue("getCatalog"), stringFunction(connection::getCatalog));
set(new StringValue("getSchema"), stringFunction(connection::getSchema));
set("getCatalog", stringFunction(connection::getCatalog));
set("getSchema", stringFunction(connection::getSchema));
}
private Value createStatement(Value... args) {
@ -224,68 +224,68 @@ public final class jdbc implements Module {
}
private void init() {
set(new StringValue("addBatch"), new FunctionValue(this::addBatch));
set(new StringValue("execute"), new FunctionValue(this::execute));
set(new StringValue("executeQuery"), new FunctionValue(this::executeQuery));
set(new StringValue("executeUpdate"), new FunctionValue(this::executeUpdate));
set(new StringValue("executeLargeUpdate"), new FunctionValue(this::executeLargeUpdate));
set("addBatch", new FunctionValue(this::addBatch));
set("execute", new FunctionValue(this::execute));
set("executeQuery", new FunctionValue(this::executeQuery));
set("executeUpdate", new FunctionValue(this::executeUpdate));
set("executeLargeUpdate", new FunctionValue(this::executeLargeUpdate));
set(new StringValue("cancel"), voidFunction(statement::cancel));
set(new StringValue("clearBatch"), voidFunction(statement::clearBatch));
set(new StringValue("clearWarnings"), voidFunction(statement::clearWarnings));
set(new StringValue("close"), voidFunction(statement::close));
set(new StringValue("closeOnCompletion"), voidFunction(statement::closeOnCompletion));
set("cancel", voidFunction(statement::cancel));
set("clearBatch", voidFunction(statement::clearBatch));
set("clearWarnings", voidFunction(statement::clearWarnings));
set("close", voidFunction(statement::close));
set("closeOnCompletion", voidFunction(statement::closeOnCompletion));
set(new StringValue("setFetchDirection"), voidIntFunction(statement::setFetchDirection));
set(new StringValue("setFetchSize"), voidIntFunction(statement::setFetchSize));
set(new StringValue("setMaxFieldSize"), voidIntFunction(statement::setMaxFieldSize));
set(new StringValue("setMaxRows"), voidIntFunction(statement::setMaxRows));
set(new StringValue("setQueryTimeout"), voidIntFunction(statement::setQueryTimeout));
set("setFetchDirection", voidIntFunction(statement::setFetchDirection));
set("setFetchSize", voidIntFunction(statement::setFetchSize));
set("setMaxFieldSize", voidIntFunction(statement::setMaxFieldSize));
set("setMaxRows", voidIntFunction(statement::setMaxRows));
set("setQueryTimeout", voidIntFunction(statement::setQueryTimeout));
set(new StringValue("getMoreResults"), booleanFunction(statement::getMoreResults));
set(new StringValue("isCloseOnCompletion"), booleanFunction(statement::isCloseOnCompletion));
set(new StringValue("isClosed"), booleanFunction(statement::isClosed));
set(new StringValue("isPoolable"), booleanFunction(statement::isPoolable));
set("getMoreResults", booleanFunction(statement::getMoreResults));
set("isCloseOnCompletion", booleanFunction(statement::isCloseOnCompletion));
set("isClosed", booleanFunction(statement::isClosed));
set("isPoolable", booleanFunction(statement::isPoolable));
set(new StringValue("getFetchDirection"), intFunction(statement::getFetchDirection));
set(new StringValue("getFetchSize"), intFunction(statement::getFetchSize));
set(new StringValue("getMaxFieldSize"), intFunction(statement::getMaxFieldSize));
set(new StringValue("getMaxRows"), intFunction(statement::getMaxRows));
set(new StringValue("getQueryTimeout"), intFunction(statement::getQueryTimeout));
set(new StringValue("getResultSetConcurrency"), intFunction(statement::getResultSetConcurrency));
set(new StringValue("getResultSetHoldability"), intFunction(statement::getResultSetHoldability));
set(new StringValue("getResultSetType"), intFunction(statement::getResultSetType));
set(new StringValue("getUpdateCount"), intFunction(statement::getUpdateCount));
set("getFetchDirection", intFunction(statement::getFetchDirection));
set("getFetchSize", intFunction(statement::getFetchSize));
set("getMaxFieldSize", intFunction(statement::getMaxFieldSize));
set("getMaxRows", intFunction(statement::getMaxRows));
set("getQueryTimeout", intFunction(statement::getQueryTimeout));
set("getResultSetConcurrency", intFunction(statement::getResultSetConcurrency));
set("getResultSetHoldability", intFunction(statement::getResultSetHoldability));
set("getResultSetType", intFunction(statement::getResultSetType));
set("getUpdateCount", intFunction(statement::getUpdateCount));
set(new StringValue("setCursorName"), updateData(statement::setCursorName, (args) -> args[0].asString()));
set(new StringValue("setEscapeProcessing"), updateData(statement::setEscapeProcessing, (args) -> args[0].asInt() != 0));
set(new StringValue("setLargeMaxRows"), updateData(statement::setLargeMaxRows, (args) -> getNumber(args[0]).longValue()));
set(new StringValue("setPoolable"), updateData(statement::setPoolable, (args) -> args[0].asInt() != 0));
set("setCursorName", updateData(statement::setCursorName, (args) -> args[0].asString()));
set("setEscapeProcessing", updateData(statement::setEscapeProcessing, (args) -> args[0].asInt() != 0));
set("setLargeMaxRows", updateData(statement::setLargeMaxRows, (args) -> getNumber(args[0]).longValue()));
set("setPoolable", updateData(statement::setPoolable, (args) -> args[0].asInt() != 0));
set(new StringValue("getResultSet"), objectFunction(statement::getResultSet, ResultSetValue::new));
set(new StringValue("getGeneratedKeys"), objectFunction(statement::getGeneratedKeys, ResultSetValue::new));
set(new StringValue("executeBatch"), objectFunction(statement::executeBatch, jdbc::intArrayToValue));
set(new StringValue("executeLargeBatch"), objectFunction(statement::executeLargeBatch, jdbc::longArrayToValue));
set("getResultSet", objectFunction(statement::getResultSet, ResultSetValue::new));
set("getGeneratedKeys", objectFunction(statement::getGeneratedKeys, ResultSetValue::new));
set("executeBatch", objectFunction(statement::executeBatch, jdbc::intArrayToValue));
set("executeLargeBatch", objectFunction(statement::executeLargeBatch, jdbc::longArrayToValue));
if (ps != null) {
set(new StringValue("clearParameters"), voidFunction(ps::clearParameters));
set("clearParameters", voidFunction(ps::clearParameters));
set(new StringValue("setBigDecimal"), updateData(ps::setBigDecimal, (args) -> new BigDecimal(args[1].asString())));
set(new StringValue("setBoolean"), updateData(ps::setBoolean, (args) -> args[1].asInt() != 0));
set(new StringValue("setByte"), updateData(ps::setByte, (args) -> getNumber(args[1]).byteValue()));
set(new StringValue("setBytes"), updateData(ps::setBytes, (args) -> valueToByteArray(args[1])));
set(new StringValue("setDate"), updateData(ps::setDate, (args) -> new Date(getNumber(args[1]).longValue())));
set(new StringValue("setDouble"), updateData(ps::setDouble, (args) -> getNumber(args[1]).doubleValue()));
set(new StringValue("setFloat"), updateData(ps::setFloat, (args) -> getNumber(args[1]).floatValue()));
set(new StringValue("setInt"), updateData(ps::setInt, (args) -> args[1].asInt()));
set(new StringValue("setLong"), updateData(ps::setLong, (args) -> getNumber(args[1]).longValue()));
set(new StringValue("setNString"), updateData(ps::setNString, (args) -> args[1].asString()));
set(new StringValue("setNull"), updateData(ps::setNull, (args) -> args[1].asInt()));
set(new StringValue("setShort"), updateData(ps::setShort, (args) -> getNumber(args[1]).shortValue()));
set(new StringValue("setString"), updateData(ps::setString, (args) -> args[1].asString()));
set(new StringValue("setTime"), updateData(ps::setTime, (args) -> new Time(getNumber(args[1]).longValue())));
set(new StringValue("setTimestamp"), updateData(ps::setTimestamp, (args) -> new Timestamp(getNumber(args[1]).longValue())));
set(new StringValue("setURL"), updateData(ps::setURL, (args) -> {
set("setBigDecimal", updateData(ps::setBigDecimal, (args) -> new BigDecimal(args[1].asString())));
set("setBoolean", updateData(ps::setBoolean, (args) -> args[1].asInt() != 0));
set("setByte", updateData(ps::setByte, (args) -> getNumber(args[1]).byteValue()));
set("setBytes", updateData(ps::setBytes, (args) -> valueToByteArray(args[1])));
set("setDate", updateData(ps::setDate, (args) -> new Date(getNumber(args[1]).longValue())));
set("setDouble", updateData(ps::setDouble, (args) -> getNumber(args[1]).doubleValue()));
set("setFloat", updateData(ps::setFloat, (args) -> getNumber(args[1]).floatValue()));
set("setInt", updateData(ps::setInt, (args) -> args[1].asInt()));
set("setLong", updateData(ps::setLong, (args) -> getNumber(args[1]).longValue()));
set("setNString", updateData(ps::setNString, (args) -> args[1].asString()));
set("setNull", updateData(ps::setNull, (args) -> args[1].asInt()));
set("setShort", updateData(ps::setShort, (args) -> getNumber(args[1]).shortValue()));
set("setString", updateData(ps::setString, (args) -> args[1].asString()));
set("setTime", updateData(ps::setTime, (args) -> new Time(getNumber(args[1]).longValue())));
set("setTimestamp", updateData(ps::setTimestamp, (args) -> new Timestamp(getNumber(args[1]).longValue())));
set("setURL", updateData(ps::setURL, (args) -> {
try {
return new URL(args[1].asString());
} catch (IOException ioe) {
@ -384,84 +384,84 @@ public final class jdbc implements Module {
}
private void init() {
set(new StringValue("findColumn"), new FunctionValue(this::findColumn));
set("findColumn", new FunctionValue(this::findColumn));
set(new StringValue("afterLast"), voidFunction(rs::afterLast));
set(new StringValue("beforeFirst"), voidFunction(rs::beforeFirst));
set(new StringValue("cancelRowUpdates"), voidFunction(rs::cancelRowUpdates));
set(new StringValue("clearWarnings"), voidFunction(rs::clearWarnings));
set(new StringValue("close"), voidFunction(rs::close));
set(new StringValue("deleteRow"), voidFunction(rs::deleteRow));
set(new StringValue("insertRow"), voidFunction(rs::insertRow));
set(new StringValue("moveToCurrentRow"), voidFunction(rs::moveToCurrentRow));
set(new StringValue("moveToInsertRow"), voidFunction(rs::moveToInsertRow));
set(new StringValue("refreshRow"), voidFunction(rs::refreshRow));
set(new StringValue("updateRow"), voidFunction(rs::updateRow));
set("afterLast", voidFunction(rs::afterLast));
set("beforeFirst", voidFunction(rs::beforeFirst));
set("cancelRowUpdates", voidFunction(rs::cancelRowUpdates));
set("clearWarnings", voidFunction(rs::clearWarnings));
set("close", voidFunction(rs::close));
set("deleteRow", voidFunction(rs::deleteRow));
set("insertRow", voidFunction(rs::insertRow));
set("moveToCurrentRow", voidFunction(rs::moveToCurrentRow));
set("moveToInsertRow", voidFunction(rs::moveToInsertRow));
set("refreshRow", voidFunction(rs::refreshRow));
set("updateRow", voidFunction(rs::updateRow));
set(new StringValue("absolute"), voidIntFunction(rs::absolute));
set(new StringValue("relative"), voidIntFunction(rs::relative));
set(new StringValue("setFetchDirection"), voidIntFunction(rs::setFetchDirection));
set(new StringValue("setFetchSize"), voidIntFunction(rs::setFetchSize));
set("absolute", voidIntFunction(rs::absolute));
set("relative", voidIntFunction(rs::relative));
set("setFetchDirection", voidIntFunction(rs::setFetchDirection));
set("setFetchSize", voidIntFunction(rs::setFetchSize));
set(new StringValue("first"), booleanFunction(rs::first));
set(new StringValue("isAfterLast"), booleanFunction(rs::isAfterLast));
set(new StringValue("isBeforeFirst"), booleanFunction(rs::isBeforeFirst));
set(new StringValue("isClosed"), booleanFunction(rs::isClosed));
set(new StringValue("isFirst"), booleanFunction(rs::isFirst));
set(new StringValue("isLast"), booleanFunction(rs::isLast));
set(new StringValue("last"), booleanFunction(rs::last));
set(new StringValue("next"), booleanFunction(rs::next));
set(new StringValue("previous"), booleanFunction(rs::previous));
set(new StringValue("rowDeleted"), booleanFunction(rs::rowDeleted));
set(new StringValue("rowInserted"), booleanFunction(rs::rowInserted));
set(new StringValue("rowUpdated"), booleanFunction(rs::rowUpdated));
set(new StringValue("wasNull"), booleanFunction(rs::wasNull));
set("first", booleanFunction(rs::first));
set("isAfterLast", booleanFunction(rs::isAfterLast));
set("isBeforeFirst", booleanFunction(rs::isBeforeFirst));
set("isClosed", booleanFunction(rs::isClosed));
set("isFirst", booleanFunction(rs::isFirst));
set("isLast", booleanFunction(rs::isLast));
set("last", booleanFunction(rs::last));
set("next", booleanFunction(rs::next));
set("previous", booleanFunction(rs::previous));
set("rowDeleted", booleanFunction(rs::rowDeleted));
set("rowInserted", booleanFunction(rs::rowInserted));
set("rowUpdated", booleanFunction(rs::rowUpdated));
set("wasNull", booleanFunction(rs::wasNull));
set(new StringValue("getConcurrency"), intFunction(rs::getConcurrency));
set(new StringValue("getFetchDirection"), intFunction(rs::getFetchDirection));
set(new StringValue("getFetchSize"), intFunction(rs::getFetchSize));
set(new StringValue("getHoldability"), intFunction(rs::getHoldability));
set(new StringValue("getRow"), intFunction(rs::getRow));
set(new StringValue("getType"), intFunction(rs::getType));
set("getConcurrency", intFunction(rs::getConcurrency));
set("getFetchDirection", intFunction(rs::getFetchDirection));
set("getFetchSize", intFunction(rs::getFetchSize));
set("getHoldability", intFunction(rs::getHoldability));
set("getRow", intFunction(rs::getRow));
set("getType", intFunction(rs::getType));
set(new StringValue("getCursorName"), stringFunction(rs::getCursorName));
set(new StringValue("getStatement"), objectFunction(rs::getStatement, StatementValue::new));
set("getCursorName", stringFunction(rs::getCursorName));
set("getStatement", objectFunction(rs::getStatement, StatementValue::new));
// Results
set(new StringValue("getArray"), getObjectResult(rs::getArray, rs::getArray, jdbc::arrayToResultSetValue));
set(new StringValue("getBigDecimal"), getObjectResult(rs::getBigDecimal, rs::getBigDecimal, (bd) -> new StringValue(bd.toString())));
set(new StringValue("getBoolean"), getBooleanResult(rs::getBoolean, rs::getBoolean));
set(new StringValue("getByte"), getNumberResult(rs::getByte, rs::getByte));
set(new StringValue("getBytes"), getObjectResult(rs::getBytes, rs::getBytes, (bytes) -> ArrayValue.of(bytes)));
set(new StringValue("getDate"), getObjectResult(rs::getDate, rs::getDate, (date) -> NumberValue.of(date.getTime())));
set(new StringValue("getDouble"), getNumberResult(rs::getDouble, rs::getDouble));
set(new StringValue("getFloat"), getNumberResult(rs::getFloat, rs::getFloat));
set(new StringValue("getInt"), getNumberResult(rs::getInt, rs::getInt));
set(new StringValue("getLong"), getNumberResult(rs::getLong, rs::getLong));
set(new StringValue("getNString"), getStringResult(rs::getNString, rs::getNString));
set(new StringValue("getRowId"), getObjectResult(rs::getRowId, rs::getRowId, (rowid) -> ArrayValue.of(rowid.getBytes())));
set(new StringValue("getShort"), getNumberResult(rs::getShort, rs::getShort));
set(new StringValue("getString"), getStringResult(rs::getString, rs::getString));
set(new StringValue("getTime"), getObjectResult(rs::getTime, rs::getTime, (time) -> NumberValue.of(time.getTime())));
set(new StringValue("getTimestamp"), getObjectResult(rs::getTimestamp, rs::getTimestamp, (timestamp) -> NumberValue.of(timestamp.getTime())));
set(new StringValue("getURL"), getObjectResult(rs::getURL, rs::getURL, (url) -> new StringValue(url.toExternalForm())));
set("getArray", getObjectResult(rs::getArray, rs::getArray, jdbc::arrayToResultSetValue));
set("getBigDecimal", getObjectResult(rs::getBigDecimal, rs::getBigDecimal, (bd) -> new StringValue(bd.toString())));
set("getBoolean", getBooleanResult(rs::getBoolean, rs::getBoolean));
set("getByte", getNumberResult(rs::getByte, rs::getByte));
set("getBytes", getObjectResult(rs::getBytes, rs::getBytes, (bytes) -> ArrayValue.of(bytes)));
set("getDate", getObjectResult(rs::getDate, rs::getDate, (date) -> NumberValue.of(date.getTime())));
set("getDouble", getNumberResult(rs::getDouble, rs::getDouble));
set("getFloat", getNumberResult(rs::getFloat, rs::getFloat));
set("getInt", getNumberResult(rs::getInt, rs::getInt));
set("getLong", getNumberResult(rs::getLong, rs::getLong));
set("getNString", getStringResult(rs::getNString, rs::getNString));
set("getRowId", getObjectResult(rs::getRowId, rs::getRowId, (rowid) -> ArrayValue.of(rowid.getBytes())));
set("getShort", getNumberResult(rs::getShort, rs::getShort));
set("getString", getStringResult(rs::getString, rs::getString));
set("getTime", getObjectResult(rs::getTime, rs::getTime, (time) -> NumberValue.of(time.getTime())));
set("getTimestamp", getObjectResult(rs::getTimestamp, rs::getTimestamp, (timestamp) -> NumberValue.of(timestamp.getTime())));
set("getURL", getObjectResult(rs::getURL, rs::getURL, (url) -> new StringValue(url.toExternalForm())));
// Update
set(new StringValue("updateNull"), new FunctionValue(this::updateNull));
set(new StringValue("updateBigDecimal"), updateData(rs::updateBigDecimal, rs::updateBigDecimal, (args) -> new BigDecimal(args[1].asString())));
set(new StringValue("updateBoolean"), updateData(rs::updateBoolean, rs::updateBoolean, (args) -> args[1].asInt() != 0));
set(new StringValue("updateByte"), updateData(rs::updateByte, rs::updateByte, (args) -> getNumber(args[1]).byteValue()));
set(new StringValue("updateBytes"), updateData(rs::updateBytes, rs::updateBytes, (args) -> valueToByteArray(args[1])));
set(new StringValue("updateDate"), updateData(rs::updateDate, rs::updateDate, (args) -> new Date(getNumber(args[1]).longValue())));
set(new StringValue("updateDouble"), updateData(rs::updateDouble, rs::updateDouble, (args) -> getNumber(args[1]).doubleValue()));
set(new StringValue("updateFloat"), updateData(rs::updateFloat, rs::updateFloat, (args) -> getNumber(args[1]).floatValue()));
set(new StringValue("updateInt"), updateData(rs::updateInt, rs::updateInt, (args) -> getNumber(args[1]).intValue()));
set(new StringValue("updateLong"), updateData(rs::updateLong, rs::updateLong, (args) -> getNumber(args[1]).longValue()));
set(new StringValue("updateNString"), updateData(rs::updateNString, rs::updateNString, (args) -> args[1].asString()));
set(new StringValue("updateShort"), updateData(rs::updateShort, rs::updateShort, (args) -> getNumber(args[1]).shortValue()));
set(new StringValue("updateString"), updateData(rs::updateString, rs::updateString, (args) -> args[1].asString()));
set(new StringValue("updateTime"), updateData(rs::updateTime, rs::updateTime, (args) -> new Time(getNumber(args[1]).longValue())));
set(new StringValue("updateTimestamp"), updateData(rs::updateTimestamp, rs::updateTimestamp, (args) -> new Timestamp(getNumber(args[1]).longValue())));
set("updateNull", new FunctionValue(this::updateNull));
set("updateBigDecimal", updateData(rs::updateBigDecimal, rs::updateBigDecimal, (args) -> new BigDecimal(args[1].asString())));
set("updateBoolean", updateData(rs::updateBoolean, rs::updateBoolean, (args) -> args[1].asInt() != 0));
set("updateByte", updateData(rs::updateByte, rs::updateByte, (args) -> getNumber(args[1]).byteValue()));
set("updateBytes", updateData(rs::updateBytes, rs::updateBytes, (args) -> valueToByteArray(args[1])));
set("updateDate", updateData(rs::updateDate, rs::updateDate, (args) -> new Date(getNumber(args[1]).longValue())));
set("updateDouble", updateData(rs::updateDouble, rs::updateDouble, (args) -> getNumber(args[1]).doubleValue()));
set("updateFloat", updateData(rs::updateFloat, rs::updateFloat, (args) -> getNumber(args[1]).floatValue()));
set("updateInt", updateData(rs::updateInt, rs::updateInt, (args) -> getNumber(args[1]).intValue()));
set("updateLong", updateData(rs::updateLong, rs::updateLong, (args) -> getNumber(args[1]).longValue()));
set("updateNString", updateData(rs::updateNString, rs::updateNString, (args) -> args[1].asString()));
set("updateShort", updateData(rs::updateShort, rs::updateShort, (args) -> getNumber(args[1]).shortValue()));
set("updateString", updateData(rs::updateString, rs::updateString, (args) -> args[1].asString()));
set("updateTime", updateData(rs::updateTime, rs::updateTime, (args) -> new Time(getNumber(args[1]).longValue())));
set("updateTimestamp", updateData(rs::updateTimestamp, rs::updateTimestamp, (args) -> new Timestamp(getNumber(args[1]).longValue())));
}
private Value findColumn(Value... args) {

View File

@ -13,12 +13,12 @@ import com.annimon.ownlang.lib.modules.functions.*;
public final class std implements Module {
public static void initConstants() {
Variables.define("ARGS", ArrayValue.of(Main.getOwnlangArgs()));
}
@Override
public void init() {
initConstants();
Variables.define("ARGS", ArrayValue.of(Main.getOwnlangArgs())); // is not constant
Functions.set("echo", new std_echo());
Functions.set("readln", new std_readln());
Functions.set("length", new std_length());