Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renamed variables for easier reading

  • Loading branch information...
commit 1d29aea5e0e325cc49baf67dfae779dd399c9591 1 parent 07cbb14
@marcesher marcesher authored
View
49 java/src/net/marcesher/CFStrictTyper.java
@@ -1,6 +1,5 @@
package net.marcesher;
-import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -21,53 +20,53 @@ private CFStrictTyper(){}
* @see com.mongodb.Typer#toJavaType(java.lang.Object)
*/
@Override
- public Object toJavaType(Object val){
- if( val == null ) return "";
+ public Object toJavaType(Object value){
+ if( value == null ) return "";
- if(val instanceof java.lang.String){
- return handleSimpleValue(val);
- } else if ( val instanceof List ){
- return handleArray(val);
- } else if( val instanceof Map ){
- return handleMap(val);
+ if(value instanceof java.lang.String){
+ return handleSimpleValue(value);
+ } else if ( value instanceof List ){
+ return handleArray(value);
+ } else if( value instanceof Map ){
+ return handleMap(value);
}
- return val;
+ return value;
}
- public Object handleSimpleValue(Object val) {
- String sval = (java.lang.String) val;
- String svalLC = sval.toLowerCase();
+ public Object handleSimpleValue(Object value) {
+ String stringValue = (java.lang.String) value;
+ String stringValueLowerCase = stringValue.toLowerCase();
//CF booleans
- if( svalLC.equals("false") ) return false;
- if( svalLC.equals("true") ) return true;
+ if( stringValueLowerCase.equals("false") ) return false;
+ if( stringValueLowerCase.equals("true") ) return true;
//CF numbers
//my testing showed that it was faster to let these fall through rather than check for alpha characters via string.matches() and then parse the numbers.
try {
- return Integer.parseInt(sval);
+ return Integer.parseInt(stringValue);
} catch (Exception e) {
//nothing; it's not an int
}
try {
- return Long.parseLong(sval);
+ return Long.parseLong(stringValue);
} catch (Exception e){
//nothing; it's not a long
}
try {
- return Float.parseFloat(sval);
+ return Float.parseFloat(stringValue);
} catch (Exception e) {
//nothing; it's not a float
}
- return val;
+ return value;
}
- public Object handleArray(Object val) {
+ public Object handleArray(Object value) {
try {
- List array = (List) val;
+ List array = (List) value;
Vector newArray = new Vector();
for (Iterator iterator = array.iterator(); iterator.hasNext();) {
newArray.add( toJavaType((Object) iterator.next()) );
@@ -75,18 +74,18 @@ public Object handleArray(Object val) {
return newArray;
} catch (Exception e) {
System.out.println("Exception creating DBObject from Array: " +e.toString());
- return val;
+ return value;
}
}
- public Object handleMap(Object val) {
+ public Object handleMap(Object value) {
try {
- Map map = (Map) val;
+ Map map = (Map) value;
Map ts = new TypedStruct( map, instance );
return ts ;
} catch (Exception e) {
System.out.println("Exception creating DBObject from Map: " + e.toString());
- return val;
+ return value;
}
}
View
BIN  lib/cfmongodb.jar
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.