Beispiel #1
0
        ///
        ///	 <summary> * fitsValueList - tests, if the defined 'rangelist' matches the
        ///	 * AllowedValueList or in the 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 'rangelist' matches the valuelist or if
        ///	 *         AllowedValueList is not specified </returns>
        ///
        private bool fitsValueList(JDFDurationRangeList rangelist, EnumFitsValue valuelist)
        {
            JDFDurationRangeList 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));
            }

            return(list.isPartOfRange(rangelist));
        }
Beispiel #2
0
        ///
        ///	 <summary> * fitsListType - checks whether <code>matrixList</code> matches the value
        ///	 * of the ListType attribute specified for this State
        ///	 *  </summary>
        ///	 * <param name="matrixList">
        ///	 *            vector of matrices to test
        ///	 *  </param>
        ///	 * <returns> boolean - true, if 'value' matches specified ListType </returns>
        ///
        private bool fitsListType(List <JDFMatrix> matrixList)
        {
            EnumListType listType = getListType();

            int size = matrixList.Count;

            if (listType.Equals(EnumListType.SingleValue) || listType.Equals(EnumListType.getEnum(0)))
            { // default ListType = SingleValue
                return(size == 1);
            }
            else if (listType.Equals(EnumListType.List))
            {
                return(true);
            }
            else if (listType.Equals(EnumListType.UniqueList))
            {
                for (int i = 0; i < size; i++)
                {
                    for (int j = i + 1; j < size; j++)
                    {
                        JDFMatrix mi = matrixList[i];
                        JDFMatrix mj = matrixList[j];
                        if (mi.Equals(mj))
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
            else
            {
                throw new JDFException("JDFMatrixState.fitsListType illegal ListType attribute");
            }
        }
Beispiel #3
0
        ///
        ///	 <summary> * fitsValueList - checks whether <code>value</code> matches the
        ///	 * AllowedValueList/PresentValueList specified for this State
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            nmtokens to test </param>
        ///	 * <param name="valuelist">
        ///	 *            switches between AllowedValueList and PresentValueList. </param>
        ///	 * <returns> boolean - true, if <code>value</code> matches
        ///	 *         <code>valuelist</code> or if AllowedValueList is not specified </returns>
        ///
        private bool fitsValueList(string @value, EnumFitsValue valuelist)
        {
            VString list;

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

            VString vs = new VString(@value, null);

            EnumListType listType = getListType();

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

            int v_size = vs.Count;
            int l_size = list.Count;

            for (int i = 0; i < v_size; i++) // test every token, that 'value'
            // consists of
            {
                bool bFound = false;
                for (int j = 0; j < l_size; j++)
                {
                    string ve = vs[i];
                    string le = list[j];
                    if (ve.CompareTo(le) == 0)
                    {
                        bFound = true;
                        break;
                    }
                }
                if (!bFound)
                {
                    return(false); // no such value in the 'list'
                }
            }
            return(true);
        }
Beispiel #4
0
        ///
        ///	 <summary> * fitsListType - checks whether <code>matrixList</code> matches the
        ///	 * ListType attribute specified for this Evaluation
        ///	 *  </summary>
        ///	 * <param name="matrixList">
        ///	 *            value to test </param>
        ///	 * <returns> boolean - true, if <code>matrixList</code> matches specified
        ///	 *         value of ListType </returns>
        ///
        private bool fitsListType(VString matrixList)
        {
            EnumListType listType = getListType();

            int size = matrixList.Count;

            for (int i = 0; i < size; i++)
            {
                try
                {
                    new JDFMatrix(matrixList[i]);
                }
                catch (JDFException)
                {
                    return(false);
                }
                catch (FormatException)
                {
                    return(false);
                }
            }

            if (listType.Equals(EnumListType.SingleValue) || listType.Equals(EnumListType.getEnum(0)))
            { // default ListType = SingleValue
                return(size == 1);
            }
            else if (listType.Equals(EnumListType.List))
            {
                return(true);
            }
            else if (listType.Equals(EnumListType.UniqueList))
            {
                for (int i = 0; i < size; i++)
                {
                    for (int j = 0; j < size; j++)
                    {
                        if (j != i)
                        {
                            string mi = matrixList[i];
                            string mj = matrixList[j];
                            if (mi.CompareTo(mj) == 0)
                            {
                                return(false);
                            }
                        }
                    }
                }
                return(true);
            }
            else
            {
                throw new JDFException("JDFMatrixEvaluation.fitsListType illegal ListType attribute");
            }
        }
Beispiel #5
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(JDFIntegerRangeList rangelist, EnumFitsValue valuelist)
        {
            JDFIntegerRangeList list = null;

            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++)
            {
                JDFIntegerRange range = (JDFIntegerRange)rangelist[i];

                // if range looks like"0~-1" but no xdef, then we assume that
                // xdef=lastIntegerInList
                int lastInList   = ((JDFIntegerRange)list[list.Count - 1]).Right;
                int leftInRange  = range.Left;
                int rightInRange = range.Right;
                if (lastInList > 0 && ((rightInRange < 0 && Math.Abs(rightInRange) < lastInList) || (leftInRange < 0 && Math.Abs(leftInRange) < lastInList)))
                {
                    range.setDef(lastInList);
                }
                if (!list.isPartOfRange(range))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #6
0
        ///
        ///	 <summary> * fitsValueList - checks whether <code>value</code> matches the
        ///	 * AllowedValueList or the PresentValueList specified for this Evaluation
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            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(string @value)
        {
            if (!hasAttribute(AttributeName.VALUELIST))
            {
                return(true); // ValueList is not specified
            }
            VString vs = new VString(@value, null);

            VString list = getValueList();

            EnumListType listType = getListType();

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

            int v_size = vs.Count;
            int l_size = list.Count;

            for (int i = 0; i < v_size; i++) // test every token, that 'value'
            // consists of
            {
                bool bFound = false;
                for (int j = 0; j < l_size; j++)
                {
                    string str_i = vs[i];
                    string str_j = list[j];
                    if (str_i.CompareTo(str_j) == 0)
                    {
                        bFound = true;
                        break;
                    }
                }
                if (!bFound)
                {
                    return(false); // no such value in the 'list'
                }
            }
            return(true);
        }
Beispiel #7
0
///
///	 <summary> * fitsListType - tests, if the defined 'value' matches value of ListType
///	 * attribute, specified for this Evaluation
///	 *  </summary>
///	 * <param name="value">
///	 *            value to test </param>
///	 * <returns> boolean - true, if 'value' matches specified value of ListType </returns>
///
        private bool fitsListType(string @value)
        {
            VString vBool = new VString(@value, null);
            int     size  = vBool.Count;

            for (int i = 0; i < size; i++)
            {
                if (!StringUtil.isBoolean(vBool[i]))
                {
                    return(false);
                }
            }

            EnumListType listType = getListType();

            if (listType.Equals(EnumListType.SingleValue) || listType.Equals(EnumListType.getEnum(0)))
            { // default ListType = SingleValue
                return(size == 1);
            }
            else if (listType.Equals(EnumListType.List) || listType.Equals(EnumListType.Span))
            {
                return(true);
            }
            else if (listType.Equals(EnumListType.UniqueList))
            {
                for (int i = 0; i < size; i++)
                {
                    for (int j = 0; j < size; j++)
                    {
                        if (j != i)
                        {
                            string bi = vBool[i];
                            string bj = vBool[j];
                            if (bi.CompareTo(bj) == 0)
                            {
                                return(false);
                            }
                        }
                    }
                }
                return(true);
            }
            else
            {
                throw new JDFException("JDFBooleanEvaluation.fitsListType illegal ListType attribute");
            }
        }
Beispiel #8
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(JDFNumberRangeList rangelist, EnumFitsValue valuelist)
        {
            JDFNumberRangeList 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++)
            {
                JDFNumberRange range = (JDFNumberRange)rangelist[i];

                if (!list.isPartOfRange(range))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #9
0
        ///
        ///	 <summary> * fitsListType - checks whether <code>value</code> matches the value of the
        ///	 * ListType attribute specified for this Evaluation
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            value to test </param>
        ///	 * <returns> boolean - true, if <code>value</code> matches the specified value
        ///	 *         of ListType </returns>
        ///
        private bool fitsListType(string @value)
        {
            if (!StringUtil.isNMTOKENS(@value, false))
            {
                return(false);
            }

            EnumListType listType = getListType();

            if (listType == null)
            {
                return(true);
            }

            if (listType.Equals(EnumListType.SingleValue) || listType.Equals(EnumListType.getEnum(0)))
            { // default ListType = SingleValue
                return(StringUtil.isNMTOKEN(@value));
            }
            // not -
            // tested in
            // fitsValueList
            // in
            // fitsValueList
            else if (listType.Equals(EnumListType.List) || listType.Equals(EnumListType.Span) || listType.Equals(EnumListType.CompleteList) || listType.Equals(EnumListType.CompleteOrderedList) || listType.Equals(EnumListType.ContainedList)) // tested in
            // fitsValueList
            // )
            {
                return(true);
            }
            else if (listType.Equals(EnumListType.UniqueList))
            {
                VString v = new VString(@value, null);
                return(isUnique(v));
            }
            else
            {
                throw new JDFException("JDFNameEvaluation.fitsListType illegal ListType attribute");
            }
        }
Beispiel #10
0
///
///	 <summary> * fitsListType - tests, if the defined <code>value</code> matches the value
///	 * of the ListType attribute, specified for this Evaluation
///	 *  </summary>
///	 * <param name="value">
///	 *            value to test </param>
///	 * <returns> boolean - true, if <code>value</code> matches specified ListType </returns>
///
        private bool fitsListType(string @value)
        {
            EnumListType listType = getListType();

            JDFDateTimeRangeList rangelist;

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

            if (listType.Equals(EnumListType.SingleValue) || listType.Equals(EnumListType.getEnum(0)))
            { // default ListType = SingleValue
                if (@value.IndexOf("P") != 0)
                {
                    return(false);
                }

                try
                {
                    new JDFDate(@value);
                }
                catch (JDFException)
                {
                    return(false);
                }
                catch (FormatException)
                {
                    return(false);
                }

                return(true);
            }
            else if (listType.Equals(EnumListType.RangeList) || listType.Equals(EnumListType.Span))
            {
                return(true);
            }
            else if (listType.Equals(EnumListType.List))
            {
                return(rangelist.isList());
            }
            else if (listType.Equals(EnumListType.OrderedList))
            {
                return(rangelist.isList() && rangelist.isOrdered());
            }
            else if (listType.Equals(EnumListType.UniqueList))
            {
                return(rangelist.isList() && rangelist.isUnique());
            }
            else if (listType.Equals(EnumListType.UniqueOrderedList))
            {
                return(rangelist.isList() && rangelist.isUniqueOrdered());
            }
            else if (listType.Equals(EnumListType.OrderedRangeList))
            {
                return(rangelist.isOrdered());
            }
            else if (listType.Equals(EnumListType.UniqueRangeList))
            {
                return(rangelist.isUnique());
            }
            else if (listType.Equals(EnumListType.UniqueOrderedRangeList))
            {
                return(rangelist.isUniqueOrdered());
            }
            else
            {
                throw new JDFException("JDFDateTimeEvaluation.fitsListType illegal ListType attribute");
            }
        }
Beispiel #11
0
        ///
        ///	 <summary> * fitsListType - tests, if the defined <code>value</code> matches value of
        ///	 * ListType attribute, specified for this State
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            value to test
        ///	 *  </param>
        ///	 * <returns> boolean - true, if 'value' matches specified ListType </returns>
        ///
        protected internal bool fitsListType(string @value)
        {
            if (@value == null)
            {
                return(true);
            }

            EnumListType listType = getListType();

            JDFRangeList rangelist; // lists of strings are most generic

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

            if (listType == null || listType.Equals(EnumListType.SingleValue))
            { // default ListType = SingleValue
                return(@value.IndexOf(" ") == -1);
            }
            else if (listType.Equals(EnumListType.RangeList) || listType.Equals(EnumListType.Span))
            {
                return(true);
            }
            else if (listType.Equals(EnumListType.Range))
            {
                return(rangelist.Count == 1);
            }
            // not -
            // tested in
            // fitsValueList
            // in
            // fitsValueList
            else if (listType.Equals(EnumListType.List) || listType.Equals(EnumListType.CompleteList) || listType.Equals(EnumListType.CompleteOrderedList) || listType.Equals(EnumListType.ContainedList)) // tested in
            // fitsValueList
            {
                return(rangelist.isList());
            }
            else if (listType.Equals(EnumListType.OrderedList))
            {
                return(rangelist.isList() && rangelist.isOrdered());
            }
            else if (listType.Equals(EnumListType.UniqueList))
            {
                return(rangelist.isList() && rangelist.isUnique());
            }
            else if (listType.Equals(EnumListType.UniqueOrderedList))
            {
                return(rangelist.isList() && rangelist.isUniqueOrdered());
            }
            else if (listType.Equals(EnumListType.OrderedRangeList))
            {
                return(rangelist.isOrdered());
            }
            else if (listType.Equals(EnumListType.UniqueRangeList))
            {
                return(rangelist.isUnique());
            }
            else if (listType.Equals(EnumListType.UniqueOrderedRangeList))
            {
                return(rangelist.isUniqueOrdered());
            }
            else
            {
                throw new JDFException("JDFDateTimeState.fitsListType illegal ListType attribute");
            }
        }