Package Framework

Examples of Framework.DataValue


            //  0 < attr < ATTR_FOREIGN is true, which means that it is a regular simple
            //  attribute.  Get it and add a constraint which will modify the value in
            //  the Database.  Note:  The constraint on a query for update is used to
            //  specify the columns to update and their values.

            DataValue myValue = null;

            myValue = source.getAttr(attr);

            if (myValue == null) {
                myValue = source.newAttr(attr);
View Full Code Here


   * @return
   */
  public String getString()
  {
    Object anObj = pageContext.getAttribute(this.getVariable(), RESULT_SET_SCOPE);
    DataValue dv;
    String aString = null;
    if (this.getVariable().equalsIgnoreCase("FORTE"))
    {
      if (this.getUrl() != null)
      {
        aString = ((HttpServletResponse) pageContext.getResponse()).encodeURL(this.getUrl());
      }
      else
      if (anObj != null && anObj instanceof ResultSet)
      {
        dv = ((ResultSet) anObj).findMember(this.getItem());
        aString = dv.toString();
      }
    }
    else
    {
      if (anObj != null && anObj instanceof IterateResultSet)
      {
        IterateResultSet anIterateSet = (IterateResultSet) anObj;
        dv = anIterateSet.getResultSet().findMember(anIterateSet.getMemberName(), anIterateSet.getIndex(), this.getItem());
        aString = dv.toString();
      }
      else
      if (anObj != null && anObj instanceof ResultSet)
      {
        dv = ((ResultSet) anObj).findMember(this.getItem());
        aString = dv.toString();
      }
    }
    return aString;
  }
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

        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

                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 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

     * @param value Type: DataValue
     * @param type Type: DataValue
     * @param templateText Type: TextData (Input) (default in Forte: NIL)
     */
    public void addConstraint(int attr, DataValue value, DataValue type, TextData templateText) {
        DataValue kind = null;

        if (attr > this.getNumAttrs()) {

            throw new Error(Error.BQ_ILLEGAL_ATTR, "AddConstraint", this, new IntegerData(attr), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM1).getException();

        }
        else if (type == null || !(value instanceof TextData)) {

            // no need to parse or do SetValue() on "value".
            this.addConstraint(attr, ConstraintOperation.OP_EQ, value);

        }
        else if (type instanceof TextData) {

            TextData v = (TextData)value;
            v.setOffset(0);

            if (v.moveToChar("%_")) {
                this.addConstraint(attr, ConstraintOperation.OP_LIKE, value);
            }
            else if (v.getActualSize() == 4 && v.moveToString("NULL", false, true)) {
                this.addConstraint(attr, ConstraintOperation.OP_NULL, (DataValue)null);
            }
            else {
                this.addConstraint(attr, ConstraintOperation.OP_EQ, value);
            }

        }
        else if (!(type instanceof NumericData) && !(type instanceof DateTimeData)) {

            kind = CloneHelper.clone(type, false);
            kind.setValue(value);
            this.addConstraint(attr, ConstraintOperation.OP_EQ, kind);

        }
        else {

View Full Code Here

            }
        }

        if (!(oneQuery)) {

            DataValue val = null;

            if (result != null) {
                ProcessResult:
                for (BusinessClass entity : result) {
View Full Code Here

          // for example)
          //this.updateInstrument(instrument);
        }
        // TF:6/6/07: if updateData() has not been called on the instrument, we won't know it's type
        // so we are going to have to assume string
        DataValue value = ((ConfigValueInst)instrument).getData();
        if (value != null) {
          String frameworkName = value.getClass().getName();
          if (frameworkName.equalsIgnoreCase("Framework.IntegerData")) {
            typeName = "java.lang.Integer";
          }
          else if (frameworkName.equalsIgnoreCase("Framework.DoubleData")) {
            typeName = "java.lang.Double";
View Full Code Here

    public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException {
        Instrument instrument = this.findInstrument(name);
        Object result = null;
        if (instrument instanceof ConfigValueInst) {
            DataValue value = ((ConfigValueInst)instrument).getData();
            result = value.toString();
        }
        if (instrument instanceof CounterInst) {
            result = ((CounterInst)instrument).getIntegerValue();
        }
        if (instrument instanceof AverageInst) {
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.