Пример #1
0
        ///
        ///	 <summary> * Inverts the boolean state of a Term child element (and, or, xor, not,
        ///	 * Evaluation, TestRef)
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode we test to know if the Device can accept it </param>
        ///	 * <param name="reportRoot">
        ///	 *            the report to generate. Set to <code>null</code> if no report
        ///	 *            is requested. </param>
        ///	 * <returns> boolean - true, if boolean “not” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            VElement v   = getTermVector(null);
            int      siz = v.Count;
            bool     b   = false;

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("not");
            }

            int count = 0;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t = (JDFTerm)v[i];
                b = !t.fitsJDF(jdf, reportRootLocal);
                count++;
                if (reportRootLocal != null)
                {
                    reportRootLocal.setAttribute("Value", b, null);
                }
            }

            if (reportRootLocal != null && count != 1)
            {
                reportRootLocal.setAttribute("SyntaxWarning", "Warning: not element with more than one term, count=" + Convert.ToString(count));
            }

            return(b);
        }
Пример #2
0
        ///
        ///	 <summary> * Evaluates the boolean expression (child Term element) if it fits the
        ///	 * JDFNode 'jdf' a value of true corresponds to a failed test, i.e. the test
        ///	 * describes INVALID states for the jdf
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode to test to know if the Device can accept it </param>
        ///	 * <param name="reportRoot">
        ///	 *            the report to generate. Set to <code>null</code> if no report
        ///	 *            is requested. </param>
        ///	 * <returns> boolean - true, if boolean expression (child Term element)
        ///	 *         evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("TestReport");
            }
            JDFTerm t = getTerm();

            if (t == null)
            {
                return(true); // no term --> assume it is a non test; i.e. ok
            }
            bool checkContext = true;

            if (hasAttribute(AttributeName.CONTEXT))
            {
                checkContext = !jdf.matchesPath(getContext(), true);
            }
            if (checkContext && !t.fitsContext(jdf))
            {
                return(true);
            }
            bool b = t.fitsJDF(jdf, reportRootLocal);

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }
            return(b);
        }
Пример #3
0
        ///
        ///	 <summary> * check whether the boolean logic defined by a Test and a test's
        ///	 * subelements make sense in the context of the tested element jdf </summary>
        ///
        public override bool fitsContext(KElement testElement)
        {
            // we only want the leaves as of now
            if (testElement is JDFResource)
            {
                JDFResource r = (JDFResource)testElement;
                if (!r.isLeaf())
                {
                    return(false);
                }
            }
            VElement v   = getTermVector(null);
            int      siz = v.Count;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t = (JDFTerm)v[i];
                if (!t.fitsContext(testElement)) // one bad context spoils the
                // barrell
                {
                    return(false);
                }
            }
            return(siz > 0); // if no subelements, then no context
        }
Пример #4
0
        ///
        ///	 <summary> * Evaluates two or more Term elements (and, or, xor, not, Evaluation,
        ///	 * TestRef) to determine if, as a set, they evaluate to “true” when combined
        ///	 * in a boolean “or” function.
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode we test iot know if the Device can accept it </param>
        ///	 * <returns> boolean - true, if boolean “or” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            VElement v   = getTermVector(null);
            int      siz = v.Count;

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("or");
            }

            bool b = false;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t  = (JDFTerm)v[i];
                bool    b2 = t.fitsJDF(jdf, reportRootLocal);
                if (b2 && reportRootLocal == null)
                {
                    return(true); // don't need complete report and it is true; ciao
                }
                b = b || b2;
            }

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }

            return(b);
        }
Пример #5
0
        ///
        ///	 <summary> * Inverts the boolean state of a Term element (and, or, xor, not,
        ///	 * Evaluation, TestRef).<br>
        ///	 * To determine the state of Term tests Evaluations that “not” consists of,
        ///	 * it checks whether attribute map 'm' has a key, specified by
        ///	 * Evaluation/BasicPreflightTest/@Name. If 'm' has such key, it checks
        ///	 * whether its value fits the testlists specified for matching the
        ///	 * Evaluation (uses FitsValue(value))
        ///	 *  </summary>
        ///	 * <param name="m">
        ///	 *            key-value pair attribute map </param>
        ///	 * <returns> boolean - true, if boolean “not” expression evaluates to “true” </returns>
        ///
        public override bool fitsMap(JDFAttributeMap m)
        {
            JDFTerm t = getTerm(null, 0);

            if (t == null)
            {
                return(false);
            }
            return(!t.fitsMap(m));
        }
Пример #6
0
        ///
        ///	 <summary> * Evaluates two or more Term elements (
        ///	 * <code>and, or, xor, not, Evaluation, TestRef</code>) to determine if, as
        ///	 * a set, they evaluate to “true” when combined in a boolean “and” function. <br>
        ///	 * Looks for evaluations which contain <code>and</code>. Tests the status of
        ///	 * every evaluation found, until the result of a whole boolean expression
        ///	 * will is determinated. <br>
        ///	 * Tests if attribute map <code>m</code> has a key, specified by
        ///	 * Evaluation/BasicPreflightTest/@Name and if <code>m</code> has such key,
        ///	 * checks if its value fits testlists, specified for matching Evaluation
        ///	 * (uses <code>FitsValue(value)</code>)
        ///	 *  </summary>
        ///	 * <param name="m">
        ///	 *            key-value pair attribute map </param>
        ///	 * <returns> boolean - true, if boolean “and” expression evaluates to “true” </returns>
        ///
        public override bool fitsMap(JDFAttributeMap m)
        {
            VElement v   = getTermVector(null);
            int      siz = v.Count;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t = (JDFTerm)v[i];
                if (!t.fitsMap(m))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #7
0
        ///
        ///	 <summary> * Evaluates two or more Term elements (and, or, xor, not, Evaluation,
        ///	 * TestRef) to determine if, as a set, they evaluate to “true” when combined
        ///	 * in a boolean “xor” function. ! For more than two arguments, exactly one
        ///	 * Term must evaluate to “true” for the “xor” to evaluate to “true”.<br>
        ///	 *
        ///	 * Looks for Evaluations that “xor” consists of, and tests the status of
        ///	 * every Evaluation, until the result of a whole boolean expression is
        ///	 * determinated. Tests whether attribute map 'm' has a key specified by
        ///	 * Evaluation/BasicPreflightTest/@Name. If 'm' has such key, checks if its
        ///	 * value fits the testlists, specified for matching Evaluation (uses
        ///	 * FitsValue(value))
        ///	 *  </summary>
        ///	 * <param name="m">
        ///	 *            key-value pair attribute map </param>
        ///	 * <returns> boolean - true, if boolean “xor” expression evaluates to “true” </returns>
        ///
        public override bool fitsMap(JDFAttributeMap m)
        {
            VElement v     = getChildElementVector(null, null, null, true, 0, false);
            int      siz   = v.Count;
            int      count = 0;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t = (JDFTerm)v[i];
                if (t.fitsMap(m))
                {
                    count++;
                }
                if (count > 1)
                {
                    return(false);
                }
            }

            return(count == 1);
        }
Пример #8
0
        ///
        ///	 <summary> * Evaluates two or more Term elements (and, or, xor, not, Evaluation,
        ///	 * TestRef) to determine if, as a set, they evaluate to “true” when combined
        ///	 * in a boolean “xor” function.
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode to test to know if the Device can accept it </param>
        ///	 * <param name="reportRoot">
        ///	 *            the report to generate; set to <code>null</code> if no report
        ///	 *            is requested </param>
        ///	 * <returns> boolean - true, if boolean “xor” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            VElement v = getTermVector(null);

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("xor");
            }

            int siz = v.Count;

            int count = 0;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t = (JDFTerm)v[i];
                if (t.fitsJDF(jdf, reportRootLocal))
                {
                    count++;
                }

                if (count > 1 && reportRootLocal == null)
                {
                    break;
                }
            }

            bool b = (count == 1);

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }

            return(b);
        }
Пример #9
0
        ///
        ///	 <summary> * Evaluates two or more term elements (
        ///	 * <code>and, or, xor, not, Evaluation, TestRef</code>) to determine if, as
        ///	 * a set, they evaluate to “true” when combined in a boolean “and” function.
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            the JDFNode to be checked iot find out if the device can
        ///	 *            accept it </param>
        ///	 * <returns> boolean - true, if boolean “and” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot) // const JDFNode
        {
            KElement reportRootLocal = reportRoot;

            VElement v = getTermVector(null);

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("and");
            }

            int  siz = v.Count;
            bool b   = true;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t  = (JDFTerm)v[i];
                bool    b2 = t.fitsJDF(jdf, reportRootLocal);
                if (!b2)
                {
                    if (reportRootLocal == null)
                    {
                        return(false);
                    }
                }

                b = b && b2;
            }

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }

            return(b);
        }
Пример #10
0
        ///
        ///	 <summary> * Evaluates the boolean expression (child Term element) if it fits the
        ///	 * attribute map 'm'
        ///	 *  </summary>
        ///	 * <param name="m">
        ///	 *            key-value pair attribute map </param>
        ///	 * <returns> boolean - true, if the boolean expression (child Term element)
        ///	 *         evaluates to “true” </returns>
        ///
        public override bool fitsMap(JDFAttributeMap m)
        {
            JDFTerm t = getTerm();

            return(t == null ? false : t.fitsMap(m));
        }