Skip to content

Commit 7a94130

Browse files
committed
Remove ValueRef interface
1 parent d655c03 commit 7a94130

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+445
-395
lines changed

msgpack-core/src/main/java/org/msgpack/core/example/MessagePackExample.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ public static void readAndWriteFile() throws IOException {
181181
switch(format.getValueType()) {
182182
case NIL:
183183
Value nil = v.get();
184-
nil.isNil(); // true
184+
nil.isNilValue(); // true
185185
System.out.println("read nil");
186186
break;
187187
case BOOLEAN:
188-
boolean b = v.get().asBoolean().toBoolean();
188+
boolean b = v.get().asBooleanValue().toBoolean();
189189
System.out.println("read boolean: " + b);
190190
break;
191191
case INTEGER:
@@ -206,22 +206,22 @@ public static void readAndWriteFile() throws IOException {
206206
System.out.println("read float: " + d);
207207
break;
208208
case STRING:
209-
String s = v.get().asString().toString();
209+
String s = v.get().asStringValue().toString();
210210
System.out.println("read string: " + s);
211211
break;
212212
case BINARY:
213213
// Message buffer is an efficient byte buffer
214-
MessageBuffer mb = v.get().asBinary().toMessageBuffer();
214+
MessageBuffer mb = v.get().asBinaryValue().toMessageBuffer();
215215
System.out.println("read binary: " + mb.toHexString(0, mb.size()));
216216
break;
217217
case ARRAY:
218218
ArrayValue arr = v.get().asArrayValue();
219-
for(ValueRef a : arr) {
219+
for(Value a : arr) {
220220
System.out.println("read array element: " + a);
221221
}
222222
break;
223223
case EXTENDED:
224-
ExtendedValue ev = v.get().asExtended();
224+
ExtendedValue ev = v.get().asExtendedValue();
225225
int extType = ev.getExtType();
226226
byte[] extValue = ev.toByteArray();
227227
break;

msgpack-core/src/main/java/org/msgpack/value/ArrayCursor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
/**
66
* Created on 6/16/14.
77
*/
8-
public interface ArrayCursor extends ValueRef, Iterable<ValueRef> {
8+
public interface ArrayCursor extends Value, Iterable<Value> {
99
public int size();
1010

1111
public boolean hasNext();
12-
public ValueRef next();
12+
public Value next();
1313
public void skip();
1414

1515
/**
1616
* Skips all of the remaining values
1717
*/
1818
public void skipAll();
1919

20-
public Iterator<ValueRef> iterator();
20+
public Iterator<Value> iterator();
2121

22-
public ArrayValue toValue();
22+
public ArrayValue toImmutable();
2323

2424
}

msgpack-core/src/main/java/org/msgpack/value/ArrayValue.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
* Implementation note: We do not implement List<Value> interface here, because
1010
* we cannot reuse AbstractList and AbstractValue implementations simultaneously since
1111
* Java does not support mixin of classes. Instead, it provides {@link #iterator} or
12-
* {@link #toValueArray()} methods to traverse the array contents.
12+
* {@link #toArray()} methods to traverse the array contents.
1313
*/
1414
public interface ArrayValue extends Value, ArrayCursor {
1515

16-
public Value[] toValueArray();
16+
public Value[] toArray();
1717

1818
public Value get(int index);
1919
public Value apply(int index);
2020

21-
public ArrayValue toValue();
21+
public ArrayValue toImmutable();
2222

2323
}

msgpack-core/src/main/java/org/msgpack/value/Cursor.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import java.util.Iterator;
66

77
/**
8-
* Cursor for traversing a stream of message-packed values
8+
* Cursor for traversing a stream of message-packed values.
9+
* Returned value might be changed for efficiency. To retrieving an immutable value,
10+
* call {@link org.msgpack.value.Value#toImmutable()} after retrieving a value.
911
*/
1012
public interface Cursor extends Iterator<Value>, Closeable {
1113

@@ -16,14 +18,7 @@ public interface Cursor extends Iterator<Value>, Closeable {
1618
public boolean hasNext();
1719

1820
/**
19-
* Returns a reference to the value, then proceeds the cursor.
20-
* The returned reference is valid until {@link #hasNext()} is called.
21-
* @return
22-
*/
23-
public ValueRef nextRef();
24-
25-
/**
26-
* Returns the materialized value of the referenced value, then proceeds the cursor.
21+
* Returns the next value, then proceeds the cursor.
2722
* @return
2823
*/
2924
public Value next();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package org.msgpack.value;
22

33
/**
4-
* Created on 5/30/14.
4+
* ExtendedValue interface
55
*/
66
public interface ExtendedValue extends RawValue {
77
public int getExtType();
8-
public ExtendedValue toValue();
8+
public ExtendedValue toImmutable();
99
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.msgpack.value;
22

33
/**
4-
* Created on 5/30/14.
4+
* FloatValue interface
55
*/
66
public interface FloatValue extends NumberValue {
7-
FloatValue toValue();
7+
FloatValue toImmutable();
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.msgpack.value;
22

33
/**
4-
* Created on 5/30/14.
4+
* IntegerValue interface
55
*/
66
public interface IntegerValue extends NumberValue {
7-
IntegerValue toValue();
7+
IntegerValue toImmutable();
88
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.msgpack.value;
2+
3+
/**
4+
*
5+
*/
6+
public class KeyValuePair {
7+
public final Value key;
8+
public final Value value;
9+
10+
public KeyValuePair(Value key, Value value) {
11+
this.key = key;
12+
this.value = value;
13+
}
14+
}
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package org.msgpack.value;
22

3-
import java.util.Iterator;
4-
import java.util.Map;
53

64
/**
75
* Cursor for traversing map value entries. This cursor reports a sequence of key and value pairs.
86
*/
9-
public interface MapCursor extends ValueRef {
7+
public interface MapCursor extends Value {
108
public int size();
119

1210
/**
@@ -16,20 +14,20 @@ public interface MapCursor extends ValueRef {
1614
public boolean hasNext();
1715

1816
/**
19-
* Retrieves a reference to the next key or value.
17+
* Retrieves the next key and value.
2018
* @return
2119
*/
22-
public ValueRef nextKeyOrValue();
20+
public KeyValuePair next();
2321

2422
/**
25-
* Skips a next key or value
23+
* Skips a next key-value pair
2624
*/
27-
public void skipKeyOrValue();
25+
public void skip();
2826

2927
/**
3028
* Skips all of the remaining keys and values.
3129
*/
3230
public void skipAll();
3331

34-
MapValue toValue();
32+
public MapValue toImmutable();
3533
}

msgpack-core/src/main/java/org/msgpack/value/MapValue.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
import java.util.Map;
44

55
/**
6-
* Created on 5/30/14.
6+
* MapValue interface
77
*/
88
public interface MapValue extends Value, MapCursor {
9-
public Value[] toKeyValueSeq();
9+
public Value[] toKeyValueArray();
10+
public KeyValuePair[] toArray();
1011
public Map<Value, Value> toMap();
1112

12-
public MapValue toValue();
13+
public MapValue toImmutable();
1314
}

0 commit comments

Comments
 (0)