Package Framework

Examples of Framework.DataValue


            //   For Sybase we cannot verify the class by adding constraints if there
            //  are any BLOB columns.
            //
            if (((BusinessDBMgr)this.getParentService().getMgr(query)).getDB().getDBVendorType() == Constants.DB_VT_SYBASE) {

                DataValue value1 = null;
                int dtype = 0;

                for (int j = query.getNumKeyAttrs()+1; j <= query.getNumAttrs(); j++) {
                    value1 = query.getOriginalClass().getAttr(j);
                    if (value1 != null) {
                        dtype = value1.dataType()&127;
                        if (dtype == 8 || dtype == 9 || (dtype == 6 && value1 instanceof LongTextDomain)) {
                            verifyByQuery = true;
                            break;
                        }
                    }
View Full Code Here


  public Object stringToValue(String value) throws ParseException {
        log.debug("stringToValue(" + value + ")");
        Class<?> vc = getValueClass();
        if (vc != null) {
            if (DataValue.class.isAssignableFrom(vc)) {
                DataValue dataValue = null;
                // If its already created we want to reuse the same instance in
                // order to preseve the datavalues current state
                if (installedTextField != null
                        && installedTextField.getValue() != null) {
                    log.debug("using existing data value");
                    DataValue existingValue = (DataValue) installedTextField.getValue();

                    // The setValue mutator fires a value change that we dont want
                    // anyone to receive so we need to remolve any listeners from
                    // the textfield before we set the value
                    PropertyChangeListener[] listeners = removeValueChangeListeners(existingValue);
                    // TF:07/06/2008:Added in safety in case an exception is thrown
                    try {
                      // CraigM:15/01/2009 - Removed length==0 check as it meant it would incorrectly force
                      //             a non null TextNullable with length 0, to be null.
                      // if (existingValue.isNullable() && (value == null || value.length() == 0))
                      if (existingValue.isNullable() && value == null)
                      {
                          existingValue.setIsNull(true);
                          dataValue = existingValue;
                      }
                      else
                      {
                          // Set the internal value from the string
View Full Code Here

    protected DataValue createDataValueInstance(Class<? extends DataValue> dataValueClass, String value)
            throws ParseException {
        try {
            Constructor<? extends DataValue> constructor = dataValueClass.getConstructor(new Class[0]);
            DataValue dataValue = constructor.newInstance(new Object[0]);
            return setDataValueFromString(dataValue,  value);
        } catch (Throwable t) {
            ParseException errorVar = new ParseException("Unable to instantiate valueclass", 0);
            ErrorMgr.addError(errorVar);
            throw errorVar;
View Full Code Here

                Logger.getLogger("task.part.logmgr").info("CopyRecordValues: Skipping copy; fromRecord and toRecord are the same object.");
            }
            return false;
        }

        DataValue fromValue = null;
        DataValue toValue = null;
        boolean didCopy = false;

        BusinessQuery tmpQry = fromRecord.newQuery();
        int lastDBAttr = tmpQry.getNumAttrs(BusinessQuery.ATTR_DB);

        for (int i = 1; i <= tmpQry.getNumAttrs(BusinessQuery.ATTR_SIMPLE); i++) {
            toValue = toRecord.getAttr(i);
            fromValue = fromRecord.getAttr(i);

            if ((toValue != null && fromValue != null && StringUtils.notEquals(toValue.getTextValue().toString(), fromValue.getTextValue().toString())) || (toValue == null && setIfNil)) {

                if (LogMgr.getInstance().test(Framework.Constants.SP_MT_DEBUG, Framework.Constants.SP_ST_EX, 30, 20)) {
                    Logger.getLogger("task.part.logmgr").info("Copying: fromValue.TextValue=");
                    if (fromValue != null) {
                        Logger.getLogger("task.part.logmgr").info(fromValue.getTextValue());
                    }
                    else {
                        Logger.getLogger("task.part.logmgr").info("NIL");
                    }
                    Logger.getLogger("task.part.logmgr").info("  -->  toValue.TextValue=");
                    if (toValue != null) {
                        Logger.getLogger("task.part.logmgr").info(toValue.getTextValue());
                    }
                    else {
                        Logger.getLogger("task.part.logmgr").info("NIL");
                    }
                }
View Full Code Here

    public void initializeDates(BusinessClass record, BusinessQuery template) {
        DateTimeNullable emptyDate = new DateTimeNullable();
        int recStat = record.getInstanceStatus();

        for (int i = 1; i <= template.getNumAttrs(BusinessQuery.ATTR_DB); i++) {
            DataValue attr = record.getAttr(i);
            if (attr != null && attr instanceof DateTimeNullable) {
                if (recStat == BusinessClass.ST_EMPTY || recStat == BusinessClass.ST_INSERT) {
                    this.getBusinessClient().logAttr(record, i);
                }
                if (((DateTimeNullable)attr).getIsNull() || ((DateTimeNullable)attr).isEqual(emptyDate).getValue()) {
View Full Code Here

                ps.setNull(paramIndex, sqlType);
            }
        }
        else if (inValue instanceof DataValue) {
            // work out the correct type to call
            DataValue value = (DataValue)inValue;
            if (value instanceof TextData) {
                if (value.isNull()) {
                    ps.setNull(paramIndex, Types.VARCHAR);
                }
                else {
                    ps.setString(paramIndex, inValue.toString());
                }
            }
            else if (value instanceof IntegerData) {
                if (value.isNull()) {
                    ps.setNull(paramIndex, Types.INTEGER);
                }
                else {
                    ps.setInt(paramIndex, ((IntegerData)value).intValue());
                }
            }
            else if (value instanceof DecimalData) {
                if (value.isNull()) {
                    ps.setNull(paramIndex, Types.DOUBLE);
                }
                else {
                    ps.setDouble(paramIndex, ((DecimalData)value).doubleValue());
                }
            }
            else if (value instanceof DoubleData) {
                if (value.isNull()) {
                    ps.setNull(paramIndex, Types.DOUBLE);
                }
                else {
                    ps.setDouble(paramIndex, ((DoubleData)value).doubleValue());
                }
            }
            else if (value instanceof DateTimeData) {
                if (value.isNull()) {
                    ps.setNull(paramIndex, Types.DATE);
                }
                else {
                    java.util.Date theDate = ((DateTimeData)value).asDate();
                    ps.setTimestamp(paramIndex, new java.sql.Timestamp(theDate.getTime()));
                }
            }
            else if (value instanceof BinaryData) {
                if (value.isNull()) {
                    ps.setNull(paramIndex, Types.BINARY);
                }
                else {
                    ps.setBytes(paramIndex, ((BinaryData)inValue).toByteArray());
                }
            }
            // TF:20/3/08:Added a missing case for inserting boolean datas into the database
            else if (value instanceof BooleanData) {
              if (sqlType == SqlTypeValue.TYPE_UNKNOWN){ //PM:23/01/2009: special case to handle the BooleanData into column type of number(1)
                if (value.isNull()) {
                  ps.setNull(paramIndex, Types.NULL);
                }
                else {
                  int numericBoolean = ((((BooleanData)inValue).getValue()) ? 1 : 0);
                  ps.setInt(paramIndex, numericBoolean);
                }

              } else {
                if (value.isNull()) {
                  ps.setNull(paramIndex, Types.BOOLEAN);
                }
                else {
                  ps.setBoolean(paramIndex, ((BooleanData)inValue).getValue());
                }
View Full Code Here

              return "N/A";
          }
          return format(numericValue, (NumberFormat) getFormat());
        }
        else if (value instanceof DataValue) {
            DataValue dataValue = (DataValue) value;
            if (dataValue.isNullable() && dataValue.isNull()) {
              return "N/A";
            }
            else {
              return dataValueToString((DataValue)value);
            }
View Full Code Here

     * @return a DataValue instance of the specified typethat contains the value in the column
     * @throws UsageException if there is a type mismatch between the specified type and the database, or if data exceptions occur.
     */
    public DataValue getDataValue(int pColumnID, Class<? extends DataValue> c) {
        try {
            DataValue tn = c.newInstance();
            this.getDataValue(pColumnID, tn); // CraigM:24/09/2008 - Moved code into getDataValue(int, DataValue) method

            return tn;
        } catch (IllegalAccessException e1){
          throw processException("ResultSetHelper: Cannot construct the property type", e1);
View Full Code Here

TOP

Related Classes of Framework.DataValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.