Package Framework

Examples of Framework.DataValue


            else if (NumericData.class.isAssignableFrom(valueClass)) {
              Class<? extends NumericData>numericValueClass = (Class<? extends NumericData>)valueClass;
            try {
              // TF:10/4/08:Added in the scale of decimaldatas if necessary
              Object currentValue = this.docFilter.field.getValue();
          DataValue dataValue = FormatterUtils.createDataValueInstance(numericValueClass);
          if (currentValue instanceof DecimalData) {
            DecimalData originalValue = (DecimalData)currentValue;
            if (!originalValue.isNull() && dataValue instanceof DecimalData) {
              ((DecimalData)dataValue).setScale(originalValue.getScale());
            }
View Full Code Here


     */
    public String valueToString(Object value) throws ParseException {
      log.debug("valueToString(" + value + ")");

      if (value instanceof DataValue) {
        DataValue dataValue = (DataValue) value;
        Class<?> vc = this.getValueClass();
       
        //PM:7 oct. 2008:this is a special case for DateTimeNullable
        /*
         * if it is set to the beginning of the Gregorian calendar
         * the mask should contain '*'
         */
        if (DateTimeNullable.class.isAssignableFrom(vc)){
          DateTimeNullable dtn = (DateTimeNullable)value;
          if (dtn.asDate().getTime()==DateTimeData.GREGORIAN_START_AS_LONG){
            return super.valueToString(null);
          }
        }
       
        if (dataValue.isNullable() && dataValue.isNull()) {

          // TF+CraigM:19/08/2008 - Only set N/A if we are based on a TextData
          if (TextData.class.isAssignableFrom(vc)) {
            // TF:19/06/2008:Changed this to return N/A if the data field is null
            return "N/A";
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

              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

    // ----------------------
    // Accessors and Mutators
    // ----------------------
    public void setValue(DataValue value) {
        DataValue oldValue = this.value;
        this.value = value;
        this.qq_Listeners.firePropertyChange("value", oldValue, this.value);
    }
View Full Code Here

        GenericException e = null;
        int severity = Constants.SP_ER_ERROR;
        int reasonCode = 0;
        String message = null;
        TextData key = null, status = null;
        DataValue p1 = null, p2 = null;

        if (this.getMsgSetID() == 0) {
            this.setMsgSetID(Error.SVC_MSGSET_ID);
        }
View Full Code Here

     * @param level Type: int (Input) (default in Forte: 0)
     * @return TextData
     */
    @SuppressWarnings("unchecked")
  public TextData fillString(int level) {
        DataValue attr = null;
        BusinessQuery query = null;
        TextData indent = new TextData("\n");
        TextData result = new TextData();

        for (int i = 1; i <= level; i++) {
            indent.concat("   ");
            result.concat("   ");
        }

        query = this.newQuery();
        query.setOperation(BusinessQuery.OP_INSERT, (BusinessKey)null);
        SqlQuery sqlQuery = new SqlQuery(BusinessQuery.OP_INSERT);
        query.describeTables(sqlQuery);
        result.concat(this.getClass().getSimpleName());
        result.concat(": Status = ");
        result.concat(this.statusAsTextData());
        result.concat(", Key = ");
        if (this.getInstanceKey() == null) {
            result.concat("<NIL>");
        }
        else {
            result.concat(this.getInstanceKey().asTextData());
        }

        for (int j = 1; j <= query.getNumAttrs(); j++) {
            result.concat(indent);
            attr = this.getAttr(j);
            result.concat("Attribute ");
            result.concat(j);
            result.concat(" (");
            result.concat(query.getAttrName(j));
            result.concat(") = ");
            if (attr == null) {
                result.concat("<NIL>");
            }
            else if (attr.getIsNull()) {
                result.concat("<NULL>");
            }
            else if (attr instanceof DoubleData && ((DoubleData)attr).getValue() < 1e+012 && ((DoubleData)attr).getValue() > 1e-012) {
                result.concat(new NumericFormat(new TextData("#.############"), NumericFormat.qq_Resolver.cTEMPLATE).formatNumeric((DoubleData)attr));
            }
View Full Code Here

     * <p>
     * @param attr Type: int
     * @param value Type: DataValue
     */
    public void setAttrValue(int attr, DataValue value) {
        DataValue attrVal = null;

        attrVal = this.getAttr(attr);

        if (attrVal == null) {
            attrVal = this.newAttr(attr);
        }

        attrVal.setValue(value);
    }
View Full Code Here

     * @param source Type: BusinessKey
     * @return int
     */
    public int compare(BusinessKey source) {
        BooleanNullable result = null;
        DataValue srcItem = null;
        int srcItemIndex = 0;

        if (source == null || this.getValues() == null) {
            return BusinessKey.CMP_NULL;
        }

        //
        //  Iterate through each DataValues item in the Values array and compare
        //  it against the corresponding element in source's Values array.
        // 
        if (this.getValues() != null) {
            for (DataValue item : this.getValues()) {

                srcItemIndex = srcItemIndex+1;

                if (item == null) {
                    return BusinessKey.CMP_NULL;
                    //
                    //  If source runs out of items then we must be greater
                    //
                }
                else if (srcItemIndex > source.getValues().size()) {
                    return BusinessKey.CMP_LONGER;
                }
                else {
                    srcItem = source.getValues().get(srcItemIndex-1);
                    if (srcItem == null) {
                        return BusinessKey.CMP_NULL;
                    }
                }

                //
                //  Numeric things might not be of the same class but they can all compare
                //  against each other so check this case first
                //
                if (item instanceof NumericData && srcItem instanceof NumericData) {

                    result = ((NumericData)item).isEqual((NumericData)srcItem);
                    if (result.getIsNull()) {
                        return BusinessKey.CMP_NULL;
                    }
                    else if (!(result.getValue())) {
                        result = ((NumericData)item).isGreaterThan((NumericData)srcItem);
                        if ((result).getValue()) {
                            return BusinessKey.CMP_GT;
                        }
                        return BusinessKey.CMP_LT;
                    }

                }
                else {
                    //
                    //  Everthing else can only compare if it is of the same data type.
                    //  We and the data type with 0x7F to mask off the nullable bit.
                    //   
                    int myType = item.dataType()&127;
                    int srcType = srcItem.dataType()&127;

                    if (myType != srcType) {
                        result = item.getTextValue().isEqual(srcItem.getTextValue());
                        if (result.getIsNull()) {
                            return BusinessKey.CMP_NULL;
                        }
                        else if (!(result.getValue())) {
                            return BusinessKey.CMP_NE;
                        }

                    }
                    else {
                        switch (myType) {

                            case Constants.DV_DT_TEXT: {
                                result = ((TextData)item).isEqual((TextData)srcItem);
                                if (result.getIsNull()) {
                                    return BusinessKey.CMP_NULL;
                                }
                                else if (!(result.getValue())) {
                                    result = ((TextData)item).isGreaterThan((TextData)srcItem);
                                    if ((result).getValue()) {
                                        return BusinessKey.CMP_GT;
                                    }
                                    return BusinessKey.CMP_LT;
                                }

                                break;
                            }
                            case Constants.DV_DT_DATETIME: {
                                result = ((DateTimeData)item).isEqual((DateTimeData)srcItem);
                                if (result.getIsNull()) {
                                    return BusinessKey.CMP_NULL;
                                }
                                else if (!(result.getValue())) {
                                    result = ((DateTimeData)item).isGreaterThan((DateTimeData)srcItem);
                                    if ((result).getValue()) {
                                        return BusinessKey.CMP_GT;
                                    }
                                    return BusinessKey.CMP_LT;
                                }

                                break;
                            }
                            case Constants.DV_DT_INTERVAL: {
                                result = ((IntervalData)item).isEqual((IntervalData)srcItem);
                                if (result.getIsNull()) {
                                    return BusinessKey.CMP_NULL;
                                }
                                else if (!(result.getValue())) {
                                    result = ((IntervalData)item).isGreaterThan((IntervalData)srcItem);
                                    if ((result).getValue()) {
                                        return BusinessKey.CMP_GT;
                                    }
                                    return BusinessKey.CMP_LT;
                                }

                                break;
                            }
                            case Constants.DV_DT_BOOLEAN: {
                                result = ((BooleanData)item).isEqual((BooleanData)srcItem);
                                if (result.getIsNull()) {
                                    return BusinessKey.CMP_NULL;
                                }
                                else if (!(result.getValue())) {
                                    return BusinessKey.CMP_NE;
                                }

                                break;
                            }

                            default: {
                                result = item.getTextValue().isEqual(srcItem.getTextValue());
                                if (result.getIsNull()) {
                                    return BusinessKey.CMP_NULL;
                                }
                                else if (!(result.getValue())) {
                                    return BusinessKey.CMP_NE;
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.