Beispiel #1
0
  public GIPSYType getNext(GIPSYType poCurrentTag) {
    GIPSYType result = null;
    switch (this.getExpressionType()) {
      case UPPER_STEP:
        {
          if (isInTagSet(poCurrentTag)) {
            if (poCurrentTag instanceof GIPSYInteger) {
              if (!poCurrentTag.equals(this.getUpper()))
                result =
                    new GIPSYInteger(((GIPSYInteger) poCurrentTag).getValue() + this.getStep());
              // ?????????if it is the end of set, EXCEPTION?

            }

            /** ************************************************************************** */
            /*FUTURE POSSIBLE TYPES THAT HAS PLUS FUNCTIONS DEFINED*/
            /** ************************************************************************** */
          }

          break;
        }
      case LOWER_STEP:
        {
          if (isInTagSet(poCurrentTag)) {
            if (poCurrentTag instanceof GIPSYInteger) {
              if (!poCurrentTag.equals(Integer.MAX_VALUE))
                result =
                    new GIPSYInteger(((GIPSYInteger) poCurrentTag).getValue() + this.getStep());
            }
            /** ************************************************************************** */
            /*FUTURE POSSIBLE TYPES THAT HAS PLUS FUNCTIONS DEFINED*/
            /** ************************************************************************** */
          }

          break;
        }
      case INFINITY:
        {
          if (isInTagSet(poCurrentTag)) {
            if (!poCurrentTag.equals(Integer.MAX_VALUE))
              result = new GIPSYInteger(((GIPSYInteger) poCurrentTag).getValue() + 1);
          }
          break;
        }
    }
    return result;
  }
Beispiel #2
0
  public boolean isInTagSet(GIPSYType poTag) {
    boolean result = false;
    switch (this.getExpressionType()) {
      case UPPER_STEP:
        {
          if (poTag.getClass() == this.getUpper().getClass()) {
            //				Only consider type of GIPSYInteger, since the < > operaters are not defined for
            // other types.
            if (poTag instanceof GIPSYInteger) {
              // The given tag is greater than minus infinite and less than or equal to the upper
              // boundary and can be divided by step, it is inside the tag set.
              if (((GIPSYInteger) poTag).getValue() >= Integer.MIN_VALUE
                  && ((GIPSYInteger) poTag).getValue()
                      <= ((GIPSYInteger) this.getUpper()).getValue()
                  && ((GIPSYInteger) poTag).getValue() % this.getStep() == 0) {
                result = true;
              }
            }

            /** ************************************************************************** */
            /*FUTURE POSSIBLE TYPES THAT HAS LESS THAN AND GREATER THAN FUNCTIONS DEFINED*/
            /** ************************************************************************** */
          }
          break;
        }

      case LOWER_STEP:
        {
          if (poTag.getClass() == this.getLower().getClass()) {
            // Only consider type of GIPSYInteger, since the < > operaters are not defined for other
            // types.
            if (poTag instanceof GIPSYInteger) {
              // The given tag is less than plus infinite and greater than or equal to the lower
              // boundary and can be devided by the step, it is inside the tag set.

              if (((GIPSYInteger) poTag).getValue() <= Integer.MAX_VALUE
                  && ((GIPSYInteger) poTag).getValue()
                      >= ((GIPSYInteger) this.getLower()).getValue()
                  && ((GIPSYInteger) poTag).getValue() % this.getStep() == 0) {
                result = true;
              }
              /** ************************************************************************** */
              /*FUTURE POSSIBLE TYPES THAT HAS LESS THAN AND GREATER THAN FUNCTIONS DEFINED*/
              /** ************************************************************************** */
            }
          }
          break;
        }

      case INFINITY:
        {
          if (poTag instanceof GIPSYInteger) {
            // The given tag is less than plus infinite and greater than or equal to the lower
            // boundary, it is inside the tag set.
            if (((GIPSYInteger) poTag).getValue() <= Integer.MAX_VALUE
                && ((GIPSYInteger) poTag).getValue() >= Integer.MIN_VALUE) {
              result = true;
            }
          }
          break;
        }
    }
    return result;
  }