diff options
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/slime/ObjectSymbolInserter.java')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/slime/ObjectSymbolInserter.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/slime/ObjectSymbolInserter.java b/vespajlib/src/main/java/com/yahoo/slime/ObjectSymbolInserter.java new file mode 100644 index 00000000000..9f50e1ae7df --- /dev/null +++ b/vespajlib/src/main/java/com/yahoo/slime/ObjectSymbolInserter.java @@ -0,0 +1,33 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.slime; + +/** + * Helper class for inserting values into an ObjectValue. + * For justification read Inserter documentation. + **/ +public final class ObjectSymbolInserter implements Inserter { + private Cursor target; + private int symbol; + + public ObjectSymbolInserter() {} + + public ObjectSymbolInserter(Cursor cursor, int sym) { + adjust(cursor, sym); + } + + public final ObjectSymbolInserter adjust(Cursor c, int sym) { + target = c; + symbol = sym; + return this; + } + + public final Cursor insertNIX() { return target.setNix(symbol); } + public final Cursor insertBOOL(boolean value) { return target.setBool(symbol, value); } + public final Cursor insertLONG(long value) { return target.setLong(symbol, value); } + public final Cursor insertDOUBLE(double value) { return target.setDouble(symbol, value); } + public final Cursor insertSTRING(String value) { return target.setString(symbol, value); } + public final Cursor insertSTRING(byte[] utf8) { return target.setString(symbol, utf8); } + public final Cursor insertDATA(byte[] value) { return target.setData(symbol, value); } + public final Cursor insertARRAY() { return target.setArray(symbol); } + public final Cursor insertOBJECT() { return target.setObject(symbol); } +} |