Exemplo n.º 1
0
        ///
        ///	 <summary> * Gets the NamePath of this State in form "
        ///	 * <code>DevCapsName[Context=aaa, LinkUsage=ccc]/DevCapName1/DevCapName2../@StateName</code>
        ///	 * "
        ///	 * <p>
        ///	 * default getNamePath(false)
        ///	 *  </summary>
        ///	 * <returns> String - NamePath of this State </returns>
        ///
        public string getNamePath()
        {
            string namePath = getParentPath();

            JDFDevCaps dcs = getParentDevCaps();

            if (dcs != null)
            {
                EnumContext context = dcs.getContext();
                if (EnumContext.Link.Equals(context))
                {
                    namePath += "Link";
                }
            }
            if (getListType().Equals(EnumListType.Span))
            {
                return(namePath + "/" + getName()); // Span is an element
            }
            return(namePath + "/@" + getName());
        }
Exemplo n.º 2
0
        ///
        ///	 <summary> * Gets the NamePath of this State in form "
        ///	 * <code>DevCapsName[Context=aaa, LinkUsage=ccc]/DevCapName1/DevCapName2../@StateName</code>
        ///	 * "
        ///	 * <p>
        ///	 * default getNamePath(false)
        ///	 *  </summary>
        ///	 * <param name="bRecurse">
        ///	 *            if true returns "
        ///	 *            <code>DevCapsName/SubelemName1/SubelemName2/../@StateName</code>
        ///	 *            "
        ///	 *  </param>
        ///	 * <returns> String - NamePath of this State </returns>
        ///
        public VString getNamePathVector(bool bRecurse)
        {
            VString    vNamePath = getParentPathVector(bRecurse);
            JDFDevCaps dcs       = getParentDevCaps();

            if (dcs != null)
            {
                EnumContext context = dcs.getContext();
                if (EnumContext.Link.Equals(context))
                {
                    StringUtil.concatStrings(vNamePath, "Link");
                }
            }
            if (getListType().Equals(EnumListType.Span))
            {
                StringUtil.concatStrings(vNamePath, "/" + getName()); // Span is an
                // element
            }
            else
            {
                StringUtil.concatStrings(vNamePath, "/@" + getName());
            }
            return(vNamePath);
        }
Exemplo n.º 3
0
        ///
        ///	 <summary> * gets the XPath to the attributes of a given JDF node
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDF node to test </param>
        ///	 * <returns> String - the XPath to the attributes </returns>
        ///
        protected internal virtual string getEvalXPath(KElement jdf)
        {
            ICapabilityElement stateDC = getRefTarget();

            if (stateDC == null)
            {
                return(null);
            }

            VString vPath    = null;
            bool    bElement = false;
            string  attName  = null;

            if (stateDC is JDFDevCap)
            {
                if (!(this is JDFIsPresentEvaluation)) // only ispresent may
                // reference a
                // devcap, all
                // others must
                // reference a state
                {
                    return(null);
                }
                bElement = true;
                JDFDevCap dc = (JDFDevCap)stateDC;
                vPath = dc.getNamePathVector(true);
                // fix up for the fact that ispresent for a resource is actually a
                // link
                if (vPath != null)
                {
                    for (int i = 0; i < vPath.Count; i++)
                    {
                        string  path   = vPath.stringAt(i);
                        VString tokens = new VString(StringUtil.tokenize(path, "/", false));
                        if (tokens.Count == 3 && tokens.stringAt(1).Equals(ElementName.RESOURCEPOOL))
                        {
                            tokens[1] = ElementName.RESOURCELINKPOOL;
                            tokens[2] = tokens.stringAt(2) + "Link";
                            vPath[i]  = StringUtil.setvString(tokens, "/", null, null);
                        }
                    }
                }
            }
            else if (stateDC is JDFDevCaps)
            {
                if (!(this is JDFIsPresentEvaluation)) // only ispresent may
                // reference a
                // devcap, all
                // others must
                // reference a state
                {
                    return(null);
                }
                bElement = true;
                JDFDevCaps dc = (JDFDevCaps)stateDC;
                vPath = dc.getNamePathVector();
                // fix up for the fact that ispresent for a resource is actually a
                // link
                if (vPath != null)
                {
                    for (int i = 0; i < vPath.Count; i++)
                    {
                        string  path   = vPath.stringAt(i);
                        VString tokens = new VString(StringUtil.tokenize(path, "/", false));
                        if (tokens.Count == 3 && tokens.stringAt(1).Equals(ElementName.RESOURCEPOOL))
                        {
                            tokens[1] = ElementName.RESOURCELINKPOOL;
                            string    link = tokens.stringAt(2) + "Link";
                            EnumUsage lu   = dc.getLinkUsage();
                            if (lu != null)
                            {
                                link += "[@Usage=\"" + lu.getName() + "\"]";
                            }
                            tokens[2] = link;
                            vPath[i]  = StringUtil.setvString(tokens, "/", null, null);
                        }
                    }
                }
            }
            else
            {
                // we have found our state -> take its xPath and look for
                // corresponding elem in JDFNode, we test

                JDFAbstractState state = (JDFAbstractState)stateDC;
                if (state.getListType().Equals(EnumListType.Span))
                {
                    vPath    = state.getNamePathVector(true);
                    bElement = true;
                }
                else
                {
                    KElement kdc = state.getParentNode_KElement();
                    if (kdc is IDeviceCapable)
                    {
                        vPath = ((IDeviceCapable)kdc).getNamePathVector();
                    }
                    else if (kdc is ICapabilityElement)
                    {
                        vPath = ((ICapabilityElement)kdc).getNamePathVector();
                    }
                    attName = state.getName();
                }
            }
            if (vPath != null)
            {
                for (int i = 0; i < vPath.Count; i++)
                {
                    string xPath  = vPath.stringAt(i);
                    int    slash  = xPath.Length;
                    string finalS = null;
                    do
                    {
                        string xPath2 = xPath.Substring(0, slash);
                        if (jdf.matchesPath(xPath2, true))
                        {
                            finalS = "." + xPath.Substring(slash);
                        }
                        slash = xPath2.LastIndexOf("/");
                    } while (slash >= 0 && finalS == null);

                    if (finalS != null && !bElement)
                    {
                        finalS += "/@" + attName;
                    }
                    if (finalS != null)
                    {
                        return(finalS);
                    }
                }
            }
            return(null);
        }