Skip to content

Commit 299f05b

Browse files
committed
Rename .value -> .get, remove some asXXX methods, fix broken test
:x
1 parent 892b0d7 commit 299f05b

Some content is hidden

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

58 files changed

+317
-517
lines changed

driver/src/main/java/org/neo4j/driver/internal/InternalEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public Iterable<String> keys()
106106
}
107107

108108
@Override
109-
public Value value( String key )
109+
public Value get( String key )
110110
{
111111
Value value = properties.get( key );
112112
return value == null ? Values.NULL : value;

driver/src/main/java/org/neo4j/driver/internal/InternalRecord.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public boolean containsKey( String key )
7575
}
7676

7777
@Override
78-
public Value value( String key )
78+
public Value get( String key )
7979
{
8080
Integer fieldIndex = keyIndexLookup.get( key );
8181

@@ -90,7 +90,7 @@ public Value value( String key )
9090
}
9191

9292
@Override
93-
public Value value( int index )
93+
public Value get( int index )
9494
{
9595
return index >= 0 && index < values.length ? values[index] : Values.NULL;
9696
}
@@ -145,8 +145,8 @@ else if ( other instanceof Record )
145145
}
146146
for ( int i = 0; i < size; i++ )
147147
{
148-
Value value = value( i );
149-
Value otherValue = otherRecord.value( i );
148+
Value value = get( i );
149+
Value otherValue = otherRecord.get( i );
150150
if ( ! value.equals( otherValue ) )
151151
{
152152
return false;

driver/src/main/java/org/neo4j/driver/internal/InternalResultCursor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ public boolean isOpen()
6060
return open;
6161
}
6262

63-
public Value value( int index )
63+
public Value get( int index )
6464
{
65-
return record().value( index );
65+
return record().get( index );
6666
}
6767

68-
public Value value( String key )
68+
public Value get( String key )
6969
{
70-
return record().value( key );
70+
return record().get( key );
7171
}
7272

7373
@Override
@@ -298,9 +298,9 @@ public int index( String key )
298298
}
299299

300300
@Override
301-
public Value value( String key )
301+
public Value get( String key )
302302
{
303-
return record().value( key );
303+
return record().get( key );
304304
}
305305

306306
@Override
@@ -336,9 +336,9 @@ public Record record()
336336
}
337337

338338
@Override
339-
public Value value( int index )
339+
public Value get( int index )
340340
{
341-
return record().value( index );
341+
return record().get( index );
342342
}
343343
}
344344
}

driver/src/main/java/org/neo4j/driver/internal/connector/socket/SocketResponseHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private void collectStatistics( StreamCollector collector, Value stats )
177177

178178
private int statsValue( Value stats, String name )
179179
{
180-
Value value = stats.value( name );
180+
Value value = stats.get( name );
181181
return value.isNull() ? 0 : value.asInt();
182182
}
183183

driver/src/main/java/org/neo4j/driver/internal/messaging/PackStreamMessageFormatV1.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private void packValue( Value value ) throws IOException
243243
for ( String s : value.keys() )
244244
{
245245
packer.pack( s );
246-
packValue( value.value( s ) );
246+
packValue( value.get( s ) );
247247
}
248248
break;
249249

@@ -371,7 +371,7 @@ private void packProperties( Entity entity ) throws IOException
371371
for ( String propKey : keys )
372372
{
373373
packer.pack( propKey );
374-
packValue( entity.value( propKey ) );
374+
packValue( entity.get( propKey ) );
375375
}
376376
}
377377
}

driver/src/main/java/org/neo4j/driver/internal/summary/InternalNotification.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ public class InternalNotification implements Notification
3030
@Override
3131
public Notification apply( Value value )
3232
{
33-
String code = value.value( "code" ).asString();
34-
String title = value.value( "title" ).asString();
35-
String description = value.value( "description" ).asString();
33+
String code = value.get( "code" ).asString();
34+
String title = value.get( "title" ).asString();
35+
String description = value.get( "description" ).asString();
3636

37-
Value posValue = value.value( "position" );
37+
Value posValue = value.get( "position" );
3838
InputPosition position = null;
3939
if( posValue != null )
4040
{
41-
position = new InternalInputPosition( posValue.value( "offset" ).asInt(),
42-
posValue.value( "line" ).asInt(),
43-
posValue.value( "column" ).asInt() );
41+
position = new InternalInputPosition( posValue.get( "offset" ).asInt(),
42+
posValue.get( "line" ).asInt(),
43+
posValue.get( "column" ).asInt() );
4444
}
4545

4646
return new InternalNotification( code, title, description, position );

driver/src/main/java/org/neo4j/driver/internal/summary/InternalPlan.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,19 @@ public Converter( PlanCreator<T> planCreator )
161161
@Override
162162
public T apply( Value plan )
163163
{
164-
final String operatorType = plan.value( "operatorType" ).asString();
164+
final String operatorType = plan.get( "operatorType" ).asString();
165165

166-
final Value argumentsValue = plan.value( "args" );
166+
final Value argumentsValue = plan.get( "args" );
167167
final Map<String, Value> arguments = argumentsValue.isNull()
168168
? Collections.<String, Value>emptyMap()
169169
: argumentsValue.asMap( valueAsIs() );
170170

171-
final Value identifiersValue = plan.value( "identifiers" );
171+
final Value identifiersValue = plan.get( "identifiers" );
172172
final List<String> identifiers = identifiersValue.isNull()
173173
? Collections.<String>emptyList()
174174
: identifiersValue.asList( valueAsString() );
175175

176-
final Value childrenValue = plan.value( "children" );
176+
final Value childrenValue = plan.get( "children" );
177177
final List<T> children = childrenValue.isNull()
178178
? Collections.<T>emptyList()
179179
: childrenValue.asList( this );

driver/src/main/java/org/neo4j/driver/internal/summary/InternalProfiledPlan.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public long records()
5656
public ProfiledPlan create( String operatorType, Map<String,Value> arguments, List<String> identifiers, List<ProfiledPlan> children, Value originalPlanValue )
5757
{
5858
return new InternalProfiledPlan( operatorType, arguments, identifiers, children,
59-
originalPlanValue.value( "dbHits" ).asLong(),
60-
originalPlanValue.value( "rows" ).asLong() );
59+
originalPlanValue.get( "dbHits" ).asLong(),
60+
originalPlanValue.get( "rows" ).asLong() );
6161
}
6262
};
6363

driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.security.KeyStore;
2929
import java.security.KeyStoreException;
3030
import java.security.cert.Certificate;
31+
import java.security.cert.CertificateException;
3132
import java.security.cert.CertificateFactory;
3233
import javax.xml.bind.DatatypeConverter;
3334

@@ -119,9 +120,22 @@ public static void loadX509Cert( File certFile, KeyStore keyStore ) throws Gener
119120
int certCount = 0; // The file might contain multiple certs
120121
while ( inputStream.available() > 0 )
121122
{
122-
Certificate cert = certFactory.generateCertificate( inputStream );
123-
certCount++;
124-
loadX509Cert( cert, "neo4j.javadriver.trustedcert." + certCount, keyStore );
123+
try
124+
{
125+
Certificate cert = certFactory.generateCertificate( inputStream );
126+
certCount++;
127+
loadX509Cert( cert, "neo4j.javadriver.trustedcert." + certCount, keyStore );
128+
}
129+
catch( CertificateException e )
130+
{
131+
if( e.getCause() != null && e.getCause().getMessage().equals( "Empty input" ) )
132+
{
133+
// This happens if there is whitespace at the end of the certificate - we load one cert, and then try and load a
134+
// second cert, at which point we fail
135+
return;
136+
}
137+
throw new IOException( "Failed to load certificate from `" + certFile.getAbsolutePath() + "`: " + certCount + " : " + e.getMessage(), e );
138+
}
125139
}
126140
}
127141

driver/src/main/java/org/neo4j/driver/internal/util/Extract.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ public static <T> Map<String, T> map( RecordAccessor record, Function<Value, T>
121121
return emptyMap();
122122

123123
case 1:
124-
return singletonMap( record.keys().get( 0 ), mapFunction.apply( record.value( 0 ) ) );
124+
return singletonMap( record.keys().get( 0 ), mapFunction.apply( record.get( 0 ) ) );
125125

126126
default:
127127
Map<String, T> map = new HashMap<>( size );
128128
List<String> keys = record.keys();
129129
for ( int i = 0; i < size; i++ )
130130
{
131-
map.put( keys.get( i ), mapFunction.apply( record.value( i ) ) );
131+
map.put( keys.get( i ), mapFunction.apply( record.get( i ) ) );
132132
}
133133
return unmodifiableMap( map );
134134
}
@@ -145,7 +145,7 @@ public static <V> Iterable<Pair<String, V>> properties( final MapAccessor map, f
145145
case 1:
146146
{
147147
String key = map.keys().iterator().next();
148-
Value value = map.value( key );
148+
Value value = map.get( key );
149149
return singletonList( InternalPair.of( key, mapFunction.apply( value ) ) );
150150
}
151151

@@ -154,7 +154,7 @@ public static <V> Iterable<Pair<String, V>> properties( final MapAccessor map, f
154154
List<Pair<String, V>> list = new ArrayList<>( size );
155155
for ( String key : map.keys() )
156156
{
157-
Value value = map.value( key );
157+
Value value = map.get( key );
158158
list.add( InternalPair.of( key, mapFunction.apply( value ) ) );
159159
}
160160
return unmodifiableList( list );
@@ -173,7 +173,7 @@ public static <V> List<Pair<String, V>> fields( final RecordAccessor map, final
173173
case 1:
174174
{
175175
String key = map.keys().iterator().next();
176-
Value value = map.value( key );
176+
Value value = map.get( key );
177177
return singletonList( InternalPair.of( key, mapFunction.apply( value ) ) );
178178
}
179179

@@ -184,7 +184,7 @@ public static <V> List<Pair<String, V>> fields( final RecordAccessor map, final
184184
for ( int i = 0; i < size; i++ )
185185
{
186186
String key = keys.get( i );
187-
Value value = map.value( i );
187+
Value value = map.get( i );
188188
list.add( InternalPair.of( key, mapFunction.apply( value ) ) );
189189
}
190190
return unmodifiableList( list );

driver/src/main/java/org/neo4j/driver/internal/util/Iterables.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ public static <T> List<T> asList( Iterable<T> it )
5252
return list;
5353
}
5454

55+
public static Map<String, String> map( String ... alternatingKeyValue )
56+
{
57+
Map<String, String> out = new HashMap<>();
58+
for ( int i = 0; i < alternatingKeyValue.length; i+=2 )
59+
{
60+
out.put( alternatingKeyValue[i], alternatingKeyValue[i+1] );
61+
}
62+
return out;
63+
}
64+
5565
public static <A,B> Iterable<B> map(final Iterable<A> it, final Function<A,B> f)
5666
{
5767
return new Iterable<B>()

driver/src/main/java/org/neo4j/driver/internal/value/EntityValueAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public Iterable<String> keys()
4646
}
4747

4848
@Override
49-
public Value value( String key )
49+
public Value get( String key )
5050
{
51-
return asEntity().value( key );
51+
return asEntity().get( key );
5252
}
5353
}

driver/src/main/java/org/neo4j/driver/internal/value/FloatValue.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,6 @@ public int asInt()
6767
return intVal;
6868
}
6969

70-
@Override
71-
public short asShort()
72-
{
73-
short shortVal = (short) val;
74-
if ((double) shortVal != val)
75-
{
76-
throw new LossyCoercion( type().name(), "Java short" );
77-
}
78-
79-
return shortVal;
80-
}
81-
82-
@Override
83-
public byte asByte()
84-
{
85-
byte byteVal = (byte) val;
86-
if ((double) byteVal != val)
87-
{
88-
throw new LossyCoercion( type().name(), "Java byte" );
89-
}
90-
91-
return byteVal;
92-
}
93-
9470
public double asDouble()
9571
{
9672
return val;

driver/src/main/java/org/neo4j/driver/internal/value/IntegerValue.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,6 @@ public int asInt()
5959
return (int) val;
6060
}
6161

62-
@Override
63-
public short asShort()
64-
{
65-
if (val > Short.MAX_VALUE || val < Short.MIN_VALUE)
66-
{
67-
throw new LossyCoercion( type().name(), "Java short" );
68-
}
69-
return (short) val;
70-
}
71-
72-
public byte asByte()
73-
{
74-
if (val > Byte.MAX_VALUE || val < Byte.MIN_VALUE)
75-
{
76-
throw new LossyCoercion( type().name(), "Java byte" );
77-
}
78-
return (byte) val;
79-
}
80-
8162
@Override
8263
public double asDouble()
8364
{

driver/src/main/java/org/neo4j/driver/internal/value/ListValue.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -115,28 +115,6 @@ public int[] asIntArray()
115115
return result;
116116
}
117117

118-
@Override
119-
public short[] asShortArray()
120-
{
121-
short[] result = new short[ size() ];
122-
for ( int i = 0; i < values.length; i++ )
123-
{
124-
result[i] = values[i].asShort();
125-
}
126-
return result;
127-
}
128-
129-
@Override
130-
public byte[] asByteArray()
131-
{
132-
byte[] result = new byte[ size() ];
133-
for ( int i = 0; i < values.length; i++ )
134-
{
135-
result[i] = values[i].asByte();
136-
}
137-
return result;
138-
}
139-
140118
@Override
141119
public double[] asDoubleArray()
142120
{
@@ -166,7 +144,7 @@ public int size()
166144
}
167145

168146
@Override
169-
public Value value( int index )
147+
public Value get( int index )
170148
{
171149
return index >= 0 && index < values.length ? values[index] : Values.NULL;
172150
}

driver/src/main/java/org/neo4j/driver/internal/value/MapValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public <T> Iterable<T> values( Function<Value, T> mapFunction )
9999
}
100100

101101
@Override
102-
public Value value( String key )
102+
public Value get( String key )
103103
{
104104
Value value = val.get( key );
105105
return value == null ? Values.NULL: value;

driver/src/main/java/org/neo4j/driver/internal/value/NullValue.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ public Object asObject()
4242
return null;
4343
}
4444

45-
@Override
46-
public String asString()
47-
{
48-
return "null";
49-
}
50-
5145
@Override
5246
public Type type()
5347
{

0 commit comments

Comments
 (0)