Beispiel #1
0
        public virtual System.String getAdditionalAttribute(System.String namespace_Renamed, System.String name)
        {
            TreeElement e = TreeElement.getAttribute(additionalAttributes, namespace_Renamed, name);

            if (e != null)
            {
                return(e.getAttributeValue());
            }
            return(null);
        }
Beispiel #2
0
        public virtual System.String serializeNode(TreeElement instanceNode)
        {
            StringBuilder b = new StringBuilder();

            // don't serialize template nodes or non-relevant nodes
            if (!instanceNode.isRelevant() || instanceNode.Mult == TreeReference.INDEX_TEMPLATE)
            {
                return(null);
            }

            if (instanceNode.Value != null)
            {
                System.Object serializedAnswer = serializer.serializeAnswerData(instanceNode.Value, instanceNode.DataType);

                if (serializedAnswer is Element)
                {
                    // DON"T handle this.
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    throw new System.SystemException("Can't handle serialized output for" + instanceNode.Value.ToString() + ", " + serializedAnswer);
                }
                else if (serializedAnswer is System.String)
                {
                    Element e = new Element();
                    e.addChild(Node.TEXT, (System.String)serializedAnswer);

                    System.String tag = instanceNode.getAttributeValue("", "tag");
                    if (tag != null)
                    {
                        b.append(tag);
                    }
                    b.append(delimiter);

                    for (int k = 0; k < e.getChildCount(); k++)
                    {
                        b.append(e.getChild(k).toString());
                        b.append(delimiter);
                    }
                }
                else
                {
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    throw new System.SystemException("Can't handle serialized output for" + instanceNode.Value.ToString() + ", " + serializedAnswer);
                }

                if (serializer.containsExternalData(instanceNode.Value))
                {
                    IDataPointer[] pointer = serializer.retrieveExternalDataPointer(instanceNode.Value);
                    for (int i = 0; i < pointer.Length; ++i)
                    {
                        dataPointers.Add(pointer[i]);
                    }
                }
            }
            return(b.toString());
        }
Beispiel #3
0
        /*
         * (non-Javadoc)
         *
         * @see
         * org.javarosa.core.model.utils.ITreeVisitor#visit(org.javarosa.core.model
         * .DataModelTree)
         */
        public virtual void  visit(FormInstance tree)
        {
            nodeSet = new System.Text.StringBuilder().ToString();

            //TreeElement root = tree.getRoot();
            TreeElement root = tree.resolveReference(rootRef);

            xmlns     = root.getAttributeValue("", "xmlns");
            delimiter = root.getAttributeValue("", "delimiter");
            if (delimiter == null)
            {
                // for the spelling-impaired...
                delimiter = root.getAttributeValue("", "delimeter");
            }
            prefix = root.getAttributeValue("", "prefix");

            xmlns     = (xmlns != null)?xmlns:" ";
            delimiter = (delimiter != null)?delimiter:" ";
            prefix    = (prefix != null)?prefix:" ";

            //Don't bother adding any delimiters, yet. Delimiters are
            //added before tags/data
            theSmsStr = prefix;

            // serialize each node to get it's answers
            for (int j = 0; j < root.NumChildren; j++)
            {
                TreeElement   tee = root.getChildAt(j);
                System.String e   = serializeNode(tee);
                if (e != null)
                {
                    theSmsStr += e;
                }
            }
            theSmsStr = theSmsStr.Trim();
        }
Beispiel #4
0
        public virtual Element serializeNode(TreeElement instanceNode)
        {
            Element e = new Element();             //don't set anything on this element yet, as it might get overwritten

            //don't serialize template nodes or non-relevant nodes
            if ((respectRelevance && !instanceNode.isRelevant()) || instanceNode.Mult == TreeReference.INDEX_TEMPLATE)
            {
                return(null);
            }

            if (instanceNode.Value != null)
            {
                System.Object serializedAnswer = serializer.serializeAnswerData(instanceNode.Value, instanceNode.DataType);

                if (serializedAnswer is Element)
                {
                    e = (Element)serializedAnswer;
                }
                else if (serializedAnswer is System.String)
                {
                    e = new Element();
                    e.addChild(Node.TEXT, (System.String)serializedAnswer);
                }
                else
                {
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    throw new System.SystemException("Can't handle serialized output for" + instanceNode.Value.ToString() + ", " + serializedAnswer);
                }

                if (serializer.containsExternalData(instanceNode.Value))
                {
                    IDataPointer[] pointer = serializer.retrieveExternalDataPointer(instanceNode.Value);
                    for (int i = 0; i < pointer.Length; ++i)
                    {
                        dataPointers.Add(pointer[i]);
                    }
                }
            }
            else
            {
                //make sure all children of the same tag name are written en bloc
                System.Collections.ArrayList childNames = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
                for (int i = 0; i < instanceNode.NumChildren; i++)
                {
                    System.String childName = instanceNode.getChildAt(i).Name;
                    if (!childNames.Contains(childName))
                    {
                        childNames.Add(childName);
                    }
                }

                for (int i = 0; i < childNames.Count; i++)
                {
                    System.String childName = (System.String)childNames[i];
                    int           mult      = instanceNode.getChildMultiplicity(childName);
                    for (int j = 0; j < mult; j++)
                    {
                        Element child = serializeNode(instanceNode.getChild(childName, j));
                        if (child != null)
                        {
                            e.addChild(Node.ELEMENT, child);
                        }
                    }
                }
            }

            e.setName(instanceNode.Name);

            // add hard-coded attributes
            for (int i = 0; i < instanceNode.AttributeCount; i++)
            {
                System.String namespace_Renamed = instanceNode.getAttributeNamespace(i);
                System.String name = instanceNode.getAttributeName(i);
                System.String val  = instanceNode.getAttributeValue(i);
                // is it legal for getAttributeValue() to return null? playing it safe for now and assuming yes
                if (val == null)
                {
                    val = "";
                }
                e.setAttribute(namespace_Renamed, name, val);
            }
            if (instanceNode.Namespace != null)
            {
                e.setNamespace(instanceNode.Namespace);
            }

            return(e);
        }