Exemple #1
0
        ///
        ///	 <summary> * create a new JMF with one Message Element of family <code>family</code> and type <code>typ</code>
        ///	 *  </summary>
        ///	 * <param name="family"> the Message family - Query, Acknowledge, Command, Response, Registration or Signal </param>
        ///	 * <param name="typ"> the messages @Type value, null if unknown </param>
        ///	 * <returns> the newly created message </returns>
        ///
        public static JDFJMF createJMF(JDFMessage.EnumFamily family, JDFMessage.EnumType typ)
        {
            if (family == null)
            {
                throw new JDFException("createJMF: creating undefined message family");
            }

            JDFJMF jmf = new JDFDoc(ElementName.JMF).getJMFRoot();

            jmf.appendMessageElement(family, typ);
            return(jmf);
        }
Exemple #2
0
        ///
        ///	 <summary> * append a message element to <code>this</code>
        ///	 *  </summary>
        ///	 * <param name="family"> the Message family - Query, Acknowledge, Command, Response, Registration or Signal </param>
        ///	 * <param name="typ"> the messages @Type value, null if unknown </param>
        ///	 * <returns> the newly created message </returns>
        ///
        public virtual JDFMessage appendMessageElement(JDFMessage.EnumFamily family, JDFMessage.EnumType typ)
        {
            if (family == null)
            {
                throw new JDFException("appendMessageElement: creating undefined message family");
            }

            string     sFamily = family.getName();
            JDFMessage m       = (JDFMessage)appendElement(sFamily, null);

            if (typ != null)
            {
                m.setType(typ);
            }

            return(m);
        }
Exemple #3
0
        ///
        ///	 <summary> * get the ith message element of family type family
        ///	 *  </summary>
        ///	 * <param name="family"> the Message family - Query, Acknowledge, Command, Response, Registration or Signal </param>
        ///	 * <param name="typ"> the messages @Type value, null if unknown </param>
        ///	 * <param name="i"> the i'th message element to get, if i<0, get from back </param>
        ///	 * <returns> the matching message, null if none are found </returns>
        ///
        public virtual JDFMessage getMessageElement(JDFMessage.EnumFamily family, JDFMessage.EnumType typ, int i)
        {
            int iLocal = i;

            if (iLocal < 0) // search from back
            {
                JDFMessage message = null;
                VElement   v       = getMessageVector(family, typ);
                if (v != null)
                {
                    int siz = v.Count;
                    iLocal  = siz + iLocal;
                    message = (JDFMessage)(iLocal >= 0 ? v[iLocal] : null);
                }

                return(message);
            }

            string typString    = typ == null ? null : typ.getName();
            string familyString = family == null ? null : family.getName();

            KElement e = getElement(familyString, null, 0);
            int      n = 0;

            while (e != null)
            {
                if (e is JDFMessage)
                {
                    if (typString == null || typString.Equals(((JDFMessage)e).getType()))
                    {
                        if (n++ >= iLocal)
                        {
                            return((JDFMessage)e);
                        }
                    }
                }

                e = e.getNextSiblingElement(familyString, null);
            }

            return(null);
        }
Exemple #4
0
        ///
        ///	 <summary> * get a vector of all messages in this JMF
        ///	 *  </summary>
        ///	 * <param name="family"> requested message family </param>
        ///	 * <param name="typ"> requested message type </param>
        ///	 * <returns> VElement all message elements
        ///	 *  </returns>
        ///
        public virtual VElement getMessageVector(JDFMessage.EnumFamily family, JDFMessage.EnumType typ)
        {
            VElement vM;
            string   sFamily = (family != null) ? family.getName() : null;

            JDFAttributeMap typMap = typ == null ? null : new JDFAttributeMap(AttributeName.TYPE, typ.getName());

            vM = getChildrenByTagName(sFamily, null, typMap, true, true, 0);

            if (family == null) // only needed if call was generic
            {
                // do reverse iteration because erase invalidates
                for (int i = vM.Count - 1; i >= 0; i--)
                {
                    if (!(vM[i] is JDFMessage))
                    {
                        vM.RemoveAt(i);
                    }
                }
            }

            return(vM);
        }
Exemple #5
0
 ///
 ///	 <summary> * Append an Acknowledge
 ///	 *  </summary>
 ///	 * <param name="typ"> the type attribute of the appended message </param>
 ///	 * <returns> JDFAcknowledge the newly created message element </returns>
 ///
 public virtual JDFAcknowledge appendAcknowledge(JDFMessage.EnumType typ)
 {
     return((JDFAcknowledge)appendMessageElement(JDFMessage.EnumFamily.Acknowledge, typ));
 }
Exemple #6
0
 ///
 ///	 <summary> * Append a Response
 ///	 *  </summary>
 ///	 * <param name="typ"> the type attribute of the appended message </param>
 ///	 * <returns> JDFResponse the newly created message element </returns>
 ///
 public virtual JDFResponse appendResponse(JDFMessage.EnumType typ)
 {
     return((JDFResponse)appendMessageElement(JDFMessage.EnumFamily.Response, typ));
 }
Exemple #7
0
 ///
 ///	 <summary> * Append a Signal
 ///	 *  </summary>
 ///	 * <param name="typ"> the type attribute of the appended message </param>
 ///	 * <returns> JDFSignal: the newly created message element </returns>
 ///
 public virtual JDFSignal appendSignal(JDFMessage.EnumType typ)
 {
     return((JDFSignal)appendMessageElement(JDFMessage.EnumFamily.Signal, typ));
 }
Exemple #8
0
 ///
 ///	 <summary> * Append a query
 ///	 *  </summary>
 ///	 * <param name="typ"> the type attribute of the appended message </param>
 ///	 * <returns> JDFQuery: the newly created message element </returns>
 ///
 public virtual JDFQuery appendQuery(JDFMessage.EnumType typ)
 {
     return((JDFQuery)appendMessageElement(JDFMessage.EnumFamily.Query, typ));
 }
Exemple #9
0
 ///
 ///	 <summary> * Append a Command
 ///	 *  </summary>
 ///	 * <param name="typ"> the type attribute of the appended message </param>
 ///	 * <returns> JDFQuery the newly created message element </returns>
 ///
 public virtual JDFRegistration appendRegistration(JDFMessage.EnumType typ)
 {
     return((JDFRegistration)appendMessageElement(JDFMessage.EnumFamily.Registration, typ));
 }
Exemple #10
0
 ///
 ///	 <summary> * Append a Command
 ///	 *  </summary>
 ///	 * <param name="typ"> the type attribute of the appended message </param>
 ///	 * <returns> JDFQuery the newly created message element </returns>
 ///
 public virtual JDFCommand appendCommand(JDFMessage.EnumType typ)
 {
     return((JDFCommand)appendMessageElement(JDFMessage.EnumFamily.Command, typ));
 }
Exemple #11
0
        ///
        ///	 <summary> * get a vector of all messages in a JMF from a JDFDoc
        ///	 *  </summary>
        ///	 * <param name="doc"> the JDFDoc to search - only valid for root JMF </param>
        ///	 * <param name="family"> requested message family </param>
        ///	 * <param name="typ"> requested message type </param>
        ///	 * <returns> VElement all message elements, null if no match found
        ///	 *  </returns>
        ///
        public static VElement getMessageVector(JDFDoc doc, JDFMessage.EnumFamily family, JDFMessage.EnumType typ)
        {
            if (doc == null)
            {
                return(null);
            }
            JDFJMF jmf = doc.getJMFRoot();

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

            VElement vM = jmf.getMessageVector(family, typ);

            return(vM.Count == 0 ? null : vM);
        }
Exemple #12
0
        ///
        ///	 <summary> * get an existing message element, create it if it doesn't exist
        ///	 *  </summary>
        ///	 * <param name="family"> the Message family - Query, Acknowledge, Command, Response, Registration or Signal </param>
        ///	 * <param name="i"> get the ith element </param>
        ///	 * <returns> the newly created message </returns>
        ///
        public virtual JDFMessage getCreateMessageElement(JDFMessage.EnumFamily family, JDFMessage.EnumType typ, int i)
        {
            if (family == null)
            {
                throw new JDFException("GetMessageElement: creating undefined message family");
            }

            JDFMessage m = getMessageElement(family, typ, i);

            if (m == null)
            {
                m = appendMessageElement(family, typ);
            }

            return(m);
        }