//
        //	 * // FitsValue Methods
        //

        ///
        ///	 <summary> * fitsValue - checks whether <code>value</code> matches the testlists
        ///	 * specified for this Evaluation
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            value to test </param>
        ///	 * <returns> boolean - true, if <code>value</code> matches the testlists or if
        ///	 *         testlists are not specified </returns>
        ///
        public override bool fitsValue(string @value)
        {
            if (!fitsListType(@value))
            {
                return(false);
            }

            JDFXYPairRangeList rrl = null;

            try
            {
                rrl = new JDFXYPairRangeList(@value);
            }
            catch (FormatException)
            {
                return(false);
            }

            int siz = rrl.Count;

            for (int i = 0; i < siz; i++) // For every range, that rangelist
            // consists of,
            {                             // we test both of range deliminators - right and left, if they fit
                // XYRelation
                // In this case test of deliminators is sufficient for evaluation of
                // the whole range
                JDFXYPairRange range = (JDFXYPairRange)rrl[i];

                JDFXYPair left  = range.Left;
                JDFXYPair right = range.Right;

                if (left.Equals(right))
                {
                    JDFXYPair xypair = left;
                    if ((fitsValueList(new JDFXYPairRange(xypair)) && fitsXYRelation(xypair)) == false)
                    {
                        return(false);
                    }
                }
                else
                {
                    if ((fitsValueList(range) && fitsXYRelation(left) && fitsXYRelation(right)) == false)
                    {
                        return(false);
                    }
                }
            }
            return(true); // all elements of rangelist fit
        }
Exemple #2
0
        ///
        ///	 <summary> * fitsValue - checks whether <code>value</code> matches the Allowed/Present
        ///	 * test lists specified for this State. In this State the test lists are
        ///	 * ValueList AND XYRelation.
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            value to test </param>
        ///	 * <param name="valuelist">
        ///	 *            the test lists the value has to match.<br>
        ///	 *            Choose one of two values: FitsValue_Allowed and
        ///	 *            FitsValue_Present. (Defaults to Allowed)
        ///	 *  </param>
        ///	 * <returns> boolean - true, if the value is in the valuelist or if
        ///	 *         AllowedValueList is not specified </returns>
        ///
        public override bool fitsValue(string @value, EnumFitsValue testlists)
        {
            if (!fitsListType(@value))
            {
                return(false);
            }

            JDFXYPairRangeList rangelist = null;

            try
            {
                rangelist = new JDFXYPairRangeList(@value);
            }
            catch (FormatException)
            {
                return(false);
            }

            int siz = rangelist.Count;

            for (int i = 0; i < siz; i++) // For every range, that rangelist
            // consists of,
            {                             // we test both of range deliminators - right and left, if they fit
                // XYRelation
                // In this case test of deliminators is sufficient for evaluation of
                // the whole range
                JDFXYPairRange range = (JDFXYPairRange)rangelist[i];

                JDFXYPair left  = range.Left;
                JDFXYPair right = range.Right;

                bool bFitsXY;
                if (left.Equals(right))
                {
                    bFitsXY = fitsXYRelation(left, testlists);
                }
                else
                {
                    bFitsXY = fitsXYRelation(left, testlists) && fitsXYRelation(right, testlists);
                }
                if (!bFitsXY)
                {
                    return(false);
                }
            }

            return(fitsValueList(rangelist, testlists)); // if we are here bFitsXY is
            // true, test ValueList
        }
        ///
        ///	 <summary> * fitsValueList - checks whether <code>rangelist</code> matches the
        ///	 * AllowedValueList or the PresentValueList specified for this Evaluation
        ///	 *  </summary>
        ///	 * <param name="rangelist">
        ///	 *            nmtokens to test </param>
        ///	 * <returns> boolean - true, if <code>value</code> matches
        ///	 *         <code>valuelist</code> or if AllowedValueList is not specified </returns>
        ///
        private bool fitsValueList(JDFXYPairRange range)
        {
            if (!hasAttribute(AttributeName.VALUELIST))
            {
                return(true);
            }

            JDFXYPairRangeList rangelist = getValueList();

            if (hasAttribute(AttributeName.TOLERANCE))
            {
                return(fitsTolerance(rangelist).isPartOfRange(range));
            }
            return(rangelist.isPartOfRange(range));
        }
Exemple #4
0
        ///
        ///	 <summary> * fitsValueList - checks whether <code>rangelist</code> matches the
        ///	 * AllowedValueList/PresentValueList specified for this State
        ///	 *  </summary>
        ///	 * <param name="rangelist">
        ///	 *            range list to test </param>
        ///	 * <param name="valuelist">
        ///	 *            switches between AllowedValueList and PresentValueList.
        ///	 *  </param>
        ///	 * <returns> boolean - true, if <code>rangelist</code> matches the valuelist
        ///	 *         or if AllowedValueList is not specified </returns>
        ///
        private bool fitsValueList(JDFXYPairRangeList rangelist, EnumFitsValue valuelist)
        {
            JDFXYPairRangeList list;

            if (valuelist.Equals(EnumFitsValue.Allowed))
            {
                list = getAllowedValueList();
            }
            else
            {
                list = getPresentValueList();
            }
            if (list == null)
            {
                return(true);
            }

            EnumListType listType = getListType();

            if (listType.Equals(EnumListType.CompleteList))
            {
                return(fitsCompleteList(rangelist, list));
            }
            else if (listType.Equals(EnumListType.CompleteOrderedList))
            {
                return(fitsCompleteOrderedList(rangelist, list));
            }
            else if (listType.Equals(EnumListType.ContainedList))
            {
                return(fitsContainedList(rangelist, list));
            }

            int siz = rangelist.Count;

            for (int i = 0; i < siz; i++)
            {
                JDFXYPairRange range = (JDFXYPairRange)rangelist[i];

                if (!list.isPartOfRange(range))
                {
                    return(false);
                }
            }
            return(true);
        }
        ///
        ///	 <summary> * fitsTolerance - checks whether this Evaluation has a specified Tolerance
        ///	 * that it is not equal to "0 0", and expands the original rangelist to the
        ///	 * rangelist that fits Tolerance.
        ///	 *  </summary>
        ///	 * <param name="origRangeList">
        ///	 *            original rangelist </param>
        ///	 * <returns> NumberRangeList - expanded rangelist, returns original range if
        ///	 *         Tolerance=="0 0" </returns>
        ///
        private JDFXYPairRangeList fitsTolerance(JDFXYPairRangeList origRangeList)
        {
            JDFXYPair tolerance = getTolerance();
            double    nt        = tolerance.X; // negative tolerance
            double    pt        = tolerance.Y; // positive tolerance

            if ((nt == 0) && (pt == 0))
            {
                return(origRangeList);
            }

            // expand our original range into the range +/- Tolerance

            JDFXYPairRangeList rangeList = new JDFXYPairRangeList(origRangeList);

            JDFXYPairRangeList tolRangeList = new JDFXYPairRangeList();

            int size = rangeList.Count;

            for (int i = 0; i < size; i++)
            {
                JDFXYPairRange range = (JDFXYPairRange)rangeList[i];

                JDFXYPair left  = range.Left;
                double    leftX = left.X;
                double    leftY = left.Y;
                left.X = leftX - nt;
                left.Y = leftY - nt;

                JDFXYPair right  = range.Right;
                double    rightX = right.X;
                double    rightY = right.Y;
                right.X = rightX + pt;
                right.Y = rightY + pt;

                range.Left  = left;
                range.Right = right;

                tolRangeList.Append(range);
            }

            return(tolRangeList);
        }