Вызовы 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); final MapValue arcType = new MapValue(ArcType.values().length);
for (ArcType value : ArcType.values()) { 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); Variables.define("ArcType", arcType);
final MapValue fillRule = new MapValue(FillRule.values().length); final MapValue fillRule = new MapValue(FillRule.values().length);
for (FillRule value : FillRule.values()) { 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); Variables.define("FillRule", fillRule);
final MapValue blendMode = new MapValue(BlendMode.values().length); final MapValue blendMode = new MapValue(BlendMode.values().length);
for (BlendMode value : BlendMode.values()) { 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); Variables.define("BlendMode", blendMode);
final MapValue lineCap = new MapValue(StrokeLineCap.values().length); final MapValue lineCap = new MapValue(StrokeLineCap.values().length);
for (StrokeLineCap value : StrokeLineCap.values()) { 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); Variables.define("StrokeLineCap", lineCap);
final MapValue lineJoin = new MapValue(StrokeLineJoin.values().length); final MapValue lineJoin = new MapValue(StrokeLineJoin.values().length);
for (StrokeLineJoin value : StrokeLineJoin.values()) { 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); Variables.define("StrokeLineJoin", lineJoin);
final MapValue textAlignment = new MapValue(TextAlignment.values().length); final MapValue textAlignment = new MapValue(TextAlignment.values().length);
for (TextAlignment value : TextAlignment.values()) { 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); Variables.define("TextAlignment", textAlignment);
final MapValue vPos = new MapValue(VPos.values().length); final MapValue vPos = new MapValue(VPos.values().length);
for (VPos value : VPos.values()) { 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); Variables.define("VPos", vPos);
final MapValue events = new MapValue(Events.values().length); final MapValue events = new MapValue(Events.values().length);
for (Events value : Events.values()) { 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); Variables.define("Events", events);
final MapValue mouseButton = new MapValue(MouseButton.values().length); final MapValue mouseButton = new MapValue(MouseButton.values().length);
for (MouseButton value : MouseButton.values()) { 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); Variables.define("MouseButton", mouseButton);
final MapValue keyCodes = new MapValue(KeyCode.values().length); final MapValue keyCodes = new MapValue(KeyCode.values().length);
for (KeyCode value : KeyCode.values()) { 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); Variables.define("KeyCode", keyCodes);
} }
@ -594,11 +594,11 @@ public final class canvasfx implements Module {
} }
private void init() { private void init() {
set(new StringValue("width"), NumberValue.of(image.getWidth())); set("width", NumberValue.of(image.getWidth()));
set(new StringValue("height"), NumberValue.of(image.getHeight())); set("height", NumberValue.of(image.getHeight()));
set(new StringValue("preserveRatio"), NumberValue.fromBoolean(image.isPreserveRatio())); set("preserveRatio", NumberValue.fromBoolean(image.isPreserveRatio()));
set(new StringValue("smooth"), NumberValue.fromBoolean(image.isSmooth())); set("smooth", NumberValue.fromBoolean(image.isSmooth()));
set(new StringValue("getPixels"), new FunctionValue(this::getPixels)); set("getPixels", new FunctionValue(this::getPixels));
} }
private Value getPixels(Value... args) { private Value getPixels(Value... args) {
@ -737,7 +737,7 @@ public final class canvasfx implements Module {
functions.put("translate", this::translate); functions.put("translate", this::translate);
for (Map.Entry<String, Function> entry : functions.entrySet()) { 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) { private static void handleMouseEvent(MouseEvent e, final Function handler) {
final MapValue map = new MapValue(25); final MapValue map = new MapValue(25);
map.set(new StringValue("button"), NumberValue.of(e.getButton().ordinal())); map.set("button", NumberValue.of(e.getButton().ordinal()));
map.set(new StringValue("clickCount"), NumberValue.of(e.getClickCount())); map.set("clickCount", NumberValue.of(e.getClickCount()));
map.set(new StringValue("sceneX"), NumberValue.of(e.getSceneX())); map.set("sceneX", NumberValue.of(e.getSceneX()));
map.set(new StringValue("sceneY"), NumberValue.of(e.getSceneY())); map.set("sceneY", NumberValue.of(e.getSceneY()));
map.set(new StringValue("screenX"), NumberValue.of(e.getScreenX())); map.set("screenX", NumberValue.of(e.getScreenX()));
map.set(new StringValue("screenY"), NumberValue.of(e.getScreenY())); map.set("screenY", NumberValue.of(e.getScreenY()));
map.set(new StringValue("x"), NumberValue.of(e.getX())); map.set("x", NumberValue.of(e.getX()));
map.set(new StringValue("y"), NumberValue.of(e.getY())); map.set("y", NumberValue.of(e.getY()));
map.set(new StringValue("z"), NumberValue.of(e.getZ())); map.set("z", NumberValue.of(e.getZ()));
map.set(new StringValue("isAltDown"), NumberValue.fromBoolean(e.isAltDown())); map.set("isAltDown", NumberValue.fromBoolean(e.isAltDown()));
map.set(new StringValue("isConsumed"), NumberValue.fromBoolean(e.isConsumed())); map.set("isConsumed", NumberValue.fromBoolean(e.isConsumed()));
map.set(new StringValue("isControlDown"), NumberValue.fromBoolean(e.isControlDown())); map.set("isControlDown", NumberValue.fromBoolean(e.isControlDown()));
map.set(new StringValue("isDragDetect"), NumberValue.fromBoolean(e.isDragDetect())); map.set("isDragDetect", NumberValue.fromBoolean(e.isDragDetect()));
map.set(new StringValue("isMetaDown"), NumberValue.fromBoolean(e.isMetaDown())); map.set("isMetaDown", NumberValue.fromBoolean(e.isMetaDown()));
map.set(new StringValue("isMiddleButtonDown"), NumberValue.fromBoolean(e.isMiddleButtonDown())); map.set("isMiddleButtonDown", NumberValue.fromBoolean(e.isMiddleButtonDown()));
map.set(new StringValue("isPopupTrigger"), NumberValue.fromBoolean(e.isPopupTrigger())); map.set("isPopupTrigger", NumberValue.fromBoolean(e.isPopupTrigger()));
map.set(new StringValue("isPrimaryButtonDown"), NumberValue.fromBoolean(e.isPrimaryButtonDown())); map.set("isPrimaryButtonDown", NumberValue.fromBoolean(e.isPrimaryButtonDown()));
map.set(new StringValue("isSecondaryButtonDown"), NumberValue.fromBoolean(e.isSecondaryButtonDown())); map.set("isSecondaryButtonDown", NumberValue.fromBoolean(e.isSecondaryButtonDown()));
map.set(new StringValue("isShiftDown"), NumberValue.fromBoolean(e.isShiftDown())); map.set("isShiftDown", NumberValue.fromBoolean(e.isShiftDown()));
map.set(new StringValue("isShortcutDown"), NumberValue.fromBoolean(e.isShortcutDown())); map.set("isShortcutDown", NumberValue.fromBoolean(e.isShortcutDown()));
map.set(new StringValue("isStillSincePress"), NumberValue.fromBoolean(e.isStillSincePress())); map.set("isStillSincePress", NumberValue.fromBoolean(e.isStillSincePress()));
map.set(new StringValue("isSynthesized"), NumberValue.fromBoolean(e.isSynthesized())); map.set("isSynthesized", NumberValue.fromBoolean(e.isSynthesized()));
handler.execute(map); handler.execute(map);
} }
private static void handleKeyEvent(final KeyEvent e, final Function handler) { private static void handleKeyEvent(final KeyEvent e, final Function handler) {
final MapValue map = new MapValue(10); final MapValue map = new MapValue(10);
map.set(new StringValue("code"), NumberValue.of(e.getCode().ordinal())); map.set("code", NumberValue.of(e.getCode().ordinal()));
map.set(new StringValue("character"), new StringValue(e.getCharacter())); map.set("character", new StringValue(e.getCharacter()));
map.set(new StringValue("text"), new StringValue(e.getText())); map.set("text", new StringValue(e.getText()));
map.set(new StringValue("isAltDown"), NumberValue.fromBoolean(e.isAltDown())); map.set("isAltDown", NumberValue.fromBoolean(e.isAltDown()));
map.set(new StringValue("isConsumed"), NumberValue.fromBoolean(e.isConsumed())); map.set("isConsumed", NumberValue.fromBoolean(e.isConsumed()));
map.set(new StringValue("isControlDown"), NumberValue.fromBoolean(e.isControlDown())); map.set("isControlDown", NumberValue.fromBoolean(e.isControlDown()));
map.set(new StringValue("isMetaDown"), NumberValue.fromBoolean(e.isMetaDown())); map.set("isMetaDown", NumberValue.fromBoolean(e.isMetaDown()));
map.set(new StringValue("isShiftDown"), NumberValue.fromBoolean(e.isShiftDown())); map.set("isShiftDown", NumberValue.fromBoolean(e.isShiftDown()));
map.set(new StringValue("isShortcutDown"), NumberValue.fromBoolean(e.isShortcutDown())); map.set("isShortcutDown", NumberValue.fromBoolean(e.isShortcutDown()));
handler.execute(map); handler.execute(map);
} }
private static void handleDragEvent(final DragEvent e, final Function handler) { private static void handleDragEvent(final DragEvent e, final Function handler) {
final MapValue map = new MapValue(10); final MapValue map = new MapValue(10);
map.set(new StringValue("sceneX"), NumberValue.of(e.getSceneX())); map.set("sceneX", NumberValue.of(e.getSceneX()));
map.set(new StringValue("sceneY"), NumberValue.of(e.getSceneY())); map.set("sceneY", NumberValue.of(e.getSceneY()));
map.set(new StringValue("screenX"), NumberValue.of(e.getScreenX())); map.set("screenX", NumberValue.of(e.getScreenX()));
map.set(new StringValue("screenY"), NumberValue.of(e.getScreenY())); map.set("screenY", NumberValue.of(e.getScreenY()));
map.set(new StringValue("x"), NumberValue.of(e.getX())); map.set("x", NumberValue.of(e.getX()));
map.set(new StringValue("y"), NumberValue.of(e.getY())); map.set("y", NumberValue.of(e.getY()));
map.set(new StringValue("z"), NumberValue.of(e.getZ())); map.set("z", NumberValue.of(e.getZ()));
map.set(new StringValue("isAccepted"), NumberValue.fromBoolean(e.isAccepted())); map.set("isAccepted", NumberValue.fromBoolean(e.isAccepted()));
map.set(new StringValue("isConsumed"), NumberValue.fromBoolean(e.isConsumed())); map.set("isConsumed", NumberValue.fromBoolean(e.isConsumed()));
map.set(new StringValue("isDropCompleted"), NumberValue.fromBoolean(e.isDropCompleted())); map.set("isDropCompleted", NumberValue.fromBoolean(e.isDropCompleted()));
handler.execute(map); 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 { private Value getResult(Response response, MapValue options) throws IOException {
if (options.containsKey(EXTENDED_RESULT)) { if (options.containsKey(EXTENDED_RESULT)) {
final MapValue map = new MapValue(10); final MapValue map = new MapValue(10);
map.set(new StringValue("text"), new StringValue(response.body().string())); map.set("text", new StringValue(response.body().string()));
map.set(new StringValue("message"), new StringValue(response.message())); map.set("message", new StringValue(response.message()));
map.set(new StringValue("code"), NumberValue.of(response.code())); map.set("code", NumberValue.of(response.code()));
final MapValue headers = new MapValue(response.headers().size()); final MapValue headers = new MapValue(response.headers().size());
for (Map.Entry<String, List<String>> entry : response.headers().toMultimap().entrySet()) { for (Map.Entry<String, List<String>> entry : response.headers().toMultimap().entrySet()) {
final int valuesSize = entry.getValue().size(); final int valuesSize = entry.getValue().size();
@ -114,10 +114,10 @@ public final class http_http implements Function {
for (int i = 0; i < valuesSize; i++) { for (int i = 0; i < valuesSize; i++) {
values.set(i, new StringValue(entry.getValue().get(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("headers", headers);
map.set(new StringValue("content_length"), NumberValue.of(response.body().contentLength())); map.set("content_length", NumberValue.of(response.body().contentLength()));
map.set(CONTENT_TYPE, new StringValue(response.body().contentType().toString())); map.set(CONTENT_TYPE, new StringValue(response.body().contentType().toString()));
return map; return map;
} }

View File

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

View File

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