/// /// <summary> * fitsListType - checks whether <code>matrixList</code> matches the value /// * of the ListType attribute specified for this State /// * </summary> /// * <param name="matrixList"> /// * vector of matrices to test /// * </param> /// * <returns> boolean - true, if 'value' matches specified ListType </returns> /// private bool fitsListType(List <JDFMatrix> matrixList) { EnumListType listType = getListType(); int size = matrixList.Count; if (listType.Equals(EnumListType.SingleValue) || listType.Equals(EnumListType.getEnum(0))) { // default ListType = SingleValue return(size == 1); } else if (listType.Equals(EnumListType.List)) { return(true); } else if (listType.Equals(EnumListType.UniqueList)) { for (int i = 0; i < size; i++) { for (int j = i + 1; j < size; j++) { JDFMatrix mi = matrixList[i]; JDFMatrix mj = matrixList[j]; if (mi.Equals(mj)) { return(false); } } } return(true); } else { throw new JDFException("JDFMatrixState.fitsListType illegal ListType attribute"); } }
/// /// <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> * 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); }
/// /// <summary> * fitsListType - checks whether <code>matrixList</code> matches the /// * ListType attribute specified for this Evaluation /// * </summary> /// * <param name="matrixList"> /// * value to test </param> /// * <returns> boolean - true, if <code>matrixList</code> matches specified /// * value of ListType </returns> /// private bool fitsListType(VString matrixList) { EnumListType listType = getListType(); int size = matrixList.Count; for (int i = 0; i < size; i++) { try { new JDFMatrix(matrixList[i]); } catch (JDFException) { return(false); } catch (FormatException) { return(false); } } if (listType.Equals(EnumListType.SingleValue) || listType.Equals(EnumListType.getEnum(0))) { // default ListType = SingleValue return(size == 1); } else if (listType.Equals(EnumListType.List)) { return(true); } else if (listType.Equals(EnumListType.UniqueList)) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (j != i) { string mi = matrixList[i]; string mj = matrixList[j]; if (mi.CompareTo(mj) == 0) { return(false); } } } } return(true); } else { throw new JDFException("JDFMatrixEvaluation.fitsListType illegal ListType attribute"); } }
/// /// <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); }
/// /// <summary> * fitsValueList - checks whether <code>value</code> matches the /// * AllowedValueList or the PresentValueList specified for this Evaluation /// * </summary> /// * <param name="value"> /// * nmtokens to test </param> /// * <returns> boolean - true, if <code>value</code> matches /// * <code>valuelist</code> or if AllowedValueList is not specified </returns> /// private bool fitsValueList(string @value) { if (!hasAttribute(AttributeName.VALUELIST)) { return(true); // ValueList is not specified } VString vs = new VString(@value, null); VString list = getValueList(); EnumListType listType = getListType(); if (listType.Equals(EnumListType.CompleteList)) { return(fitsCompleteList(vs, list)); } else if (listType.Equals(EnumListType.CompleteOrderedList)) { return(fitsCompleteOrderedList(vs, list)); } else if (listType.Equals(EnumListType.ContainedList)) { return(fitsContainedList(vs, list)); } int v_size = vs.Count; int l_size = list.Count; for (int i = 0; i < v_size; i++) // test every token, that 'value' // consists of { bool bFound = false; for (int j = 0; j < l_size; j++) { string str_i = vs[i]; string str_j = list[j]; if (str_i.CompareTo(str_j) == 0) { bFound = true; break; } } if (!bFound) { return(false); // no such value in the 'list' } } return(true); }
/// /// <summary> * fitsListType - tests, if the defined 'value' matches value of ListType /// * attribute, specified for this Evaluation /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <returns> boolean - true, if 'value' matches specified value of ListType </returns> /// private bool fitsListType(string @value) { VString vBool = new VString(@value, null); int size = vBool.Count; for (int i = 0; i < size; i++) { if (!StringUtil.isBoolean(vBool[i])) { return(false); } } EnumListType listType = getListType(); if (listType.Equals(EnumListType.SingleValue) || listType.Equals(EnumListType.getEnum(0))) { // default ListType = SingleValue return(size == 1); } else if (listType.Equals(EnumListType.List) || listType.Equals(EnumListType.Span)) { return(true); } else if (listType.Equals(EnumListType.UniqueList)) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (j != i) { string bi = vBool[i]; string bj = vBool[j]; if (bi.CompareTo(bj) == 0) { return(false); } } } } return(true); } else { throw new JDFException("JDFBooleanEvaluation.fitsListType illegal ListType attribute"); } }
/// /// <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); }
/// /// <summary> * fitsListType - checks whether <code>value</code> matches the value of the /// * ListType attribute specified for this Evaluation /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <returns> boolean - true, if <code>value</code> matches the specified value /// * of ListType </returns> /// private bool fitsListType(string @value) { if (!StringUtil.isNMTOKENS(@value, false)) { return(false); } EnumListType listType = getListType(); if (listType == null) { return(true); } if (listType.Equals(EnumListType.SingleValue) || listType.Equals(EnumListType.getEnum(0))) { // default ListType = SingleValue return(StringUtil.isNMTOKEN(@value)); } // not - // tested in // fitsValueList // in // fitsValueList else if (listType.Equals(EnumListType.List) || listType.Equals(EnumListType.Span) || listType.Equals(EnumListType.CompleteList) || listType.Equals(EnumListType.CompleteOrderedList) || listType.Equals(EnumListType.ContainedList)) // tested in // fitsValueList // ) { return(true); } else if (listType.Equals(EnumListType.UniqueList)) { VString v = new VString(@value, null); return(isUnique(v)); } else { throw new JDFException("JDFNameEvaluation.fitsListType illegal ListType attribute"); } }
/// /// <summary> * fitsListType - tests, if the defined <code>value</code> matches the value /// * of the ListType attribute, specified for this Evaluation /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <returns> boolean - true, if <code>value</code> matches specified ListType </returns> /// private bool fitsListType(string @value) { EnumListType listType = getListType(); JDFDateTimeRangeList rangelist; try { rangelist = new JDFDateTimeRangeList(@value); } catch (FormatException) { return(false); } catch (JDFException) { return(false); } if (listType.Equals(EnumListType.SingleValue) || listType.Equals(EnumListType.getEnum(0))) { // default ListType = SingleValue if (@value.IndexOf("P") != 0) { return(false); } try { new JDFDate(@value); } catch (JDFException) { return(false); } catch (FormatException) { return(false); } return(true); } else if (listType.Equals(EnumListType.RangeList) || listType.Equals(EnumListType.Span)) { return(true); } else if (listType.Equals(EnumListType.List)) { return(rangelist.isList()); } else if (listType.Equals(EnumListType.OrderedList)) { return(rangelist.isList() && rangelist.isOrdered()); } else if (listType.Equals(EnumListType.UniqueList)) { return(rangelist.isList() && rangelist.isUnique()); } else if (listType.Equals(EnumListType.UniqueOrderedList)) { return(rangelist.isList() && rangelist.isUniqueOrdered()); } else if (listType.Equals(EnumListType.OrderedRangeList)) { return(rangelist.isOrdered()); } else if (listType.Equals(EnumListType.UniqueRangeList)) { return(rangelist.isUnique()); } else if (listType.Equals(EnumListType.UniqueOrderedRangeList)) { return(rangelist.isUniqueOrdered()); } else { throw new JDFException("JDFDateTimeEvaluation.fitsListType illegal ListType attribute"); } }
public void testFitsValue_MatrixState() { JDFDoc jdfDoc = new JDFDoc(ElementName.JDF); JDFNode root = jdfDoc.getJDFRoot(); JDFMatrix matrix1 = new JDFMatrix("1 0 0 1 3.14 21631.3"); JDFMatrix matrix2 = new JDFMatrix("0 1 1 0 2 21000"); List <ValuedEnum> transforms = new List <ValuedEnum>(); transforms.Add(EnumOrientation.Rotate0); transforms.Add(EnumOrientation.Rotate270); transforms.Add(EnumOrientation.Flip0); JDFRectangle shift = new JDFRectangle("2 4 20000 23000"); string value1 = "1 0 0 1 3.14 21631.3"; JDFMatrixState k = (JDFMatrixState)root.appendElement("MatrixState"); k.appendValue(); // k.setValueValueUsage(0, EnumFitsValue.Allowed); k.setValueAllowedValue(0, matrix2); k.appendValue(); // k.setValueValueUsage(1, EnumFitsValue.Present); k.setValueAllowedValue(1, matrix1); k.setAllowedTransforms(transforms); k.setAllowedShift(shift); k.setAllowedRotateMod(15); EnumListType lt = EnumListType.UniqueList; // JDFAbstractState.EnumListType lt = EnumListType.ListType.Unknown; // JDFAbstractState.EnumListType lt = EnumListType.ListType.List; k.setListType(lt); // EnumListType listType = k.getListType(); Assert.IsTrue(k.fitsValue(value1, EnumFitsValue.Allowed), "Matrix OK"); string @value = "1 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8"; VString vs = new VString(@value, JDFConstants.BLANK); int siz = vs.Count; Assert.AreEqual(0, siz % 6, "It is not a Matrix"); VString matrixList = new VString(); int i = 0; StringBuilder sb = new StringBuilder(250); sb.Append(vs[i]); while ((i + 1) < siz) { do { sb.Append(JDFConstants.BLANK); i++; sb.Append(vs[i]); } while ((i + 1) % 6 != 0); matrixList.Add(sb.ToString()); if ((i + 1) < siz) { i++; sb = new StringBuilder(250); sb.Append(vs[i]); } } for (int z = 0; z < matrixList.Count; z++) { JDFMatrix matrix3 = new JDFMatrix(matrixList.stringAt(z)); //matrix3.A; } }
/// /// <summary> * Gets typesafe enumerated attribute ListType /// * </summary> /// * <returns> EnumListType: the enumeration value of the attribute </returns> /// public virtual EnumListType getListType() { return(EnumListType.getEnum(getAttribute(AttributeName.LISTTYPE, null, EnumListType.SingleValue.getName()))); }
/// /// <summary> * Sets attribute ListType, default=SingleValue /// * </summary> /// * <param name="value"> /// * the value to set the attribute to </param> /// public virtual void setListType(EnumListType @value) { setAttribute(AttributeName.LISTTYPE, @value.getName(), null); }
static JDFAbstractState() { atrInfoTable[0] = new AtrInfoTable(AttributeName.AVAILABILITY, 0x33333311, AttributeInfo.EnumAttributeType.enumeration, EnumAvailability.getEnum(0), null); atrInfoTable[1] = new AtrInfoTable(AttributeName.ACTIONREFS, 0x33333311, AttributeInfo.EnumAttributeType.IDREFS, null, null); atrInfoTable[2] = new AtrInfoTable(AttributeName.DEPENDENTMACROREF, 0x33333311, AttributeInfo.EnumAttributeType.IDREF, null, null); atrInfoTable[3] = new AtrInfoTable(AttributeName.DEVNS, 0x33333331, AttributeInfo.EnumAttributeType.URI, null, JDFConstants.JDFNAMESPACE); atrInfoTable[4] = new AtrInfoTable(AttributeName.EDITABLE, 0x33333311, AttributeInfo.EnumAttributeType.boolean_, null, JDFConstants.TRUE); atrInfoTable[5] = new AtrInfoTable(AttributeName.HASDEFAULT, 0x33333331, AttributeInfo.EnumAttributeType.boolean_, null, JDFConstants.TRUE); atrInfoTable[6] = new AtrInfoTable(AttributeName.ID, 0x33333311, AttributeInfo.EnumAttributeType.ID, null, null); atrInfoTable[7] = new AtrInfoTable(AttributeName.LISTTYPE, 0x33333311, AttributeInfo.EnumAttributeType.enumeration, EnumListType.getEnum(0), EnumListType.SingleValue.getName()); atrInfoTable[8] = new AtrInfoTable(AttributeName.MACROREFS, 0x33333311, AttributeInfo.EnumAttributeType.IDREFS, null, null); atrInfoTable[9] = new AtrInfoTable(AttributeName.MAXOCCURS, 0x33333311, AttributeInfo.EnumAttributeType.unbounded, null, "1"); atrInfoTable[10] = new AtrInfoTable(AttributeName.MINOCCURS, 0x33333311, AttributeInfo.EnumAttributeType.integer, null, "1"); atrInfoTable[11] = new AtrInfoTable(AttributeName.MODULEREFS, 0x33333111, AttributeInfo.EnumAttributeType.IDREFS, null, null); atrInfoTable[12] = new AtrInfoTable(AttributeName.NAME, 0x33333331, AttributeInfo.EnumAttributeType.NMTOKEN, null, null); atrInfoTable[13] = new AtrInfoTable(AttributeName.REQUIRED, 0x33333311, AttributeInfo.EnumAttributeType.boolean_, null, null); atrInfoTable[14] = new AtrInfoTable(AttributeName.SPAN, 0x44444431, AttributeInfo.EnumAttributeType.boolean_, null, null); atrInfoTable[15] = new AtrInfoTable(AttributeName.USERDISPLAY, 0x33333311, AttributeInfo.EnumAttributeType.enumeration, EnumUserDisplay.getEnum(0), EnumUserDisplay.Display.getName()); elemInfoTable[0] = new ElemInfoTable(ElementName.LOC, 0x33333311); }
/// /// <summary> * fitsListType - tests, if the defined <code>value</code> matches value of /// * ListType attribute, specified for this State /// * </summary> /// * <param name="value"> /// * value to test /// * </param> /// * <returns> boolean - true, if 'value' matches specified ListType </returns> /// protected internal bool fitsListType(string @value) { if (@value == null) { return(true); } EnumListType listType = getListType(); JDFRangeList rangelist; // lists of strings are most generic try { rangelist = new JDFNameRangeList(@value); } catch (FormatException) { return(false); } catch (JDFException) { return(false); } if (listType == null || listType.Equals(EnumListType.SingleValue)) { // default ListType = SingleValue return(@value.IndexOf(" ") == -1); } else if (listType.Equals(EnumListType.RangeList) || listType.Equals(EnumListType.Span)) { return(true); } else if (listType.Equals(EnumListType.Range)) { return(rangelist.Count == 1); } // not - // tested in // fitsValueList // in // fitsValueList else if (listType.Equals(EnumListType.List) || listType.Equals(EnumListType.CompleteList) || listType.Equals(EnumListType.CompleteOrderedList) || listType.Equals(EnumListType.ContainedList)) // tested in // fitsValueList { return(rangelist.isList()); } else if (listType.Equals(EnumListType.OrderedList)) { return(rangelist.isList() && rangelist.isOrdered()); } else if (listType.Equals(EnumListType.UniqueList)) { return(rangelist.isList() && rangelist.isUnique()); } else if (listType.Equals(EnumListType.UniqueOrderedList)) { return(rangelist.isList() && rangelist.isUniqueOrdered()); } else if (listType.Equals(EnumListType.OrderedRangeList)) { return(rangelist.isOrdered()); } else if (listType.Equals(EnumListType.UniqueRangeList)) { return(rangelist.isUnique()); } else if (listType.Equals(EnumListType.UniqueOrderedRangeList)) { return(rangelist.isUniqueOrdered()); } else { throw new JDFException("JDFDateTimeState.fitsListType illegal ListType attribute"); } }