/// /// <summary> * Returns the validity of the given attribute for the latest JDF version. Attribute types of previous versions have /// * to be provided by attribute-specific functions (if necessary). /// * </summary> /// * <param name="String"> attributeName: name of the attribute </param> /// * <returns> EnumAttributeType: the attribute's type </returns> /// public virtual EnumAttributeValidity getAttributeValidity(string attributeName) { if (attribInfoTable.ContainsKey(attributeName)) { long l = ((AtrInfo)attribInfoTable[attributeName]).getAtrValidityStatus(); long l2 = JDFVersions.getTheMask(version); long v2 = JDFVersions.getTheOffset(version); l = (l & l2) >> (int)v2; return(EnumAttributeValidity.getEnum((int)l)); } return(null); }
public virtual bool validAttribute(string key, string attribute, KElement.EnumValidationLevel level) { EnumAttributeType typ = getAttributeType(key); if (typ == null) // unknown attributes are by definition valid, the // check is done in the unknown method { return(true); } // get the correct enumeration lists ValuedEnum enu = null; if ((typ == EnumAttributeType.enumeration) || (typ == EnumAttributeType.enumerations)) { enu = getAttributeEnum(key); } else if (typ == EnumAttributeType.JDFJMFVersion) { enu = EnumVersion.getEnum(0); } EnumAttributeValidity val = getAttributeValidity(key); if (val == EnumAttributeValidity.Unknown) { return(attribute == null); } else if (val == EnumAttributeValidity.Deprecated) { return((attribute == null) || EnumValidationLevel.isNoWarn(level)); } else if (val == EnumAttributeValidity.None) // prerelease may be set // by schema validating // parser { return((attribute == null) || attribute.Equals(getAttributeDefault(key)) || EnumValidationLevel.isNoWarn(level)); } else if ((val == EnumAttributeValidity.Optional) || ((level != EnumValidationLevel.Complete) && (level != EnumValidationLevel.RecursiveComplete))) { return((attribute == null) || validStringForType(attribute, typ, enu)); } else if (val == EnumAttributeValidity.Required) { return((attribute != null) && validStringForType(attribute, typ, enu)); } return(true); }
/// /// <summary> * Returns true if there is at least one attribute matching the requested validity for the specified JDF version. /// * </summary> /// * <param name="EnumAttributeValidity"> attrValidity: requested validity </param> /// * <returns> boolean: true if at least one attribute matches the requested validity </returns> /// public virtual bool hasConformingAttrib(EnumAttributeValidity attrValidity) { IEnumerator iter = attribInfoTable.Keys.GetEnumerator(); long l2 = JDFVersions.getTheMask(version); long v2 = JDFVersions.getTheOffset(version); while (iter.MoveNext()) { AtrInfo ai = (AtrInfo)attribInfoTable[iter.Current]; if ((ai.getAtrValidityStatus() & l2) == ((long)attrValidity.getValue() << (int)v2)) { return(true); } } return(false); }
/// /// <summary> * Returns a list of attributes matching the requested validity for the specified JDF version. /// * </summary> /// * <param name="EnumAttributeValidity"> attrValidity: requested validity </param> /// * <returns> VString: list of strings containing the names of the matching attributes </returns> /// public virtual VString conformingAttribs(EnumAttributeValidity attrValidity) { VString matchingAttribs = new VString(); long l2 = JDFVersions.getTheMask(version); long v2 = JDFVersions.getTheOffset(version); IEnumerator iter = attribInfoTable.Keys.GetEnumerator(); bool bOK = attrValidity == null; while (iter.MoveNext()) { string theKey = (string)iter.Current; AtrInfo ai = (AtrInfo)attribInfoTable[theKey]; if (bOK) { matchingAttribs.Add(theKey); } else { if (attrValidity != null) { // grab values from tables long l1 = ai.getAtrValidityStatus(); long l3 = l1 & l2; // calculate correct mask from attrValidity and version long v1 = attrValidity.getValue(); long v3 = v1 << (int)v2; // tables and version coincide if (l3 == v3) { matchingAttribs.Add(theKey); } } } } return(matchingAttribs); }
/// /// <summary> * Returns a map of attributes with defaults for the specified JDF version. /// * </summary> /// * <returns> JDFAttributeMap: map of strings containing the names and defaults of the matching attributes, null if no /// * defaults exist </returns> /// public virtual JDFAttributeMap getDefaultAttributeMap() { JDFAttributeMap matchingAttribs = new JDFAttributeMap(); IEnumerator iter = attribInfoTable.Keys.GetEnumerator(); while (iter.MoveNext()) { string theKey = (string)iter.Current; AtrInfo ai = (AtrInfo)attribInfoTable[theKey]; long l2 = JDFVersions.getTheMask(version); long v2 = JDFVersions.getTheOffset(version); EnumAttributeValidity versionVal = EnumAttributeValidity.getEnum((int)((ai.getAtrValidityStatus() & l2) >> (int)v2)); if (versionVal.Equals(EnumAttributeValidity.Optional) || versionVal.Equals(EnumAttributeValidity.Required)) { string def = ai.getAtrDefault(); if (def != null) { matchingAttribs.put(theKey, def); } } } return(matchingAttribs.IsEmpty() ? null : matchingAttribs); }