Skip to content

Commit 7537c12

Browse files
committed
Mechanical code improvements 2
1 parent 6cbbce9 commit 7537c12

File tree

7 files changed

+14
-25
lines changed

7 files changed

+14
-25
lines changed

java/src/org/exist/mongodb/shared/ConversionTools.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,11 @@ public static Object parseSequence(Sequence seq) throws XPathException {
132132
switch (seq.getItemType()) {
133133
case Type.MAP:
134134
MapType map = (MapType) seq;
135-
BasicDBObject value = parseMap(map);
136-
retVal = value;
135+
retVal = parseMap(map);
137136
break;
138137
case Type.ARRAY:
139138
ArrayType array = (ArrayType) seq;
140-
ArrayList values = parseArray(array);
141-
retVal = values;
139+
retVal = parseArray(array);
142140
break;
143141
default:
144142
retVal = ConversionTools.convertParameters(seq)[0];

java/src/org/exist/mongodb/xquery/gridfs/Get.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.bson.types.ObjectId;
3737
import org.exist.Namespaces;
3838
import org.exist.dom.QName;
39-
import org.exist.dom.memtree.DocumentImpl;
4039
import org.exist.dom.memtree.SAXAdapter;
4140
import org.exist.mongodb.shared.Constants;
4241
import static org.exist.mongodb.shared.Constants.EXIST_COMPRESSION;
@@ -129,9 +128,7 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce
129128
throw new XPathException(this, GridfsModule.GRFS0004, String.format("Document '%s' could not be found.", documentId));
130129
}
131130

132-
Sequence retVal = get(gfsFile, forceBinary);
133-
134-
return retVal;
131+
return get(gfsFile, forceBinary);
135132

136133
} catch (XPathException ex) {
137134
LOG.error(ex.getMessage(), ex);

java/src/org/exist/mongodb/xquery/gridfs/Stream.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,8 @@ private ResponseWrapper getResponseWrapper(XQueryContext context) throws XPathEx
275275
throw new XPathException(this, signatures[1].toString()
276276
+ " can only be used within the EXistServlet or XQueryServlet");
277277
}
278-
ResponseWrapper response = (ResponseWrapper) respValue.getObject();
279278

280-
return response;
279+
return (ResponseWrapper) respValue.getObject();
281280
}
282281

283282
/**
@@ -301,9 +300,8 @@ private RequestWrapper getRequestWrapper(XQueryContext context) throws XPathExce
301300
throw new XPathException(this, signatures[1].toString()
302301
+ " can only be used within the EXistServlet or XQueryServlet");
303302
}
304-
RequestWrapper request = (RequestWrapper) respValue.getObject();
305303

306-
return request;
304+
return (RequestWrapper) respValue.getObject();
307305
}
308306

309307
/**

java/src/org/exist/mongodb/xquery/mongodb/collection/FindAndModify.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,10 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce
150150

151151

152152
// Execute query
153-
Sequence retVal = (result==null)
154-
? Sequence.EMPTY_SEQUENCE
155-
: new StringValue(result.toString());
156153

157-
return retVal;
154+
return (result==null)
155+
? Sequence.EMPTY_SEQUENCE
156+
: new StringValue(result.toString());
158157

159158
} catch (Throwable t) {
160159
return GenericExceptionHandler.handleException(this, t);

java/src/org/exist/mongodb/xquery/mongodb/collection/FindAndRemove.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce
9494
DBObject result = dbcol.findAndRemove(query);
9595

9696
// Parse results
97-
Sequence retVal = (result==null)
98-
? Sequence.EMPTY_SEQUENCE
99-
: new StringValue(result.toString());
10097

101-
return retVal;
98+
return (result==null)
99+
? Sequence.EMPTY_SEQUENCE
100+
: new StringValue(result.toString());
102101

103102
} catch (Throwable t) {
104103
return GenericExceptionHandler.handleException(this, t);

java/src/org/exist/mongodb/xquery/mongodb/collection/FindOne.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,11 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce
129129
}
130130

131131
// Execute query
132-
Sequence retVal = (result == null)
132+
133+
return (result == null)
133134
? Sequence.EMPTY_SEQUENCE
134135
: new StringValue(result.toString());
135136

136-
return retVal;
137-
138137
} catch (Throwable t) {
139138
return GenericExceptionHandler.handleException(this, t);
140139
}

java/src/org/exist/mongodb/xquery/mongodb/collection/Group.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,8 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce
139139
DBObject result = dbcol.group(command);
140140

141141
// Execute query
142-
Sequence retVal = new StringValue(result.toString());
143142

144-
return retVal;
143+
return new StringValue(result.toString());
145144

146145
} catch (Throwable t) {
147146
return GenericExceptionHandler.handleException(this, t);

0 commit comments

Comments
 (0)