Exemplo n.º 1
0
        ///
        ///	 <summary> * Returns a list of element names matching the requested validity for the specified JDF version.
        ///	 *  </summary>
        ///	 * <param name="EnumElementValidity"> elemValidity: requested validity </param>
        ///	 * <returns> VString: list of strings containing the names of the matching elements </returns>
        ///
        private VString conformingElements(EnumElementValidity elemValidity1, EnumElementValidity elemValidity2, EnumElementValidity elemValidity3, EnumElementValidity elemValidity4)
        {
            VString     matchingElements = new VString();
            IEnumerator iter             = elementInfoTable.Keys.GetEnumerator();

            long l2 = JDFVersions.getTheMask(version);
            long v2 = JDFVersions.getTheOffset(version);

            while (iter.MoveNext())
            {
                string   theKey      = (string)iter.Current;
                ElemInfo ei          = (ElemInfo)elementInfoTable[theKey];
                long     eiValStatus = ei.getElemValidityStatus() & l2;
                if (eiValStatus == ((long)elemValidity1.getValue() << (int)v2))
                {
                    matchingElements.Add(theKey);
                }
                else if (eiValStatus == ((long)elemValidity2.getValue() << (int)v2))
                {
                    matchingElements.Add(theKey);
                }
                else if (eiValStatus == ((long)elemValidity3.getValue() << (int)v2))
                {
                    matchingElements.Add(theKey);
                }
                else if (eiValStatus == ((long)elemValidity4.getValue() << (int)v2))
                {
                    matchingElements.Add(theKey);
                }
            }

            return(matchingElements);
        }
Exemplo n.º 2
0
 ///
 ///	 <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);
 }
Exemplo n.º 3
0
        ///
        ///	 <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);
        }
Exemplo n.º 4
0
        ///
        ///	 <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);
        }
Exemplo n.º 5
0
        ///
        ///	 <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);
        }
Exemplo n.º 6
0
 public virtual void testVersions()
 {
     Assert.AreEqual(0L, JDFVersions.getTheOffset(EnumVersion.Version_1_0));
     Assert.AreEqual(8L, JDFVersions.getTheOffset(EnumVersion.Version_1_2));
 }