@@ -96,33 +96,41 @@ public static void main(String... args) {
9696
9797 static void getFunc () {
9898 // tag::get[]
99- LookupInResult result = collection .lookupIn ("hotel_1368" , Collections .singletonList (get ("geo.lat" )));
99+ LookupInResult result = collection .lookupIn ("hotel_1368" ,
100+ Collections .singletonList (get ("geo.lat" )));
100101
101- String str = result .contentAs (0 , String .class );
102- System .out .println ("getFunc: Latitude = " + str );
102+ try {
103+ String str = result .contentAs (0 , String .class );
104+ System .out .println ("getFunc: Latitude = " + str );
105+ } catch (PathNotFoundException e ) {
106+ e .printStackTrace ();
107+ }
103108 // end::get[]
104109 }
105110
106111 static void existsFunc () {
107-
108112 // tag::exists[]
109- try {
110- LookupInResult result = collection .lookupIn ("hotel_1368" ,
111- Collections .singletonList (exists ("address.does_not_exist" )));
112- } catch (PathNotFoundException e ) {
113- System .out .println ("existsFunc: " + e );
114- }
113+ LookupInResult result = collection .lookupIn ("hotel_1368" ,
114+ Collections .singletonList (exists ("address.does_not_exist" )));
115+ boolean pathExists = result .exists (0 );
116+ System .out .println ("Non-existent path exists? " + pathExists );
115117 // end::exists[]
116118 }
117119
118120 static void combine () {
119121 // tag::combine[]
120- try {
121- LookupInResult result = collection .lookupIn ("hotel_1368" ,
122- Arrays .asList (get ("geo.lat" ), exists ("address.does_not_exist" )));
123- } catch (PathNotFoundException e ) {
124- System .out .println ("combine: " + e );
125- }
122+ LookupInResult result = collection .lookupIn ("hotel_1368" ,
123+ Arrays .asList (
124+ get ("geo.lat" ), // index 0
125+ exists ("address.does_not_exist" ) // index 1
126+ )
127+ );
128+
129+ String lat = result .contentAs (0 , String .class );
130+ boolean otherExists = result .exists (1 );
131+
132+ System .out .println ("Latitude: " + lat );
133+ System .out .println ("Non-existent path exists? " + otherExists );
126134 // end::combine[]
127135 }
128136
0 commit comments