Beispiel #1
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
        }
Beispiel #2
0
        ///
        ///	 <summary> * entrySet - Returns a Set view of the entries contained in this Hashtable. Each element in this collection is a
        ///	 * Map.Entry. The Set is backed by the Hashtable, so changes to the Hashtable are reflected in the Set, and
        ///	 * vice-versa. The Set supports element removal (which removes the corresponding entry from the Hashtable), but not
        ///	 * element addition.
        ///	 *  </summary>
        ///	 * <returns> Set - the set view of the entries contained in this hashtable </returns>
        ///
        // TODO: Just Delete this?
        //      public virtual Set entrySet()
        //      {
        ////JAVA TO VB & C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'entrySet' method:
        //         return m_hashTable.entrySet();
        //      }

        ///
        ///	 <summary> * subMap - returns true if map contains subMap, all keys of submap must be in this hashtable and they must have the
        ///	 * same value<br>
        ///	 *
        ///	 * if subMap is null, the function returns true if subMap contains any wildcards, then the existance of the key in
        ///	 * this defines a match
        ///	 *  </summary>
        ///	 * <param name="subMap"> the map to compare
        ///	 *  </param>
        ///	 * <returns> boolean - true if this map contains subMap </returns>
        ///
        public virtual bool subMap(JDFAttributeMap subMap)
        {
            if (subMap == null) // the null map is a subset of everything
            {
                return(true);
            }

            ICollection <string> mapSet    = this.Keys;
            ICollection <string> subMapSet = subMap.Keys;

            if (!this.containsAll(subMapSet))
            {
                return(false);
            }

            IEnumerator <string> it = subMapSet.GetEnumerator();

            while (it.MoveNext())
            {
                string key    = it.Current;
                string subVal = subMap[key];
                if (!KElement.isWildCard(subVal))
                {
                    string val = this[key];
                    if (!val.Equals(subVal))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #3
0
        ///
        ///	 <summary> * fitsJDF - tests whether JDFNode 'jdf' can be accepted by the Device.
        ///	 * Tests if the value of resource attribute, decribed with this Evaluation,
        ///	 * fits Evaluation/@ValueList
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            jdf node to test </param>
        ///	 * <returns> boolean - true, if 'jdf' can be accepted by the Device </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            string xPath = getEvalXPath(jdf);

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

            bool b = false;

            if (xPath != null)
            {
                b = fitsPath(jdf, xPath, reportRootLocal);
            }

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

            return(b);
        }
Beispiel #4
0
 public virtual void testNonAsciiFileURL()
 {
     for (int i = 0; i < 2; i++) // loop over escape and non-escape
     {
         FileInfo f  = new FileInfo("4€5%äö.txt");
         FileInfo f2 = FileUtil.getFileInDirectory(new DirectoryInfo(sm_dirTestDataTemp), f);
         f2.Delete();
         SupportClass.FileSupport.CreateNewFile(f2);
         f2.Refresh();
         Assert.IsTrue(f2.Exists);
         string   url  = UrlUtil.fileToUrl(f2, i == 0);
         XMLDoc   doc  = new XMLDoc("URL", null);
         KElement root = doc.getRoot();
         root.setAttribute("url", url);
         doc.write2File(sm_dirTestDataTemp + "url.xml", 2, false);
         JDFParser p = new JDFParser();
         p.bKElementOnly = true;
         JDFDoc   d        = p.parseFile(sm_dirTestDataTemp + "url.xml");
         KElement root2    = d.getRoot();
         string   urlParse = root2.getAttribute("url");
         Assert.AreEqual(url, urlParse);
         FileInfo f3 = UrlUtil.urlToFile(urlParse);
         Assert.AreEqual(f2.FullName, f3.FullName);
         Assert.IsTrue(f3.Exists);
     }
 }
Beispiel #5
0
        ///
        ///	 <summary> * walk the tree starting at e.
        ///	 *  </summary>
        ///	 * <param name="e"> the root element to walk </param>
        ///	 * <returns> n the number of traversed elements </returns>
        ///
        public virtual int walk(KElement e)
        {
            if (e == null)
            {
                return(0);
            }
            int n = 0;

            IWalker w = theFactory.getWalker(e);
            bool    b = true;

            if (w != null)
            {
                n++;
                b = w.walk(e);
            }
            if (b)                                                                         // follow kids if still alive
            {
                VElement v = e.getChildElementVector_KElement(null, null, null, true, -1); // do
                // not
                // follow
                // refelements
                int size = v.Count;
                for (int i = 0; i < size; i++)
                {
                    KElement e2 = v[i];
                    n += walk(e2);
                }
            }
            return(n);
        }
Beispiel #6
0
        ///
        ///	 <summary> * converts a response to a signal that can be sent individually
        ///	 *  </summary>
        ///	 * <param name="response"> the response to convert </param>
        ///	 * <returns> true if successful </returns>
        ///
        public virtual bool convertResponse(JDFResponse response, JDFQuery q)
        {
            if (response == null)
            {
                return(false);
            }
            setAttributes(response);
            VElement elements = response.getChildElementVector(null, null, null, true, 0, true);

            for (int i = 0; i < elements.Count; i++)
            {
                JDFElement element = (JDFElement)elements[i];
                copyElement(element, null);
            }
            if (q != null)
            {
                VElement v = q.getChildElementVector(null, null, null, true, 0, true);
                for (int i = 0; i < v.Count; i++)
                {
                    KElement item = v.item(i);
                    if (item is JDFSubscription)
                    {
                        continue;
                    }
                    copyElement(item, null);
                }
            }
            setType(response.getType()); // also fix xsi:type
            return(true);
        }
Beispiel #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 “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);
        }
Beispiel #8
0
        ///
        ///	 <summary> * overlapMap - identical keys must have the same values in both maps i.e submap is either a superset or a subset of
        ///	 * this
        ///	 *  </summary>
        ///	 * <param name="subMap"> the map to compare with <code>this</this>
        ///	 *  </param>
        ///	 * <returns> boolean - true if identical keys have the same values in both maps </returns>
        ///
        public virtual bool overlapMap(JDFAttributeMap subMap)
        {
            if (subMap == null || subMap.Count == 0)
            {
                return(true);
            }

            IEnumerator <string> subMapEnum = subMap.getKeyIterator();

            while (subMapEnum.MoveNext())
            {
                string subMapKey = subMapEnum.Current;
                string subMapVal = subMap[subMapKey];
                if (KElement.isWildCard(subMapVal))
                {
                    continue;
                }

                string val = this[subMapKey];
                if (val != null && !subMapVal.Equals(val))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #9
0
        private static void removePoolElements_Static(KElement root)
        {
            VElement v = root.getChildElementVector(null, null, null, true, 0, false);

            for (int j = v.Count - 1; j >= 0; j--)
            {
                KElement el  = v[j];
                string   nam = el.Name;
                if (nam.Equals("InvalidAttributes") || nam.Equals("InvalidElements") || nam.Equals("UnknownAttributes") || nam.Equals("UnknownElements") || nam.Equals("MissingAttributes"))
                {
                    moveChildElementVector_Static(root, el);
                    if (!el.hasChildElements() && !el.hasAttributes())
                    {
                        root.removeChild(el);
                    }
                }
            }
            VElement vv = root.getChildElementVector(null, null, null, true, 0, false);

            for (int i = vv.Count - 1; i >= 0; i--)
            {
                removePoolElements_Static(vv[i]);
            }
            return;
        }
Beispiel #10
0
        public virtual void testStateReportRequired()
        {
            JDFDoc    d  = new JDFDoc("DevCap");
            JDFDevCap dc = (JDFDevCap)d.getRoot();

            dc.setName("foo");
            JDFIntegerState @is = dc.appendIntegerState();

            @is.setName("bar1");
            @is.setRequired(true);
            JDFIntegerState is2 = dc.appendIntegerState();

            is2.setName("bar2");
            is2.setRequired(false);

            JDFDoc   d2  = new JDFDoc("foo");
            KElement foo = d2.getRoot();

            JDFDoc   d3     = new JDFDoc("parent");
            KElement parent = d3.getRoot();

            dc.stateReport(foo, EnumFitsValue.Allowed, EnumValidationLevel.Complete, false, true, parent);
            Assert.IsTrue(parent.ToString().IndexOf("bar1") >= 0);
            Assert.IsFalse(parent.ToString().IndexOf("bar2") >= 0);
        }
Beispiel #11
0
        public void testMarkObject()
        {
            JDFDoc  doc  = new JDFDoc("JDF");
            JDFNode root = doc.getJDFRoot();

            root.setVersion(EnumVersion.Version_1_4);
            root.setType(EnumType.Tiling);
            JDFResourcePool resPool = root.getCreateResourcePool();
            KElement        kElem   = resPool.appendResource(ElementName.TILE, null, null);

            Assert.IsTrue(kElem is JDFTile);
            JDFTile tile = ((JDFTile)kElem);

            try
            {
                tile.setClipBox(new JDFRectangle("0 0 123 123"));
                tile.setCTM(new JDFMatrix("1 0 0 1 0 0"));
                JDFMarkObject m = tile.appendMarkObject();
                m.setOrd(0);
                m.setCTM(new JDFMatrix("1.2 0 0 1.4 1 444."));
                Assert.IsTrue(m.isValid(EnumValidationLevel.Complete));
                JDFMarkObject m2 = tile.appendMarkObject();
                m2.setOrd(0);
                m2.setCTM(new JDFMatrix("1.234 0 0 1.4 1 444."));
                Assert.IsTrue(m2.isValid(EnumValidationLevel.Complete));
                Assert.AreEqual(tile.getMarkObject(1), m2);
                Assert.AreEqual(tile.getCreateMarkObject(1), m2);
                Assert.IsTrue(tile.isValid(EnumValidationLevel.Complete));
            }
            catch (FormatException)
            {
                Assert.Fail("bad unit matrix");
            }
        }
Beispiel #12
0
        public virtual void testObjectTagsMetadata()
        {
            KElement tagMap = rl.appendElement(METADATA_MAP);

            tagMap.setXMLComment("This tagmap specifies The path for the NMTOKEN \"ObjectTag\"");
            tagMap.setAttribute("Name", "ObjectTags");
            tagMap.setAttribute(AttributeName.VALUEFORMAT, "%s");
            tagMap.setAttribute(AttributeName.CONTEXT, "Object");
            tagMap.setAttribute(AttributeName.DATATYPE, "NMTOKEN");
            tagMap.setAttribute(AttributeName.VALUETEMPLATE, "AnyName1");
            tagMap.addNameSpace("TIFFXMP", "http://ns.adobe.com/tiff/1.0");
            string[] ss = new string[] { "Acme", "Bcme", "Ccme" };
            for (int i = 0; i < ss.Length; i++)
            {
                string   s      = ss[i];
                KElement tagSet = tagMap.appendElement(EXPR);
                tagSet.setAttribute("Name", "AnyName1");
                tagSet.setAttribute("Value", s);

                JDFStringEvaluation eval = (JDFStringEvaluation)tagSet.appendElement(ElementName.STRINGEVALUATION);
                eval.setAttribute("Path", "TIFFXMP:Make");
                eval.setRegExp("(.*)" + s + "(.*)");
                eval.setXMLComment("Any acme camera is mapped to \"" + s + "\"");
            }
            JDFColorSpaceConversionParams csp = (JDFColorSpaceConversionParams)root.addResource(ElementName.COLORSPACECONVERSIONPARAMS, EnumUsage.Input);

            csp.setXMLComment("This ColorSpaceConversionParams treats Acme and Bcme cameras the same but differentiates for Ccme");
            JDFColorSpaceConversionOp op1 = csp.appendColorSpaceConversionOp();

            op1.setAttribute("ObjectTags", "Acme Bcme");
            JDFColorSpaceConversionOp op2 = csp.appendColorSpaceConversionOp();

            op2.setAttribute("ObjectTags", "Ccme");
            doc.write2File(sm_dirTestDataTemp + "objectTags.jdf", 2, false);
        }
Beispiel #13
0
        ///
        ///	 <summary> * For KElement 'elem' takes information from parent and children about
        ///	 * original and corrected CapXPaths, compare them and set CapXPath as a
        ///	 * complete path to this element.<br>
        ///	 * Checks CapXPath's for every InvalidResource element of the given XMLDoc
        ///	 * and all children (of arbitrary depth). Appends right ancestors if
        ///	 * CapXPath is not complete.<br>
        ///	 *  </summary>
        ///	 * <param name="elem">
        ///	 *            "pool" element like "InvalidElements" or "InvalidAttributes".<br>
        ///	 *            From this element we have access to its parent and children
        ///	 *            and can compare their CapXPath's </param>
        ///	 * <param name="originalPath">
        ///	 *            parent CapXPath before correction. </param>
        ///
        private static void capXPathCorrection_Static(KElement elem, string originalPath)
        {
            string parentPath = elem.getParentNode_KElement().getAttribute("CapXPath");

            VElement vEl = elem.getChildElementVector(null, null, null, true, 0, false);

            for (int i = 0; i < vEl.Count; i++)
            {
                KElement child     = (KElement)vEl[i];
                string   childPath = child.getAttribute("CapXPath");

                if (!parentPath.Equals(JDFConstants.EMPTYSTRING) && !childPath.Equals(JDFConstants.EMPTYSTRING))
                {
                    string childPathPart = childPath;
                    if (childPath.StartsWith(originalPath))
                    {
                        childPathPart = childPath.Substring(originalPath.Length + 1); // +1 removes
                        // "/"
                    }
                    child.setAttribute("CapXPath", parentPath + "/" + childPathPart);

                    // recursion to set everywhere the right CapXPath
                    VElement vSubEl = child.getChildElementVector(null, null, null, true, 0, false);
                    for (int j = 0; j < vSubEl.Count; j++)
                    {
                        capXPathCorrection_Static(vSubEl[j], childPath);
                    }
                }
            }
            return;
        }
Beispiel #14
0
        ///
        ///	 <summary> * devCapReport - tests if the elements in vElem fit any (logical OR) DevCap
        ///	 * element that DevCaps consists of. Composes a detailed report in XML form
        ///	 * of the errors found. If XMLDoc is null there are no errors.<br>
        ///	 *
        ///	 * DevCaps will be checked if they are direct children of <code>this</code>
        ///	 * and referenced in DevCapPool.
        ///	 *  </summary>
        ///	 * <param name="vElem">
        ///	 *            vector of the elements to test </param>
        ///	 * <param name="testlists">
        ///	 *            testlists that are specified for the State elements
        ///	 *            (FitsValue_Allowed or FitsValue_Present)<br>
        ///	 *            Will be used in fitsValue method of the State element. </param>
        ///	 * <param name="level">
        ///	 *            validation level </param>
        ///	 * <returns> XMLDoc - XMLDoc output of the error messages.<br>
        ///	 *         If XMLDoc is null there are no errors, every element of vElem
        ///	 *         fits any DevCap element of <code>this</code>. </returns>
        ///	 * <exception cref="JDFException">
        ///	 *             if DevCaps/@DevCapRef refers to the DevCap elements in a
        ///	 *             non-existent DevCapPool </exception>
        ///	 * <exception cref="JDFException">
        ///	 *             if DevCaps/@DevCapRef refers to the non-existent DevCap </exception>
        ///
        public KElement devCapReport(KElement elem, EnumFitsValue testlists, EnumValidationLevel level, bool ignoreExtensions, KElement parentReport)
        {
            if (elem == null)
            {
                return(null);
            }
            VElement dcV = getDevCapVector();

            if (dcV == null || dcV.Count == 0)
            {
                throw new JDFException("JDFDevCaps.devCapReport: Invalid DeviceCap: DevCaps/@DevCapRef refers to the non-existent DevCap: " + getDevCapRef());
            }

            KElement r = parentReport.appendElement("Invalid" + getContext().getName());

            for (int i = 0; i < dcV.Count; i++)
            {
                JDFDevCap dc = (JDFDevCap)dcV[i];
                KElement  stateTestResult = dc.stateReport(elem, testlists, level, ignoreExtensions, true, r);
                if (stateTestResult == null)
                {
                    r.deleteNode();
                    return(null); // first DevCap that fits found -> erase all error
                    // messages
                }
                r.setAttribute("XPath", elem.buildXPath(null, 1));
                r.setAttribute("Name", getContextName());
                r.setAttribute("CapXPath", dc.getName());
            }

            correction_Static(r);
            return(r);
        }
Beispiel #15
0
        public virtual void testValidateCombined()
        {
            JDFDoc       doc      = new JDFDoc("JDF");
            JDFValidator checkJDF = new JDFValidator();

            checkJDF.setPrint(false);
            checkJDF.bQuiet = true;
            JDFNode n = doc.getJDFRoot();

            n.setType(EnumType.Combined);
            int v = 0;

            while (true)
            {
                checkJDF.level = EnumValidationLevel.getEnum(v);
                if (checkJDF.level == null)
                {
                    break;
                }
                for (int i = 0; i < 3; i++)
                {
                    if (i >= 1)
                    {
                        doc = null;
                    }
                    XMLDoc   schemaValidationResult = checkJDF.processSingleDocument(doc);
                    KElement root = schemaValidationResult.getRoot();
                    Assert.IsNotNull(root.getXPathElement("TestFile/SchemaValidationOutput"));
                    Assert.IsNotNull(root.getXPathElement("TestFile/CheckJDFOutput"));
                    Assert.AreEqual(root.getXPathAttribute("TestFile/CheckJDFOutput/@IsValid", "booboo"), "true");
                }
                v++;
            }
        }
Beispiel #16
0
        public virtual void testValidatePrivateDoc()
        {
            JDFDoc       doc      = new JDFDoc("JDF");
            JDFValidator checkJDF = new JDFValidator();

            checkJDF.setPrint(false);
            checkJDF.bQuiet = true;
            checkJDF.level  = EnumValidationLevel.Incomplete;
            JDFNode n = doc.getJDFRoot();

            checkJDF.setIgnorePrivate(true);

            n.setAttribute("foo:bar", "foobar", "www.foo.cpm");
            XMLDoc   schemaValidationResult = checkJDF.processSingleDocument(doc);
            KElement root = schemaValidationResult.getRoot();

            Assert.AreEqual(root.getXPathAttribute("TestFile/CheckJDFOutput/@IsValid", "booboo"), "true");

            n.removeAttribute("bar", "www.foo.cpm");
            n.appendElement("foo:bar", "www.foo.cpm");
            schemaValidationResult = checkJDF.processSingleDocument(doc);
            root = schemaValidationResult.getRoot();
            Assert.AreEqual(root.getXPathAttribute("TestFile[2]/CheckJDFOutput/@IsValid", "booboo"), "true");

            n.setAttribute("jdfbar", "thisbebad");
            schemaValidationResult = checkJDF.processSingleDocument(doc);
            root = schemaValidationResult.getRoot();
            Assert.AreEqual(root.getXPathAttribute("TestFile[3]/CheckJDFOutput/@IsValid", "booboo"), "false");

            n.removeAttribute("jdfbar", null);
            n.appendElement("jdfbar", null);
            schemaValidationResult = checkJDF.processSingleDocument(doc);
            root = schemaValidationResult.getRoot();
            Assert.AreEqual(root.getXPathAttribute("TestFile[4]/CheckJDFOutput/@IsValid", "booboo"), "false");
        }
Beispiel #17
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);
        }
Beispiel #18
0
 ///
 ///	 <summary> * get resource defined by <code>resNam</code>
 ///	 *  </summary>
 ///	 * <param name="resName"> name of the resource to get, if null get the one and only resource </param>
 ///	 * <returns> JDFResource the element, null if none exists </returns>
 ///
 public virtual JDFResource getResource(string resName)
 {
     if (resName != null)
     {
         KElement e = getElement(resName, null, 0);
         if (e is JDFResource)
         {
             return((JDFResource)e);
         }
     }
     else
     {
         string resName2 = getResourceName();
         if (resName2 != null && !resName2.Equals(""))
         {
             return(getResource(resName2));
         }
         KElement e2 = getFirstChildElement();
         while (e2 != null)
         {
             if (e2 is JDFResource)
             {
                 return((JDFResource)e2);
             }
             e2 = e2.getNextSiblingElement();
         }
     }
     return(null);
 }
Beispiel #19
0
 ///
 ///	 <summary> * if this is a new layout, return the partition key signaturename else return Signature/@Name of this or its
 ///	 * appropriate parent
 ///	 *  </summary>
 ///	 * <returns> the name of the signature </returns>
 ///
 public override string getSignatureName()
 {
     if (LocalName.Equals(ElementName.SIGNATURE))
     {
         return(getName());
     }
     if (LocalName.Equals(ElementName.SHEET))
     {
         KElement parentNode = getParentNode_KElement();
         if (parentNode is JDFSignature)
         {
             JDFSignature sig = (JDFSignature)parentNode;
             return(sig.getSignatureName());
         }
     }
     else if (LocalName.Equals(ElementName.SURFACE))
     {
         KElement parentNode = getParentNode_KElement().getParentNode_KElement();
         if (parentNode is JDFSignature)
         {
             JDFSignature sig = (JDFSignature)parentNode;
             return(sig.getSignatureName());
         }
     }
     return(base.getSignatureName());
 }
Beispiel #20
0
        ///
        ///	 <summary> * append ResourceLink
        ///	 *  </summary>
        ///	 * <param name="linkName"> name of the ResourceLink to append a link for </param>
        ///	 * <param name="bInput"> if true, the link is an input link </param>
        ///	 * <returns> JDFResourceLink: the appended element </returns>
        ///
        public virtual JDFResourceLink appendResourceLink(string linkName, bool bInput)
        {
            string linkNameLocal = linkName;

            if (!linkNameLocal.EndsWith("Link"))
            {
                linkNameLocal += "Link";
            }

            JDFResourceLink rl = null;

            if (getResourceLink() != null)
            {
                throw new JDFException("JDFpipeParams.appendResourceLink tried to append an additional link");
            }

            KElement e = appendElement(linkNameLocal, null);

            if (e is JDFResourceLink)
            {
                rl = (JDFResourceLink)e;
                rl.setUsage(bInput ? EnumUsage.Input : EnumUsage.Output);
            }
            else
            {
                throw new JDFException("JDFpipeParams.appendResourceLink tried to return a JDFElement instead of a JDFResourceLink: " + linkNameLocal);
            }

            return(rl);
        }
Beispiel #21
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);
        }
        public void testSeparationList()
        {
            JDFDoc          doc     = new JDFDoc("JDF");
            JDFNode         root    = doc.getJDFRoot();
            JDFResourcePool resPool = root.getCreateResourcePool();
            KElement        kElem   = resPool.appendResource(ElementName.COLORANTCONTROL, null, null);

            Assert.IsTrue(kElem is JDFColorantControl);
            JDFColorantControl cc   = ((JDFColorantControl)kElem);
            JDFSeparationList  co   = cc.appendColorantOrder();
            VString            seps = new VString(StringUtil.tokenize("Cyan Magenta Yellow Black", " ", false));

            co.setSeparations(seps);
            CollectionAssert.AreEqual(co.getSeparations(), seps);
            VElement vSepSpec = co.getChildElementVector(ElementName.SEPARATIONSPEC, null, null, true, 0, true);

            Assert.AreEqual(seps.Count, vSepSpec.Count);
            for (int i = 0; i < vSepSpec.Count; i++)
            {
                Assert.IsFalse(vSepSpec.item(i).hasAttribute(AttributeName.CLASS));
                Assert.IsFalse(vSepSpec.item(i) is JDFResource);
            }

            Assert.AreEqual("Cyan", co.getSeparation(0));
            co.removeSeparation("Magenta");
            Assert.AreEqual("Cyan", co.getSeparation(0));
            Assert.AreEqual("Yellow", co.getSeparation(1));
            Assert.AreEqual("Black", co.getSeparation(2));
            Assert.IsNull(co.getSeparation(3));
        }
Beispiel #23
0
        ///
        ///	 <summary> * get resource defined by <code>resName</code>
        ///	 *  </summary>
        ///	 * <param name="resName"> name of the resource to get; if null get the resource that is linked by the reslink </param>
        ///	 * <returns> JDFResource: the element </returns>
        ///
        public virtual JDFResource getResource(string resName)
        {
            if (resName == null)
            {
                JDFResourceLink rl = getResourceLink();
                if (rl != null)
                {
                    return(rl.getTarget());
                }
                VElement v = getChildElementVector(null, null, null, true, 0, false);

                for (int i = 0; i < v.Count; i++)
                {
                    KElement e = v.item(i);
                    if (e is JDFResource)
                    {
                        return((JDFResource)e);
                    }
                }
                return(null);
            }
            JDFResource r  = null;
            KElement    e2 = getElement(resName, null, 0);

            if (e2 is JDFResource)
            {
                r = (JDFResource)e2;
            }
            else
            {
                throw new JDFException("JDFPipeParams.getResource tried to return a JDFElement instead of a JDFResource");
            }
            return(r);
        }
Beispiel #24
0
        public virtual void testIsPresentPartition()
        {
            JDFAction act = devicecap.appendActionPool().appendActionTest(EnumTerm.IsPresentEvaluation, true);
            JDFTest   tst = act.getTest();

            tst.setContext("//Component");
            JDFIsPresentEvaluation ipe = (JDFIsPresentEvaluation)tst.getTerm();

            ipe.setRefTarget(ptState);
            Assert.AreEqual(ptState.getID(), ipe.getrRef());

            JDFDoc  doc  = new JDFDoc("JDF");
            JDFNode node = doc.getJDFRoot();

            node.setType("fnarf", false);
            JDFComponent comp = (JDFComponent)node.addResource("Component", null, EnumUsage.Input, null, null, null, null);

            comp.setProductType("Cover");

            XMLDoc   rep     = new XMLDoc("root", null);
            KElement eRep    = rep.getRoot();
            bool     fitsJDF = tst.fitsJDF(comp, eRep);

            Assert.IsTrue(fitsJDF);
            comp    = (JDFComponent)comp.addPartition(EnumPartIDKey.SheetName, "s1");
            fitsJDF = tst.fitsJDF(comp, eRep);
            Assert.IsTrue(fitsJDF, "also partition leaves ");
        }
Beispiel #25
0
        public void testSetGetDimension()
        {
            JDFDoc          doc     = new JDFDoc("JDF");
            JDFNode         root    = doc.getJDFRoot();
            JDFResourcePool resPool = root.getCreateResourcePool();
            KElement        kElem   = resPool.appendResource(ElementName.MEDIA, EnumResourceClass.Consumable, null);

            Assert.IsTrue(kElem is JDFMedia);
            JDFMedia media = ((JDFMedia)kElem);

            media.setDimensionCM(new JDFXYPair(2.54, 2.54));

            JDFXYPair result = media.getDimension();

            Assert.AreEqual(new JDFXYPair(72, 72), result);

            result = media.getDimensionCM();
            Assert.AreEqual(new JDFXYPair(2.54, 2.54), result);

            result = media.getDimensionInch();
            Assert.AreEqual(new JDFXYPair(1, 1), result);

            media.setDimensionInch(new JDFXYPair(1, 1));

            result = media.getDimension();
            Assert.AreEqual(new JDFXYPair(72, 72), result);

            result = media.getDimensionCM();
            Assert.AreEqual(new JDFXYPair(2.54, 2.54), result);

            result = media.getDimensionInch();
            Assert.AreEqual(new JDFXYPair(1, 1), result);
        }
Beispiel #26
0
        public virtual void testValidateJMF()
        {
            // Write temp JMF
            string   jmf     = "<?xml version='1.0' encoding='UTF-8'?><JMF xmlns='http://www.CIP4.org/JDFSchema_1_1' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'  SenderID='Alces' TimeStamp='2004-08-30T17:23:00+01:00' Version='1.2'><Query ID='M001' Type='KnownDevices' xsi:type='QueryKnownDevices'><DeviceFilter DeviceDetails='None'/></Query></JMF>";
            FileInfo jmfFile = new FileInfo(Path.Combine(Path.GetTempPath(), "Query-KnownDevices.jmf"));

            SupportClass.FileSupport.CreateNewFile(jmfFile);
            // jmfFile.deleteOnExit();
            StreamWriter @out = new StreamWriter(new FileStream(jmfFile.FullName, FileMode.Open));

            @out.Write(jmf);
            @out.Close();
            jmfFile.Refresh();
            Assert.IsTrue(jmfFile.Exists);

            FileInfo reportFile = new FileInfo(Path.Combine(Path.GetTempPath(), "Queue-KnownDevices-report.xml"));

            SupportClass.FileSupport.CreateNewFile(reportFile);
            // reportFile.deleteOnExit();

            // Run JDFValidator
            string[] args    = { jmfFile.FullName, "-cq", "-x " + reportFile.FullName };
            CheckJDF checker = new CheckJDF();
            XMLDoc   d       = checker.validate(args, null);
            KElement dRoot   = d.getRoot();

            Assert.AreEqual("true", dRoot.getXPathAttribute("/CheckOutput/TestFile/CheckJDFOutput/@IsValid", null));

            // Check that report exists
            reportFile.Refresh();
            Assert.IsTrue(reportFile.Exists);
            jmfFile.Delete();
            reportFile.Delete();
        }
Beispiel #27
0
 ///
 ///	 <summary> * check whether the boolean logic defined by a Test and a test's
 ///	 * subelements makes sense in the context of the tested element jdf </summary>
 ///
 public override bool fitsContext(KElement testElement)
 {
     if (hasAttribute(AttributeName.CONTEXT))
     {
         return(testElement.matchesPath(getContext(), true));
     }
     return(base.fitsContext(testElement));
 }
Beispiel #28
0
        public virtual void testValidateZip()
        {
            FileInfo     zip     = new FileInfo(sm_dirTestData + "checkjdf.zip");
            JDFValidator checker = new JDFValidator();
            XMLDoc       d       = checker.processZipFile(zip);
            KElement     root    = d.getRoot();

            Assert.AreEqual(17, root.numChildElements("TestFile", null), "checkJDF.zip has 17 files");
        }
Beispiel #29
0
        public static KElement appendRefAnchor(JDFMarkObject mark0, string anchor, string anchorType, string rRef)
        {
            KElement refAnchor = mark0.getCreateElement("RefAnchor", null, 0);

            refAnchor.setAttribute("Anchor", anchor);
            refAnchor.setAttribute("AnchorType", anchorType);
            refAnchor.setAttribute("rRef", rRef);
            return(refAnchor);
        }
Beispiel #30
0
        ///
        ///	 <summary> * increment occurrences by i if this lives in a standard preflight report
        ///	 * tree, also increment the appropriate higher up counters
        ///	 *  </summary>
        ///	 * <param name="i"> </param>
        ///
        public virtual void addOccurrences(int i, EnumSeverity sev)
        {
            addAttribute(AttributeName.OCCURRENCES, i, null);
            KElement e = getParentNode_KElement();

            if (e is JDFPreflightReport)
            {
                ((JDFPreflightReport)e).addOccurrences(i, sev);
            }
        }