}
private OtpErlangObject parseField(Fieldable field) {
switch (getFieldType(field.name())) {
case DOUBLE:
return new OtpErlangDouble(Double.parseDouble(field.stringValue()));
case FLOAT:
return new OtpErlangFloat(Float.parseFloat(field.stringValue()));
case INT:
return new OtpErlangInt(Integer.parseInt(field.stringValue()));
case LONG:
return new OtpErlangLong(Long.parseLong(field.stringValue()));
case ATOM:
return new OtpErlangAtom(field.stringValue());
case GEO:
double[] latLong = GeoHashUtils.decode(field.stringValue());
if (latLong.length != 2)
return new OtpErlangString(field.stringValue());
return new OtpErlangTuple(new OtpErlangObject[] {
new OtpErlangAtom("geo"), new OtpErlangDouble(latLong[0]),
new OtpErlangDouble(latLong[1]) });
default:
return new OtpErlangString(field.stringValue());
}
}