// // * (non-Javadoc) // * // * @see // * org.cip4.jdflib.resource.devicecapability.JDFAbstractState#addValue(java // * .lang.String, org.cip4.jdflib.datatypes.JDFBaseDataTypes.EnumFitsValue) // public override void addValue(string @value, EnumFitsValue testlists) { if (fitsValue(@value, testlists)) { return; } EnumBoolean b = EnumBoolean.getEnum(@value); if (b == null) { return; } if (testlists == null || EnumFitsValue.Allowed.Equals(testlists)) { List <ValuedEnum> list = getAllowedValueList(); if (list == null) { list = new List <ValuedEnum>(); } list.Add(b); setAllowedValueList(list); } if (testlists == null || EnumFitsValue.Present.Equals(testlists)) { List <ValuedEnum> list = getPresentValueList(); if (list == null || !hasAttribute(AttributeName.PRESENTVALUELIST)) { list = new List <ValuedEnum>(); } list.Add(b); setPresentValueList(list); } }
/// /// <summary> * fitsValueElem - checks whether <code>pdfPath</code> matches the /// * subelement <code>Value</code> specified for this State /// * </summary> /// * <param name="pdfPath"> /// * PDFPath to test </param> /// * <param name="valueusage"> /// * switches between Allowed and Present configuration in /// * subelement <code>Value</code>. /// * </param> /// * <returns> boolean - true, if <code>pdfPath</code> matches subelement /// * <code>Value</code> </returns> /// private bool fitsValueElem(string pdfPath, EnumFitsValue valuelist) { VElement v = getChildElementVector(ElementName.VALUE, null, null, true, 0, false); int siz = v.Count; bool hasValue = false; for (int i = 0; i < siz; i++) { JDFValue elm = (JDFValue)v[i]; if (elm.hasAttribute(AttributeName.VALUEUSAGE)) { EnumFitsValue valueUsage = getValueValueUsage(i); if (valuelist.Equals(valueUsage)) { hasValue = true; string @value = getValueAllowedValue(i); if (@value.CompareTo(pdfPath) == 0) { return(true); // we have found it } } } else { hasValue = true; string @value = getValueAllowedValue(i); if (@value.CompareTo(pdfPath) == 0) { return(true); // we have found it } } } return(!hasValue); }
// // * // Element getter / setter // // // * (non-Javadoc) // * // * @see // * org.cip4.jdflib.resource.devicecapability.JDFAbstractState#addValue(java // * .lang.String, org.cip4.jdflib.datatypes.JDFBaseDataTypes.EnumFitsValue) // public override void addValue(string @value, EnumFitsValue testlists) { if (fitsValue(@value, testlists)) { return; } if (testlists == null || EnumFitsValue.Allowed.Equals(testlists)) { VString list = getAllowedValueList(); if (list == null) { list = new VString(); } list.appendUnique(@value); setAllowedValueList(list); } if (testlists == null || EnumFitsValue.Present.Equals(testlists)) { VString list = getPresentValueList(); if (list == null || !hasAttribute(AttributeName.PRESENTVALUELIST)) { list = new VString(); } list.appendUnique(@value); setPresentValueList(list); } }
/// /// <summary> * fitsRotateMod - checks whether matrix matches the AllowedRotateMod or /// * PresentRotateMod, specified for this State /// * </summary> /// * <param name="matrix"> /// * matrix to test </param> /// * <param name="rotatemod"> /// * switches between AllowedRotateMod and PresentRotateMod. </param> /// * <returns> boolean - true, if <code>matrix</code> matches the RotateMod or /// * if AllowedRotateMod is not specified </returns> /// private bool fitsRotateMod(JDFMatrix matrix, EnumFitsValue rotatemod) { if (rotatemod == null || rotatemod.Equals(EnumFitsValue.Allowed)) { if (!hasAttribute(AttributeName.ALLOWEDROTATEMOD)) { return(true); } } else { if (!hasAttribute(AttributeName.ALLOWEDROTATEMOD) && !hasAttribute(AttributeName.PRESENTROTATEMOD)) { return(true); } } double rm; if (rotatemod == null || rotatemod.Equals(EnumFitsValue.Allowed)) { rm = getAllowedRotateMod(); } else { rm = getPresentRotateMod(); } double a = matrix.A; double b = matrix.B; double c = matrix.C; double d = matrix.D; if ((a * d - b * c) == 0) { return(false); } double param = a / Math.Sqrt(Math.Abs(a * d - b * c)); if (((param - JDFBaseDataTypes_Fields.EPSILON) > 1) || ((param + JDFBaseDataTypes_Fields.EPSILON) < -1)) { return(false); } if (param > 1) { param = param - JDFBaseDataTypes_Fields.EPSILON; } if (param < -1) { param = param + JDFBaseDataTypes_Fields.EPSILON; } double fi = Math.Acos(param) * 180 / Math.PI; //0~180 double result = (fi + JDFBaseDataTypes_Fields.EPSILON) - (rm * (int)((fi + JDFBaseDataTypes_Fields.EPSILON) / rm)); double result180 = (fi + 180 + JDFBaseDataTypes_Fields.EPSILON) - (rm * (int)((fi + 180 + JDFBaseDataTypes_Fields.EPSILON) / rm)); return((Math.Abs(result) <= 2 * JDFBaseDataTypes_Fields.EPSILON) || (Math.Abs(result180) <= 2 * JDFBaseDataTypes_Fields.EPSILON)); }
/// /// <summary> * fitsValueList - tests, if the defined 'value' matches the /// * AllowedValueList or the PresentValueList, specified for this State /// * </summary> /// * <param name="value"> /// * token to test </param> /// * <param name="valuelist"> /// * Switches between AllowedValueList and PresentValueList. </param> /// * <returns> boolean - true, if <code>value</code> matches valuelist, or if /// * AllowedValueList is not specified </returns> /// private bool fitsValueList(string @value, EnumFitsValue valuelist) { List <ValuedEnum> v; EnumBoolean eb = EnumBoolean.getEnum(@value); if (eb == null) { return(false); } if (valuelist.Equals(EnumFitsValue.Allowed)) { v = getAllowedValueList(); } else { v = getPresentValueList(); } if (v == null) { return(true); } return(v.Contains(eb)); }
/// /// <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); }
// // * // Element getter / setter // // // * (non-Javadoc) // * // * @see // * org.cip4.jdflib.resource.devicecapability.JDFAbstractState#addValue(java // * .lang.String, org.cip4.jdflib.datatypes.JDFBaseDataTypes.EnumFitsValue) // public override void addValue(string @value, EnumFitsValue testlists) { if (fitsValue(@value, testlists)) { return; } if (!StringUtil.isNumber(@value)) { return; } double d = StringUtil.parseDouble(@value, 0); if (testlists == null || EnumFitsValue.Allowed.Equals(testlists)) { JDFNumberRangeList list = getAllowedValueList(); if (list == null) { list = new JDFNumberRangeList(); } list.Append(d); setAllowedValueList(list); } if (testlists == null || EnumFitsValue.Present.Equals(testlists)) { JDFNumberRangeList list = getPresentValueList(); if (list == null || !hasAttribute(AttributeName.PRESENTVALUELIST)) { list = new JDFNumberRangeList(); } list.Append(d); setPresentValueList(list); } }
/// /// <summary> * fitsValueElem - tests, if JDFMatrix <code>matrix</code> matches /// * subelement Value, specified for this State /// * </summary> /// * <param name="matrix"> /// * JDFMatrix to test </param> /// * <param name="valuelist"> /// * switches between Allowed and Present configuration in /// * subelement Value. /// * </param> /// * <returns> boolean - true, if <code>matrix</code> matches subelement Value </returns> /// private bool fitsValueElem(JDFMatrix matrix, EnumFitsValue valuelist) { VElement v = getChildElementVector(ElementName.VALUE, null, null, true, 0, false); int siz = v.Count; bool hasValue = false; for (int i = 0; i < siz; i++) { JDFValue elm = (JDFValue)v[i]; if (elm.hasAttribute(AttributeName.VALUEUSAGE)) { EnumFitsValue valueUsage = getValueValueUsage(i); if (valuelist.Equals(valueUsage)) { hasValue = true; JDFMatrix @value = getValueAllowedValue(i); if (@value.Equals(matrix)) { return(true); // we have found it } } } else { hasValue = true; JDFMatrix @value = getValueAllowedValue(i); if (@value.Equals(matrix)) { return(true); // we have found it } } } return(!hasValue); // if no matching, there was no filter }
// // * (non-Javadoc) // * // * @see // * org.cip4.jdflib.resource.devicecapability.JDFAbstractState#addValue(java // * .lang.String, org.cip4.jdflib.datatypes.JDFBaseDataTypes.EnumFitsValue) // public override void addValue(string @value, EnumFitsValue testlists) { if (fitsValue(@value, testlists)) { return; } try { new JDFMatrix(@value); } catch (FormatException) { return; // nop for bad values } if (testlists == null || EnumFitsValue.Allowed.Equals(testlists)) { JDFValue v = appendValue(); v.setAllowedValue(@value); if (testlists != null) { v.setValueUsage(EnumValueUsage.Allowed); } } if (EnumFitsValue.Present.Equals(testlists)) { JDFValue v = appendValue(); v.setAllowedValue(@value); if (testlists != null) { v.setValueUsage(EnumValueUsage.Present); } } }
// // * (non-Javadoc) // * // * @see // * org.cip4.jdflib.resource.devicecapability.JDFAbstractState#addValue(java // * .lang.String, org.cip4.jdflib.datatypes.JDFBaseDataTypes.EnumFitsValue) // public override void addValue(string @value, EnumFitsValue testlists) { if (fitsValue(@value, testlists)) { return; } if (testlists == null || EnumFitsValue.Allowed.Equals(testlists)) { JDFValue v = appendValue(); v.setAllowedValue(@value); if (testlists != null) { v.setValueUsage(EnumValueUsage.Allowed); } } if (EnumFitsValue.Present.Equals(testlists)) { JDFValue v = appendValue(); v.setAllowedValue(@value); if (testlists != null) { v.setValueUsage(EnumValueUsage.Present); } } }
/// /// <summary> * fitsValueDurationList - tests, if the duration of the defined /// * <code>rangelist</code> value matchest the ValueDurationList, 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 the duration of the defined rangelist is in /// * <code>valueList</code> or if ValueDurationList is not specified </returns> /// private bool fitsValueDurationList(JDFDateTimeRangeList rangelist, EnumFitsValue valuelist) { JDFDurationRangeList list; if (valuelist.Equals(EnumFitsValue.Allowed)) { list = getAllowedValueDurationList(); } else { list = getPresentValueDurationList(); } if (list == null) { return(true); } int siz = rangelist.Count; for (int i = 0; i < siz; i++) { JDFDateTimeRange range = (JDFDateTimeRange)rangelist[i]; int duration = (int)((range.Right.TimeInMillis - range.Left.TimeInMillis) / 1000); JDFDuration d = new JDFDuration(); d.setDuration(duration); if (!list.inRange(d)) { return(false); } } return(true); }
/// /// <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)); }
/// /// <summary> * fitsValue - checks whether <code>value</code> matches the given test /// * lists /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <param name="testlists"> /// * test lists the value has to match. In this State the test /// * lists are ValueList AND ValueMod.<br> /// * Choose one of two values: FitsValue_Allowed or /// * FitsValue_Present. Defaults to Allowed. /// * </param> /// * <returns> boolean - true, if <code>value</code> matches the testlists or if /// * AllowedValueList and AllowedValueMod are not specified </returns> /// public override bool fitsValue(string @value, EnumFitsValue testlists) { bool testResult = true; if (!fitsListType(@value)) { testResult = false; } else { JDFIntegerRangeList rangelist = null; try { rangelist = new JDFIntegerRangeList(@value); } catch (FormatException) { testResult = false; } if (testResult) { testResult = (fitsValueList(rangelist, testlists) && fitsValueMod(rangelist, testlists)); } } return(testResult); }
/// /// <summary> * fitsValue - checks whether <code>value</code> matches the testlists /// * specified for this State /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <param name="testlists"> /// * the test lists the value has to match. In this State the test /// * lists are ValueList, RegExp.<br> /// * Choose one of two values: FitsValue_Allowed or /// * FitsValue_Present. (Defaults to Allowed) /// * </param> /// * <returns> boolean - true, if the <code>value</code> matches all test lists /// * or if Allowed test lists are not specified </returns> /// public override bool fitsValue(string @value, EnumFitsValue testlists) { if (fitsListType(@value)) { return(fitsValueList(@value, testlists) && fitsRegExp(@value, testlists)); } return(false); }
/// /// <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); }
public virtual void testProcessUsage() { JDFDoc d = new JDFDoc("JDF"); JDFNode n = d.getJDFRoot(); n.setType("fnarf", false); EnumFitsValue testlists = EnumFitsValue.Allowed; EnumValidationLevel level = KElement.EnumValidationLevel.Complete; VElement vExecNodes = devicecap.getExecutableJDF(n, testlists, level); Assert.IsNull(vExecNodes, "missing resources"); JDFLayout lo = (JDFLayout)n.addResource(ElementName.LAYOUT, null, EnumUsage.Input, null, null, null, null); lo.appendContentObject().setCTM(new JDFMatrix("1 0 0 1 0 0")); lo.appendContentObject().setCTM(new JDFMatrix("1 0 0 1 10 20")); JDFRunList rlDoc = (JDFRunList)n.addResource(ElementName.RUNLIST, null, EnumUsage.Input, EnumProcessUsage.Document, null, null, null); vExecNodes = devicecap.getExecutableJDF(n, testlists, level); Assert.IsNotNull(vExecNodes, "no missing resources"); n.addResource(ElementName.RUNLIST, null, EnumUsage.Input, EnumProcessUsage.Marks, null, null, null); vExecNodes = devicecap.getExecutableJDF(n, testlists, level); Assert.IsNotNull(vExecNodes, "no missing resources"); JDFResourceLink rl = n.getLink(rlDoc, null); rl.setUsage(EnumUsage.Output); vExecNodes = devicecap.getExecutableJDF(n, testlists, level); Assert.IsNull(vExecNodes, "no required runlist doc"); rl.setUsage(EnumUsage.Input); vExecNodes = devicecap.getExecutableJDF(n, testlists, level); Assert.IsNotNull(vExecNodes, "no required runlist doc"); JDFDevCaps dcsRLDoc = devicecap.getDevCapsByName("RunList", null, null, EnumProcessUsage.Document, 0); JDFNameState ns = dcsRLDoc.getDevCap().appendNameState("RunTag"); ns.setRequired(true); vExecNodes = devicecap.getExecutableJDF(n, testlists, level); Assert.IsNull(vExecNodes, "incomplete required runlist doc"); ns.setRequired(false); vExecNodes = devicecap.getExecutableJDF(n, testlists, level); Assert.IsNotNull(vExecNodes, "incomplete required runlist doc"); JDFDevCaps dcsRLMarks = devicecap.getDevCapsByName("RunList", null, null, EnumProcessUsage.Marks, 0); JDFNameState nsMarks = dcsRLMarks.getDevCap().appendNameState("PageNames"); nsMarks.setRequired(true); vExecNodes = devicecap.getExecutableJDF(n, testlists, level); Assert.IsNull(vExecNodes, "incomplete required runlist marks"); }
/// /// <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); }
public virtual void testGetExecutableJDF() { string docTest = "MISPrepress_ICS_Minimal.jdf"; string docDevCap = "DevCaps_Product_MISPrepress_ICS_Minimal.jdf"; // parse input file JDFParser p = new JDFParser(); JDFDoc jmfDevCap = p.parseFile(sm_dirTestData + docDevCap); JDFJMF jmfRoot = null; Assert.IsNotNull(jmfDevCap, "Parse of file " + docDevCap + " failed"); jmfRoot = jmfDevCap.getJMFRoot(); Assert.IsNotNull(jmfRoot, "jmfRoot == null Can't start Test"); XMLDoc docOutDevCap = jmfRoot.getOwnerDocument_KElement(); docOutDevCap.write2File(sm_dirTestDataTemp + "_" + docDevCap, 0, true); JDFDoc jdfTest = p.parseFile(sm_dirTestData + docTest); JDFNode jdfRoot = jdfTest.getJDFRoot(); Assert.IsTrue(jdfRoot != null, "jdfRoot is null"); if (jdfRoot != null) { jdfRoot.getOwnerDocument_KElement(); JDFDeviceCap deviceCap = (JDFDeviceCap)jmfRoot.getChildByTagName("DeviceCap", null, 0, null, false, true); EnumFitsValue testlists = EnumFitsValue.Allowed; EnumValidationLevel level = KElement.EnumValidationLevel.Complete; VElement vExecNodes = deviceCap.getExecutableJDF(jdfRoot, testlists, level); if (vExecNodes == null) { Console.WriteLine(docDevCap + ": found No matching JDFNode"); } else { for (int n = 0; n < vExecNodes.Count; n++) { // XMLDoc docExecNodes = ((JDFNode) // vExecNodes.elementAt(n)).getOwnerDocument_KElement(); // docExecNodes.write2File ("temp\\" + "_" + docTest // +"_ExecNode" + (n+1) + // ".jdf", 0); Console.WriteLine(vExecNodes[n]); } } XMLDoc testResult = deviceCap.getBadJDFInfo(jdfRoot, testlists, level); if (testResult != null) { testResult.write2File(sm_dirTestDataTemp + "_BugReport.xml", 0, true); } } }
/// /// <summary> * fitsValueMod - checks whether <code>rangelist</code> matches /// * AllowedValueMod/PresentValueMod, specified for this State /// * </summary> /// * <param name="rangelist"> /// * range list to test </param> /// * <param name="valuemod"> /// * switches between AllowedValueMod and PresentValueMod. /// * </param> /// * <returns> boolean - true, if <code>rangelist</code> matches the /// * <code>valuemod</code> or if AllowedValueMod is not specified </returns> /// private bool fitsValueMod(JDFIntegerRangeList rangelist, EnumFitsValue valuemod) { if (valuemod.Equals(EnumFitsValue.Allowed)) { if (!hasAttribute(AttributeName.ALLOWEDVALUEMOD)) { return(true); } } else { if (!hasAttribute(AttributeName.ALLOWEDVALUEMOD) && !hasAttribute(AttributeName.PRESENTVALUEMOD)) { return(true); } } JDFXYPair mod; if (valuemod.Equals(EnumFitsValue.Allowed)) { mod = getAllowedValueMod(); } else { mod = getPresentValueMod(); } int divi = (int)(mod.X + 0.5); // X - the Modulo int shift = (int)(mod.Y + 0.5); // Y - offset of the // allowed/present value if (divi == 0) // ValueMod can't be "0 x" { return(false); } JDFIntegerList v = rangelist.getIntegerList(); int[] vi = v.getIntArray(); int siz = vi.Length; for (int i = 0; i < siz; i++) { if ((((vi[i] % divi) - shift) % divi) != 0) { return(false); } } return(true); }
/// /// <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 }
// // * // Element Getter / Setter // /// /// <summary> * fitsValue - tests, if the defined value matches the Allowed test lists or /// * Present test lists, specified for this State /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <param name="testlists"> /// * test lists, that the value has to match. In this State there /// * is only one test list - ValueList.<br> /// * Choose one of two values: FitsValue_Allowed or /// * FitsValue_Present. Defaults to Allowed. /// * </param> /// * <returns> boolean - true, if <code>value</code> matches testlists or if /// * AllowedValueList is not specified </returns> /// public override sealed bool fitsValue(string valueStr, EnumFitsValue testlists) { if (fitsListType(valueStr)) { VString @value = new VString(valueStr, null); for (int i = 0; i < @value.Count; i++) { if (!fitsValueList(@value[i], testlists)) { return(false); } } return(true); // if we are here a whole 'valueStr' fits } return(false); }
/// /// <summary> * fitsValue - tests, if the defined value matches Allowed test lists or /// * Present test lists, specified for this State /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <param name="testlists"> /// * test lists, that the value has to match. In this State the /// * test list is ValueList.<br> /// * Choose one of two values: FitsValue_Allowed or /// * FitsValue_Present. (Defaults to Allowed) /// * </param> /// * <returns> boolean - true, if the value matches test list or if /// * AllowedValueList is not specified </returns> /// public sealed override bool fitsValue(string @value, EnumFitsValue testlists) { if (fitsListType(@value)) { JDFDurationRangeList rangelist = null; try { rangelist = new JDFDurationRangeList(@value); } catch (FormatException) { return(false); } return(fitsValueList(rangelist, testlists)); } return(false); // the value doesn't fit ListType attribute of this State }
/// /// <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); }
// // * // FitsValue Methods // /// /// <summary> * fitsValue - checks whether <code>value</code> matches the Allowed test /// * lists or Present test lists specified for this State /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <param name="testlists"> /// * the test lists the value has to match. In this State the test /// * lists are RotateMod, Shift, Transforms and ValueElem.<br> /// * Choose one of two values: FitsValue_Allowed or /// * FitsValue_Present. (Defaults to Allowed) /// * </param> /// * <returns> boolean - true, if the value matches all test lists or if Allowed /// * test lists are not specified </returns> /// public override bool fitsValue(string @value, EnumFitsValue testlists) { VString vs = new VString(@value, JDFConstants.BLANK); int siz = vs.Count; if (siz % 6 != 0) { return(false); } List <JDFMatrix> matrixList = new List <JDFMatrix>(); for (int i = 0; i < siz; i += 6) { VString v = new VString(); v.Capacity = 6; for (int j = 0; j < 6; j++) { v.Add(vs.stringAt(i + j)); } try { JDFMatrix m = new JDFMatrix(StringUtil.setvString(vs, " ", null, null)); matrixList.Add(m); } catch (FormatException) { return(false); } } if (fitsListType(matrixList)) { for (int k = 0; k < matrixList.Count; k++) { JDFMatrix matrix = matrixList[k]; if (!fitsRotateMod(matrix, testlists) || !fitsShift(matrix, testlists) || !fitsTransforms(matrix, testlists) || !fitsValueElem(matrix, testlists)) { return(false); } } return(true); } return(false); }
/// /// <summary> * fitsValue - checks whether <code>value</code> matches the Allowed/Present /// * test lists specified for this State /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <param name="testlists"> /// * the test lists the value has to match. In this State the test /// * lists are ValueList and HWRelation.<br> /// * Choose one of two values: FitsValue_Allowed or /// * FitsValue_Present. (Defaults to Allowed) /// * </param> /// * <returns> boolean - true, if <code>value</code> matches testlists or if /// * AllowedValueList and AllowedValueMod are not specified </returns> /// public sealed override bool fitsValue(string @value, EnumFitsValue testlists) { if (fitsListType(@value)) { JDFRectangleRangeList rrl = null; try { rrl = new JDFRectangleRangeList(@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 HWRelation // In this case test of deliminators is sufficient for // evaluation of the whole range JDFRectangleRange range = (JDFRectangleRange)rrl[i]; JDFRectangle left = range.Left; JDFRectangle right = range.Right; bool bFitsHW; if (left.Equals(right)) { bFitsHW = fitsHWRelation(left, testlists); } else { bFitsHW = fitsHWRelation(left, testlists) && fitsHWRelation(right, testlists); } if (!bFitsHW) { return(false); } } return(fitsValueList(rrl, testlists)); // if we are here bFitsHW is // true, test ValueList } return(false); // the value doesn't fit ListType attribute of this State }
/// /// <summary> * fitsLength - tests, if the defined String <code>str</code> matches /// * AllowedLength or the PresentLength, specified for this State /// * </summary> /// * <param name="str"> /// * string to test </param> /// * <param name="length"> /// * switches between AllowedLength and PresentLength. </param> /// * <returns> boolean - true, if 'str' matches Length or if AllowedLength is /// * not specified </returns> /// protected internal bool fitsLength(string str, EnumFitsValue length) { JDFIntegerRange lengthlist; if (length.Equals(EnumFitsValue.Allowed)) { lengthlist = getAllowedLength(); } else { lengthlist = getPresentLength(); } if (lengthlist != null) { int len = str.Length; return(lengthlist.inRange(len)); } return(true); }
/// /// <summary> * fitsValue - checks whether <code>value</code> matches the Allowed/Present /// * test lists specified for this State /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <param name="testlists"> /// * the test lists the value has to match. In this State the test /// * lists are ValueList AND ValueMod.<br> /// * Choose one of two values: FitsValue_Allowed or /// * FitsValue_Present. (Defaults to Allowed) /// * </param> /// * <returns> boolean - true, if <code>value</code> matches testlists or if /// * AllowedValueList and AllowedValueMod are not specified </returns> /// public override bool fitsValue(string @value, EnumFitsValue testlists) { if (!fitsListType(@value)) { return(false); } JDFShapeRangeList rangelist = null; try { rangelist = new JDFShapeRangeList(@value); } catch (FormatException) { return(false); } return(fitsValueList(rangelist, testlists) && fitsXYZ(rangelist, testlists)); }
public virtual void appendValue(JDFMatrix @value, EnumFitsValue testlists) { if (testlists == null || EnumFitsValue.Allowed.Equals(testlists)) { JDFValue v = appendValue(); v.setAllowedValue(@value.ToString()); if (testlists != null) { v.setValueUsage(EnumValueUsage.Allowed); } } if (EnumFitsValue.Present.Equals(testlists)) { JDFValue v = appendValue(); v.setAllowedValue(@value.ToString()); if (testlists != null) { v.setValueUsage(EnumValueUsage.Present); } } }
/// /// <summary> * fitsRegExp - checks whether <code>str</code> matches the /// * AllowedRegExp/PresentRegExp specified for this State /// * </summary> /// * <param name="str"> /// * string to test </param> /// * <param name="regexp"> /// * switches between AllowedRegExp and PresentRegExp. </param> /// * <returns> boolean - true, if <code>str</code> matches the RegExp or if /// * AllowedRegExp is not specified </returns> /// protected internal bool fitsRegExp(string str, EnumFitsValue regexp) { string rExp; if (regexp.Equals(EnumFitsValue.Allowed)) { rExp = getAllowedRegExp(); } else { rExp = getPresentRegExp(); } if (rExp.Length == 0) { return(true); // if AllowedRegExp is not specified return true } if (!StringUtil.matches(str, rExp)) { return(false); } return(true); }
// // * // Element getter / setter // // // * (non-Javadoc) // * // * @see // * org.cip4.jdflib.resource.devicecapability.JDFAbstractState#addValue(java // * .lang.String, org.cip4.jdflib.datatypes.JDFBaseDataTypes.EnumFitsValue) // public override void addValue(string @value, EnumFitsValue testlists) { if (fitsValue(@value, testlists)) { return; } JDFShape rect; try { rect = new JDFShape(@value); } catch (FormatException) { return; // nop for bad values } if (testlists == null || EnumFitsValue.Allowed.Equals(testlists)) { JDFShapeRangeList list = getAllowedValueList(); if (list == null) { list = new JDFShapeRangeList(); } list.Append(rect); setAllowedValueList(list); } if (testlists == null || EnumFitsValue.Present.Equals(testlists)) { JDFShapeRangeList list = getPresentValueList(); if (list == null || !hasAttribute(AttributeName.PRESENTVALUELIST)) { list = new JDFShapeRangeList(); } list.Append(rect); setPresentValueList(list); } }