2525import java .util .List ;
2626import java .util .Map ;
2727
28- import org .neo4j .driver .Value ;
29-
3028import static java .lang .Integer .toHexString ;
3129import static java .lang .String .format ;
3230import static java .util .Arrays .asList ;
4442 * <table>
4543 * <tr><th>Marker</th><th>Binary</th><th>Type</th><th>Description</th></tr>
4644 * <tr><td><code>00..7F</code></td><td><code>0xxxxxxx</code></td><td>+TINY_INT</td><td>Integer 0 to 127</td></tr>
47- * <tr><td><code>80..8F</code></td><td><code>1000xxxx</code></td><td>TINY_TEXT </td><td></td></tr>
45+ * <tr><td><code>80..8F</code></td><td><code>1000xxxx</code></td><td>TINY_STRING </td><td></td></tr>
4846 * <tr><td><code>90..9F</code></td><td><code>1001xxxx</code></td><td>TINY_LIST</td><td></td></tr>
4947 * <tr><td><code>A0..AF</code></td><td><code>1010xxxx</code></td><td>TINY_MAP</td><td></td></tr>
5048 * <tr><td><code>B0..BF</code></td><td><code>1011xxxx</code></td><td>TINY_STRUCT</td><td></td></tr>
6159 * <tr><td><code>CD</code></td><td><code>11001101</code></td><td>BYTES_16</td><td>Byte string (fewer than 2<sup>16</sup> bytes)</td></tr>
6260 * <tr><td><code>CE</code></td><td><code>11001110</code></td><td>BYTES_32</td><td>Byte string (fewer than 2<sup>32</sup> bytes)</td></tr>
6361 * <tr><td><code>CF</code></td><td><code>11001111</code></td><td><em>RESERVED</em></td><td></td></tr>
64- * <tr><td><code>D0</code></td><td><code>11010000</code></td><td>TEXT_8 </td><td>UTF-8 encoded text string (fewer than 2<sup>8</sup> bytes)</td></tr>
65- * <tr><td><code>D1</code></td><td><code>11010001</code></td><td>TEXT_16 </td><td>UTF-8 encoded text string (fewer than 2<sup>16</sup> bytes)</td></tr>
66- * <tr><td><code>D2</code></td><td><code>11010010</code></td><td>TEXT_32 </td><td>UTF-8 encoded text string (fewer than 2<sup>32</sup> bytes)</td></tr>
62+ * <tr><td><code>D0</code></td><td><code>11010000</code></td><td>STRING_8 </td><td>UTF-8 encoded string (fewer than 2<sup>8</sup> bytes)</td></tr>
63+ * <tr><td><code>D1</code></td><td><code>11010001</code></td><td>STRING_16 </td><td>UTF-8 encoded string (fewer than 2<sup>16</sup> bytes)</td></tr>
64+ * <tr><td><code>D2</code></td><td><code>11010010</code></td><td>STRING_32 </td><td>UTF-8 encoded string (fewer than 2<sup>32</sup> bytes)</td></tr>
6765 * <tr><td><code>D3</code></td><td><code>11010011</code></td><td><em>RESERVED</em></td><td></td></tr>
6866 * <tr><td><code>D4</code></td><td><code>11010100</code></td><td>LIST_8</td><td>List (fewer than 2<sup>8</sup> items)</td></tr>
6967 * <tr><td><code>D5</code></td><td><code>11010101</code></td><td>LIST_16</td><td>List (fewer than 2<sup>16</sup> items)</td></tr>
8583public class PackStream
8684{
8785
88- public static final byte TINY_TEXT = (byte ) 0x80 ;
86+ public static final byte TINY_STRING = (byte ) 0x80 ;
8987 public static final byte TINY_LIST = (byte ) 0x90 ;
9088 public static final byte TINY_MAP = (byte ) 0xA0 ;
9189 public static final byte TINY_STRUCT = (byte ) 0xB0 ;
@@ -105,9 +103,9 @@ public class PackStream
105103 public static final byte BYTES_16 = (byte ) 0xCD ;
106104 public static final byte BYTES_32 = (byte ) 0xCE ;
107105 public static final byte RESERVED_CF = (byte ) 0xCF ;
108- public static final byte TEXT_8 = (byte ) 0xD0 ;
109- public static final byte TEXT_16 = (byte ) 0xD1 ;
110- public static final byte TEXT_32 = (byte ) 0xD2 ;
106+ public static final byte STRING_8 = (byte ) 0xD0 ;
107+ public static final byte STRING_16 = (byte ) 0xD1 ;
108+ public static final byte STRING_32 = (byte ) 0xD2 ;
111109 public static final byte RESERVED_D3 = (byte ) 0xD3 ;
112110 public static final byte LIST_8 = (byte ) 0xD4 ;
113111 public static final byte LIST_16 = (byte ) 0xD5 ;
@@ -242,17 +240,17 @@ public void pack( String value ) throws IOException
242240 else
243241 {
244242 byte [] utf8 = value .getBytes ( UTF_8 );
245- packTextHeader ( utf8 .length );
243+ packStringHeader ( utf8 .length );
246244 packRaw ( utf8 );
247245 }
248246 }
249247
250- public void packText ( byte [] utf8 ) throws IOException
248+ public void packString ( byte [] utf8 ) throws IOException
251249 {
252250 if ( utf8 == null ) { packNull (); }
253251 else
254252 {
255- packTextHeader ( utf8 .length );
253+ packStringHeader ( utf8 .length );
256254 packRaw ( utf8 );
257255 }
258256 }
@@ -329,25 +327,25 @@ else if ( size <= Short.MAX_VALUE )
329327 }
330328 }
331329
332- public void packTextHeader ( int size ) throws IOException
330+ public void packStringHeader ( int size ) throws IOException
333331 {
334332 if ( size < 0x10 )
335333 {
336- out .writeByte ( (byte ) (TINY_TEXT | size ) );
334+ out .writeByte ( (byte ) (TINY_STRING | size ) );
337335 }
338336 else if ( size <= Byte .MAX_VALUE )
339337 {
340- out .writeByte ( TEXT_8 )
338+ out .writeByte ( STRING_8 )
341339 .writeByte ( (byte ) size );
342340 }
343341 else if ( size <= Short .MAX_VALUE )
344342 {
345- out .writeByte ( TEXT_16 )
343+ out .writeByte ( STRING_16 )
346344 .writeShort ( (short ) size );
347345 }
348346 else
349347 {
350- out .writeByte ( TEXT_32 )
348+ out .writeByte ( STRING_32 )
351349 .writeInt ( size );
352350 }
353351 }
@@ -537,7 +535,7 @@ public double unpackDouble() throws IOException
537535 public String unpackString () throws IOException
538536 {
539537 final byte markerByte = in .readByte ();
540- if ( markerByte == TINY_TEXT ) // Note no mask, so we compare to 0x80.
538+ if ( markerByte == TINY_STRING ) // Note no mask, so we compare to 0x80.
541539 {
542540 return EMPTY_STRING ;
543541 }
@@ -591,12 +589,12 @@ private byte[] unpackUtf8(byte markerByte) throws IOException
591589 final byte markerHighNibble = (byte ) (markerByte & 0xF0 );
592590 final byte markerLowNibble = (byte ) (markerByte & 0x0F );
593591
594- if ( markerHighNibble == TINY_TEXT ) { return unpackBytes ( markerLowNibble ); }
592+ if ( markerHighNibble == TINY_STRING ) { return unpackBytes ( markerLowNibble ); }
595593 switch (markerByte )
596594 {
597- case TEXT_8 : return unpackBytes ( unpackUINT8 () );
598- case TEXT_16 : return unpackBytes ( unpackUINT16 () );
599- case TEXT_32 :
595+ case STRING_8 : return unpackBytes ( unpackUINT8 () );
596+ case STRING_16 : return unpackBytes ( unpackUINT16 () );
597+ case STRING_32 :
600598 {
601599 long size = unpackUINT32 ();
602600 if ( size <= Integer .MAX_VALUE )
@@ -605,7 +603,7 @@ private byte[] unpackUtf8(byte markerByte) throws IOException
605603 }
606604 else
607605 {
608- throw new Overflow ( "TEXT_32 too long for Java" );
606+ throw new Overflow ( "STRING_32 too long for Java" );
609607 }
610608 }
611609 default : throw new Unexpected ( "Expected a string, but got: 0x" + toHexString ( markerByte & 0xFF ));
@@ -655,7 +653,7 @@ public PackType peekNextType() throws IOException
655653
656654 switch (markerHighNibble )
657655 {
658- case TINY_TEXT : return PackType .TEXT ;
656+ case TINY_STRING : return PackType .STRING ;
659657 case TINY_LIST : return PackType .LIST ;
660658 case TINY_MAP : return PackType .MAP ;
661659 case TINY_STRUCT : return PackType .STRUCT ;
@@ -674,10 +672,10 @@ public PackType peekNextType() throws IOException
674672 case BYTES_16 :
675673 case BYTES_32 :
676674 return PackType .BYTES ;
677- case TEXT_8 :
678- case TEXT_16 :
679- case TEXT_32 :
680- return PackType .TEXT ;
675+ case STRING_8 :
676+ case STRING_16 :
677+ case STRING_32 :
678+ return PackType .STRING ;
681679 case LIST_8 :
682680 case LIST_16 :
683681 case LIST_32 :
0 commit comments