/// /// <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); }
// // * (non-Javadoc) // * // * @see org.cip4.jdflib.core.JDFElement#getInvalidAttributes(org.cip4.jdflib. core.KElement.EnumValidationLevel, // * boolean, int) // public override VString getInvalidAttributes(EnumValidationLevel level, bool bIgnorePrivate, int nMax) { VString v = base.getInvalidAttributes(level, bIgnorePrivate, nMax); JDFResourceLink rl = (JDFResourceLink)getDeepParentChild(ElementName.RESOURCELINKPOOL); if (rl != null) { JDFAttributeMap rlMap = rl.getAttributeMap(); if (rlMap != null) { JDFAttributeMap map = getAttributeMap(); if (map != null) { IEnumerator <string> it = map.getKeyIterator(); while (it.MoveNext()) { string s = it.Current; if (rlMap.ContainsKey(s)) { v.Add(s); } } } } } return(v); }
/// /// <summary> * typesafe validator /// * </summary> /// * <param name="EnumValidationLevel"> /// * level validation level </param> /// * <returns> boolean true if this is valid </returns> /// public override bool isValid(EnumValidationLevel level) { bool bValid = base.isValid(level); if (!bValid) { return(false); } bValid = getDuplicateColors() == null; return(bValid); }
// // * (non-Javadoc) // * // * @see // * org.cip4.jdflib.core.JDFElement#getInvalidAttributes(org.cip4.jdflib. // * core.KElement.EnumValidationLevel, boolean, int) // protected internal virtual VString getInvalidAttributesImpl(EnumValidationLevel level, bool bIgnorePrivate, int nMax) { VString v = base.getInvalidAttributes(level, bIgnorePrivate, nMax); if (nMax > 0 && v.Count >= nMax) { return(v); } if (!fitsListType(getAttribute(AttributeName.DEFAULTVALUE))) { v.appendUnique(AttributeName.DEFAULTVALUE); } if (!fitsListType(getAttribute(AttributeName.CURRENTVALUE))) { v.appendUnique(AttributeName.CURRENTVALUE); } return(v); }
public override VString getInvalidElements(EnumValidationLevel level, bool bIgnorePrivate, int nMax) { bool bIgnorePrivateLocal = bIgnorePrivate; if (bIgnorePrivateLocal) { bIgnorePrivateLocal = false; // dummy to fool compiler } VString v = base.getInvalidElements(level, bIgnorePrivateLocal, nMax); if (v.Count >= nMax) { return(v); } v.appendUnique(getInvalidTerms(1)); return(v); }
public override VString getInvalidElements(EnumValidationLevel level, bool bIgnorePrivate, int nMax) { bool bIgnorePrivateLocal = bIgnorePrivate; if (bIgnorePrivateLocal) { bIgnorePrivateLocal = false; // dummy to fool compiler } VString v = base.getInvalidElements(level, bIgnorePrivateLocal, nMax); if (v.Count >= nMax) { return(v); } VElement v2 = getChildElementVector_KElement(null, null, null, true, 0); int n = 0; int size = v2.Count; for (int i = 0; i < size; i++) { if (v2[i] is JDFRefElement) { n++; } } if (n > 1) { for (int i = 0; i < size; i++) { if (v2[i] is JDFRefElement) { v.appendUnique(v2[i].LocalName); } } } return(v); }
/// /// <summary> * Method getInvalidElements /// * <p> /// * default: GetInvalidElements(level, true, 999999) /// * </summary> /// * <param name="level"> validation level </param> /// * <param name="bIgnorePrivate"> </param> /// * <param name="nMax"> maximum number of elements to get /// * </param> /// * <returns> VString - vector of names of invalid elements </returns> /// public override VString getInvalidElements(EnumValidationLevel level, bool bIgnorePrivate, int nMax) { VString s = getInvalidElements_JDFElement(level, bIgnorePrivate, nMax); if (s.Count > nMax || hasAttribute(AttributeName.RESOURCENAME)) // multiple // are // allowed // with // resourcename // set { return(s); } VElement v = getChildElementVector(null, null, null, true, 0, false); int size = v.Count; if (size > 1) { // remove anything but resources for (int i = size - 1; i >= 0; i--) { if (!(v[i] is JDFResource)) { v.RemoveAt(i); } } size = v.Count; // must refresh size due to removes // more than one resource --> evil! if (size > 1) { for (int j = 0; j < size; j++) { s.appendUnique(v.item(j).LocalName); } } } return(s); }
// // * (non-Javadoc) // * // * @see // * org.cip4.jdflib.core.JDFElement#getInvalidAttributes(org.cip4.jdflib. // * core.KElement.EnumValidationLevel, boolean, int) // public override VString getInvalidAttributes(EnumValidationLevel level, bool bIgnorePrivate, int nMax) { VString vs = base.getInvalidAttributes(level, bIgnorePrivate, nMax); if (nMax > 0 && vs.Count > nMax) { return(vs); } if (!EnumValidationLevel.RecursiveComplete.Equals(level) && !EnumValidationLevel.RecursiveIncomplete.Equals(level)) { return(vs); } if (vs.Contains(AttributeName.DEVCAPREF)) { return(vs); } if (hasAttribute(AttributeName.DEVCAPREF)) { JDFDevCapPool devCapPool = getDevCapPool(); if (devCapPool == null) { vs.Add(AttributeName.DEVCAPREF); return(vs); } VString idRefs = getDevCapRef(); for (int i = 0; i < idRefs.Count; i++) { JDFDevCap devCap = devCapPool.getDevCap(idRefs.stringAt(i)); if (devCap == null) { vs.Add(AttributeName.DEVCAPREF); return(vs); } } } return(vs); }
public override VString getInvalidElements(EnumValidationLevel level, bool bIgnorePrivate, int nMax) { VString vElem = new VString(); int n = 0; int nElem = numChildElements(ElementName.FILESPEC, null); for (int i = 0; i < nElem; i++) { string ru = getFileSpec(i).getResourceUsage(); if (!ru.Equals("SearchPath")) { vElem.appendUnique(ElementName.FILESPEC); if (++n >= nMax) { return(vElem); } break; } } vElem.appendUnique(getInvalidElements(level, bIgnorePrivate, (nMax - n))); return(vElem); }
public override bool isValid(EnumValidationLevel level) { bool b = base.isValid(level); if (!b) { return(false); } JDFResource r = getTarget(); if (r == null) { return(false); } if (!Name.Equals(r.getRefString())) { return(false); } if (!validResourcePosition()) { return(false); } // RunLists and physical resources may be referenced at the root or // intermediate nodes // if((r.getPartUsage() != JDFResource.EnumPartUsage.Explicit) && // !r.isLeaf()) // { // return false; // } return(true); }
public override VString getInvalidAttributes(EnumValidationLevel level, bool bIgnorePrivate, int nMax) { return(getInvalidAttributesImpl(level, bIgnorePrivate, nMax)); }
/// /// <summary> * Composes a BugReport in XML form for the given JDFNode 'jdfRoot'. Gives a list of error messages for 'jdfRoot' /// * and every child rejected Node.<br> /// * Returns <code>null</code> if there are no errors. /// * </summary> /// * <param name="jdfRoot"> the node 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 class. </param> /// * <param name="level"> validation level </param> /// * <returns> XMLDoc - XMLDoc output of the error messages. If XMLDoc is null there are no errors. </returns> /// public XMLDoc getBadJDFInfo(JDFNode jdfRoot, EnumFitsValue testlists, EnumValidationLevel level) { VElement vDC = getChildElementVector(ElementName.DEVICECAP, null, null, true, -1, false); if (vDC == null || vDC.IsEmpty()) { return(null); } VElement vn = new VElement(); for (int i = 0; i < vDC.Count; i++) { JDFDeviceCap dc = (JDFDeviceCap)vDC[i]; XMLDoc bugReport = dc.getBadJDFInfo(jdfRoot, testlists, level); if (bugReport == null) { return(null); } vn.addAll(bugReport.getRoot().getChildElementVector(null, null, null, true, -1, false)); } int vnSize = vn.Count; if (vnSize == 0) { return(null); } XMLDoc bugReport2 = new XMLDoc("BugReport", null); KElement root = bugReport2.getRoot(); bool bFit = false; for (int i = 0; i < vnSize; i++) { KElement e = vn[i]; if (JDFConstants.TRUE.Equals(e.getAttribute(JDFDeviceCap.FITS_TYPE))) { bFit = true; } } if (bFit) { for (int i = 0; i < vnSize; i++) { KElement e = vn[i]; if (JDFConstants.FALSE.Equals(e.getAttribute(JDFDeviceCap.FITS_TYPE))) { vn[i] = null; } } } for (int i = 0; i < vnSize; i++) { if (vn[i] != null) { root.moveElement(vn.item(i), null); } } return(bugReport2); }
/// /// <summary> * Gets of jdfRoot a vector of all executable nodes (jdf root or children nodes that this Device may execute) /// * </summary> /// * <param name="jdfRoot"> the node we 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 class. </param> /// * <param name="level"> validation level </param> /// * <returns> VElement - vector of executable JDFNodes </returns> /// public virtual VElement getExecutableJDF(JDFNode docRoot, EnumFitsValue testlists, EnumValidationLevel validationLevel) { VElement vDC = getChildElementVector(ElementName.DEVICECAP, null, null, true, -1, false); if (vDC == null || vDC.IsEmpty()) { return(null); } VElement vn = new VElement(); for (int i = 0; i < vDC.Count; i++) { JDFDeviceCap dc = (JDFDeviceCap)vDC[i]; VElement executableJDF = dc.getExecutableJDF(docRoot, testlists, validationLevel); if (executableJDF != null) { vn.addAll(executableJDF); } } vn.unify(); return(vn.IsEmpty() ? null : vn); }
/// /// * <param name="testRoot"> </param> /// * <param name="testlists"> </param> /// * <param name="level"> </param> /// * <param name="mrp"> </param> /// * <param name="irp"> </param> /// * <param name="resLinkPool"> </param> /// * <param name="goodElems"> </param> /// * <param name="badElems"> </param> /// * <param name="devCaps"> /// * @return </param> /// public virtual void analyzeDevCaps(KElement testRoot, EnumFitsValue testlists, EnumValidationLevel level, KElement mrp, KElement irp, SupportClass.HashSetSupport goodElems, Hashtable badElems, bool ignoreExtensions) { EnumAvailability av = getModuleAvailability(); KElement xpathRoot = testRoot; VElement vElemResources = null; if (testRoot is JDFNode) { JDFNode jdfNode = (JDFNode)testRoot; vElemResources = getMatchingElementsFromNode(jdfNode); xpathRoot = jdfNode.getResourceLinkPool(); if (xpathRoot == null) { xpathRoot = testRoot; } } else { vElemResources = getMatchingElementsFromJMF((JDFMessage)testRoot); } int svElemResources = vElemResources == null ? 0 : vElemResources.Count; EnumContext context = getContext(); KElement r = null; if (EnumValidationLevel.isRequired(level) && svElemResources < getMinOccurs() && EnumAvailability.Installed.Equals(av)) { if (EnumContext.Element.Equals(context) || EnumContext.JMF.Equals(context)) { r = mrp.appendElement("MissingElement"); r.setAttribute("XPath", xpathRoot.buildXPath(null, 1) + "/" + getName()); } else { EnumUsage linkUsage = getLinkUsage(); string procUsage = getProcessUsage(); r = mrp.appendElement("MissingResourceLink"); if (linkUsage != null) { r.setAttribute("Usage", linkUsage.getName()); } if (procUsage != null && procUsage.Length > 0) { r.setAttribute("ProcessUsage", procUsage); } r.setAttribute("XPath", xpathRoot.buildXPath(null, 1) + "/" + getName()); } r.setAttribute("Name", getName()); r.setAttribute("CapXPath", getName()); r.setAttribute("Occurrences", svElemResources, null); r.setAttribute("MinOccurs", getMinOccurs(), null); } else if (svElemResources > getMaxOccurs() || !EnumAvailability.Installed.Equals(av)) { if (context.Equals(EnumContext.Element) || context.Equals(EnumContext.JMF)) { r = irp.appendElement("ManyElement"); r.setAttribute("XPath", testRoot.buildXPath(null, 1) + "/" + getName()); } else { EnumUsage linkUsage = getLinkUsage(); string procUsage = getProcessUsage(); r = irp.appendElement("ManyResourceLink"); if (linkUsage != null) { r.setAttribute("Usage", linkUsage.getName()); } if (procUsage != null && procUsage.Length > 0) { r.setAttribute("ProcessUsage", procUsage); } r.setAttribute("XPath", xpathRoot.buildXPath(null, 1) + "/" + getName()); } r.setAttribute("Name", getName()); r.setAttribute("CapXPath", getName()); r.setAttribute("Occurrences", svElemResources, null); r.setAttribute("MaxOccurs", getMaxOccurs(), null); r.setAttribute("Availability", av == null ? "None" : av.getName()); } if (vElemResources != null) { for (int j = 0; j < svElemResources; j++) { KElement elem = vElemResources.item(j); if (!goodElems.Contains(elem)) { KElement report = devCapReport(elem, testlists, level, ignoreExtensions, irp); // InvalidResources if (report == null) { goodElems.Add(elem); KElement badReport = (KElement)badElems[elem]; if (badReport != null) { badReport.deleteNode(); } } else { badElems.Add(elem, report); } } } } }