@@ -146,7 +146,7 @@ public WriteConcern( int w , int wtimeout , boolean fsync ){
146146 * @param j whether writes should wait for a journaling group commit
147147 */
148148 public WriteConcern ( int w , int wtimeout , boolean fsync , boolean j ){
149- _wValue = w ;
149+ _w = w ;
150150 _wtimeout = wtimeout ;
151151 _fsync = fsync ;
152152 _j = j ;
@@ -169,7 +169,7 @@ public WriteConcern( int w , int wtimeout , boolean fsync , boolean j ){
169169 * @param j whether writes should wait for a journaling group commit
170170 */
171171 public WriteConcern ( String w , int wtimeout , boolean fsync , boolean j ){
172- _wValue = w ;
172+ _w = w ;
173173 _wtimeout = wtimeout ;
174174 _fsync = fsync ;
175175 _j = j ;
@@ -182,9 +182,9 @@ public WriteConcern( String w , int wtimeout , boolean fsync, boolean j ){
182182 public BasicDBObject getCommand (){
183183 BasicDBObject _command = new BasicDBObject ( "getlasterror" , 1 );
184184
185- if ( _wValue instanceof Integer && ( (Integer ) _wValue > 0 ) ||
186- ( _wValue instanceof String && _wValue != null ) ){
187- _command .put ( "w" , _wValue );
185+ if ( _w instanceof Integer && ( (Integer ) _w > 0 ) ||
186+ ( _w instanceof String && _w != null ) ){
187+ _command .put ( "w" , _w );
188188 _command .put ( "wtimeout" , _wtimeout );
189189 }
190190
@@ -201,40 +201,42 @@ public BasicDBObject getCommand(){
201201 * Sets the w value (the write strategy)
202202 * @param wValue
203203 */
204- public void setWObject (Object wValue ) {
205- this ._wValue = wValue ;
204+ public void setWObject (Object w ) {
205+ if ( ! (w instanceof Integer ) && ! (w instanceof String ) )
206+ throw new IllegalArgumentException ("The w parameter must be an int or a String" );
207+ this ._w = w ;
206208 }
207209
208210 /**
209211 * Gets the w value (the write strategy)
210212 * @return
211213 */
212214 public Object getWObject (){
213- return _wValue ;
215+ return _w ;
214216 }
215217
216218 /**
217219 * Sets the w value (the write strategy)
218220 * @param w
219221 */
220222 public void setW (int w ) {
221- _wValue = w ;
223+ _w = w ;
222224 }
223225
224226 /**
225227 * Gets the w parameter (the write strategy)
226228 * @return
227229 */
228230 public int getW (){
229- return (Integer ) _wValue ;
231+ return (Integer ) _w ;
230232 }
231233
232234 /**
233235 * Gets the w parameter (the write strategy) in String format
234236 * @return
235237 */
236238 public String getWString (){
237- return _wValue .toString ();
239+ return _w .toString ();
238240 }
239241
240242 /**
@@ -282,19 +284,19 @@ public boolean fsync(){
282284 * @return
283285 */
284286 public boolean raiseNetworkErrors (){
285- if (_wValue instanceof Integer )
286- return (Integer ) _wValue >= 0 ;
287- return _wValue != null ;
287+ if (_w instanceof Integer )
288+ return (Integer ) _w >= 0 ;
289+ return _w != null ;
288290 }
289291
290292 /**
291293 * Returns whether "getlasterror" should be called (w > 0)
292294 * @return
293295 */
294296 public boolean callGetLastError (){
295- if (_wValue instanceof Integer )
296- return (Integer ) _wValue > 0 ;
297- return _wValue != null ;
297+ if (_w instanceof Integer )
298+ return (Integer ) _w > 0 ;
299+ return _w != null ;
298300 }
299301
300302 /**
@@ -334,7 +336,7 @@ public boolean equals( Object o ){
334336 if ( o == null || getClass () != o .getClass () ) return false ;
335337
336338 WriteConcern that = (WriteConcern ) o ;
337- return _fsync == that ._fsync && _wValue == that ._wValue && _wtimeout == that ._wtimeout && _j == that ._j && _continueOnErrorForInsert == that ._continueOnErrorForInsert ;
339+ return _fsync == that ._fsync && _w == that ._w && _wtimeout == that ._wtimeout && _j == that ._j && _continueOnErrorForInsert == that ._continueOnErrorForInsert ;
338340 }
339341
340342 /**
@@ -384,7 +386,7 @@ public static Majority majorityWriteConcern( int wtimeout, boolean fsync, boolea
384386 }
385387
386388
387- Object _wValue = 0 ;
389+ Object _w = 0 ;
388390 int _wtimeout = 0 ;
389391 boolean _fsync = false ;
390392 boolean _j = false ;
0 commit comments