/** * Get this property from the map and convert it to the target class. * @param properties The map object to get the property from. * @param strKey The key of the property. * @param classData The target class to convert the property to. * @param objDefault The default value. * @return The data in the correct class. */ public static Object getAs(Map<String,Object> properties, String strKey, Class<?> classData, Object objDefault) { if (properties == null) return objDefault; Object objData = properties.get(strKey); try { return Converter.convertObjectToDatatype(objData, classData, objDefault); } catch (Exception ex) { return null; } } /**
/** * Convert this object to an unfomatted string (ie., toString). * @param properties The map object to get the property from. * @param strKey The key of the property. * @param classData The target class to convert the property to. * @param objDefault The default value. * @return The data in the correct class. */ public static String convertObjectToString(Object objData, Class<?> classData, Object objDefault) { try { objData = Converter.convertObjectToDatatype(objData, classData, objDefault); } catch (Exception ex) { objData = null; } if (objData == null) return null; return objData.toString(); } /**
/** * Given this retrieved property, extract the status value. */ public int getStatusFromProperty(String strValue) { if (strValue != null) if (strValue.indexOf(',') != -1) strValue = strValue.substring(0, strValue.indexOf(',')); if (DELETED_VALUE.equals(strValue)) return 0; try { return ((Integer)Converter.convertObjectToDatatype(strValue, Integer.class, IntegerField.ZERO)).intValue(); } catch (Exception ex) { } return 0; } /**
/** * Given this retrieved property, extract the status value. */ public int getStatusFromProperty(String strValue) { if (strValue != null) if (strValue.indexOf(',') != -1) strValue = strValue.substring(0, strValue.indexOf(',')); if (DELETED_VALUE.equals(strValue)) return 0; try { return ((Integer)Converter.convertObjectToDatatype(strValue, Integer.class, IntegerField.ZERO)).intValue(); } catch (Exception ex) { } return 0; } /**
objData = Converter.convertObjectToDatatype(objData, classData, null); if (classData == XMLGregorianCalendar.class)
/** * Convert and move string to this field. * Override this method to convert the String to the actual Physical Data Type. * @param bState the state to set the data to. * @param bDisplayOption Display the data on the screen if true. * @param iMoveMode INIT, SCREEN, or READ move mode. * @return The error code (or NORMAL_RETURN). */ public int setString(String strString, boolean bDisplayOption, int iMoveMode) // init this field override for other value { try { Object objData = Converter.convertObjectToDatatype(strString, this.getDataClass(), null, m_ibScale); if (objData == null) if (this.getDataClass() != Boolean.class) if (!(Number.class.isAssignableFrom(this.getDataClass()))) if (this.getDataClass() != java.util.Date.class) objData = Constants.BLANK; // To set a null internally, you must call setData directly return this.setData(objData, bDisplayOption, iMoveMode); } catch (Exception ex) { String strError = ex.getMessage(); if (strError == null) strError = ex.getClass().getName(); if (this.getRecord() != null) if (this.getRecord().getTask() != null) return this.getRecord().getTask().setLastError(strError); return Constants.ERROR_RETURN; } } /**
iQuantity = ((Integer)Converter.convertObjectToDatatype(mapProperties.get(Product.ROOM_TYPE_PARAM + Integer.toString(iPaxCategory)), Integer.class, IntegerField.ZERO)).intValue(); } catch (Exception ex) { iRooms += ((Integer)Converter.convertObjectToDatatype(mapProperties.get(Product.ROOM_TYPE_PARAM + Integer.toString(i)), Integer.class, IntegerField.ZERO)).intValue() / (i - PaxCategory.SINGLE_ID + 1); } catch (Exception ex) { iQuantity = iQuantity * ((Double)Converter.convertObjectToDatatype(mapProperties.get(strKey), Double.class, DoubleField.ZERO)).intValue(); } catch (Exception ex) {
iQuantity = ((Integer)Converter.convertObjectToDatatype(mapProperties.get(Product.ROOM_TYPE_PARAM + Integer.toString(iPaxCategory)), Integer.class, IntegerField.ZERO)).intValue(); } catch (Exception ex) { iRooms += ((Integer)Converter.convertObjectToDatatype(mapProperties.get(Product.ROOM_TYPE_PARAM + Integer.toString(i)), Integer.class, IntegerField.ZERO)).intValue() / (i - PaxCategory.SINGLE_ID + 1); } catch (Exception ex) { iQuantity = iQuantity * ((Double)Converter.convertObjectToDatatype(mapProperties.get(strKey), Double.class, DoubleField.ZERO)).intValue(); } catch (Exception ex) {
objFieldNameValue = Converter.convertObjectToDatatype(objFieldNameValue, field.getDataClass(), null); } catch (Exception ex) { objFieldNameValue = null;
objFieldNameValue = Converter.convertObjectToDatatype(objFieldNameValue, field.getDataClass(), null); } catch (Exception ex) { objFieldNameValue = null;