Package net.n3.nanoxml

Examples of net.n3.nanoxml.IXMLElement


  {
    try
    {
      final IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
      parser.setReader(new StdXMLReader(rdr));
      IXMLElement element = (IXMLElement) parser.parse();
      // Bug 2942351 (Program doesn't launch)
      // looking at the source for StdXMLBuilder, it appears that parser.parse() could possibly return
      // null.  So check for null here and skip if necessary.
      if (element != null)
      {
        Iterator it = new EnumerationIterator(element.enumerateChildren());
        while (it.hasNext())
        {
          final IXMLElement elem = (IXMLElement) it.next();
          if (isBeanElement(elem))
          {
            _beanColl.add(loadBean(elem));
          }
        }
View Full Code Here


        props.put(propDesc[i].getName(), propDesc[i]);
      }
      final List<IXMLElement> children = beanElement.getChildren();
      for (Iterator<IXMLElement> it = children.iterator(); it.hasNext();)
      {
        final IXMLElement propElem = it.next();
        final PropertyDescriptor curProp = props.get(propElem.getName());
        if (curProp != null)
        {
          loadProperty(bean, curProp, propElem);
        }
      }
View Full Code Here

  }

  private IXMLElement createElement(Object bean, String name)
    throws XMLException
  {
    IXMLElement elem = null;
    BeanInfo info = null;
    try
    {
      if (bean != null)
      {
        info = Introspector.getBeanInfo(bean.getClass(), Object.class);
      }
    }
    catch (IntrospectionException ex)
    {
      throw new XMLException(ex);
    }
    elem = new XMLElement(name != null ? name : XMLConstants.BEAN_ELEMENT_NAME);
    if (info != null)
    {
      if (bean instanceof IXMLAboutToBeWritten)
      {
        ((IXMLAboutToBeWritten) bean).aboutToBeWritten();
      }
      PropertyDescriptor[] propDesc = info.getPropertyDescriptors();
      elem = new XMLElement(name != null ? name : XMLConstants.BEAN_ELEMENT_NAME);
      elem.setAttribute(XMLConstants.CLASS_ATTRIBUTE_NAME,
                      bean.getClass().getName());
      for (int i = 0; i < propDesc.length; ++i)
      {
        processProperty(propDesc[i], bean, elem);
      }
View Full Code Here

        {
          final boolean isStringArray = returnType.getName().equals("[Ljava.lang.String;");
          Object[] props = (Object[]) getter.invoke(bean, (Object[])null);
          if (props != null)
          {
            IXMLElement indexElem = new XMLElement(propName);
            indexElem.setAttribute(XMLConstants.INDEXED, "true");
            beanElem.addChild(indexElem);
            for (int i = 0; i < props.length; ++i)
            {
              if (isStringArray)
              {
                StringWrapper sw = new StringWrapper((String)props[i]);
                indexElem.addChild(createElement(sw,
                      XMLConstants.BEAN_ELEMENT_NAME));
              }
              else
              {
                indexElem.addChild(createElement(props[i],
                        XMLConstants.BEAN_ELEMENT_NAME));
              }
            }
          }
        }
        else if (returnType == boolean.class
            || returnType == int.class
            || returnType == short.class
            || returnType == long.class
            || returnType == float.class
            || returnType == double.class
            || returnType == char.class)
        {
          IXMLElement propElem = new XMLElement(propName);
          propElem.setContent("" + getter.invoke(bean, (Object[])null));
          beanElem.addChild(propElem);
        }
        else if (returnType == String.class)
        {
          IXMLElement propElem = new XMLElement(propName);
          propElem.setContent((String) getter.invoke(bean, (Object[])null));
          beanElem.addChild(propElem);
        }
        else
        {
          beanElem.addChild(createElement(getter.invoke(bean, (Object[])null), propName));
View Full Code Here

        request.setHeaderField("Host", con.getHostHeaderValue()); //$NON-NLS-1$
        if (depth != null)
            request.setHeaderField("Depth", depth); //$NON-NLS-1$
        request.setHeaderField("Content-Type", "text/xml; charset=\"UTF-8\""); //$NON-NLS-1$ //$NON-NLS-2$

        IXMLElement root = new XMLElement(WebDAVConstants.PROPFIND_ELEM, WebDAVConstants.XML_DAV_NAMESPACE);
        root.addChild(new XMLElement(WebDAVConstants.ALLPROP_ELEM));

        StringWriter xml = new StringWriter();
        XMLWriter writer = new XMLWriter(xml);
        writer.write(root);
View Full Code Here

        if (element.getFirstChildNamed("href", element.getNamespace()) == null) //$NON-NLS-1$
            throw new IOException(Messages.getString("MultiStatusResponse.unexpectedHref")); //$NON-NLS-1$

        href = URLUTF8Encoder.decode(element.getFirstChildNamed("href", element.getNamespace()).getContent()); //$NON-NLS-1$

        IXMLElement props = element.getFirstChildNamed("propstat", element.getNamespace()); //$NON-NLS-1$

        if (props == null)
            throw new IOException(Messages.getString("MultiStatusResponse.noPropertyElements")); //$NON-NLS-1$

        if (props.getFirstChildNamed("status", element.getNamespace()) == null) //$NON-NLS-1$
            throw new IOException(Messages.getString("MultiStatusResponse.unexpectedStatusResponse")); //$NON-NLS-1$

        String status = props.getFirstChildNamed("status", element.getNamespace()).getContent(); //$NON-NLS-1$

        StringTokenizer tokens = new StringTokenizer(status, " ", false); //$NON-NLS-1$
        reason = ""; //$NON-NLS-1$

        try {
            version = tokens.nextToken();
            this.status = Integer.parseInt(tokens.nextToken());

            while (tokens.hasMoreTokens()) {
                reason += tokens.nextToken() + " "; //$NON-NLS-1$
            }
            reason = URLDecoder.decode(reason.trim());
        } catch (NoSuchElementException e) {
            throw new IOException(Messages.getString("MultiStatusResponse.failedToReadHTTPResponseHeader")); //$NON-NLS-1$
        } catch (NumberFormatException e) {
            throw new IOException(Messages.getString("MultiStatusResponse.failedToReadHTTPResponseHeader")); //$NON-NLS-1$
        }

        // Create a new set of properties
        properties = new Properties();

        // Check the status, if its not found then return
        if (this.status == 404)
            return;

        props = props.getFirstChildNamed("prop", props.getNamespace()); //$NON-NLS-1$

        if (props == null)
            throw new IOException(Messages.getString("MultiStatusResponse.noPropElementsInPropStat")); //$NON-NLS-1$

        IXMLElement child;

        for (Enumeration e = props.getChildren().elements(); e.hasMoreElements();) {
            child = (IXMLElement) e.nextElement();

            if (child.getName().equalsIgnoreCase("resourcetype")) { //$NON-NLS-1$
                if (child.getChildrenNamed("collection") != null) //$NON-NLS-1$
                    collection = true;
            } else {
                properties.put(child.getName().toLowerCase(), child.getContent() == null ? "" : child.getContent()); //$NON-NLS-1$
            }
        }

    }
View Full Code Here

        try {
            IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
            IXMLReader reader = StdXMLReader.stringReader(new String(out.toByteArray(), "UTF8")); //$NON-NLS-1$
            parser.setReader(reader);
            IXMLElement rootElement = (IXMLElement) parser.parse();

            if (!rootElement.getName().equalsIgnoreCase("multistatus")) //$NON-NLS-1$
                throw new IOException(Messages.getString("MultiStatusResponse.invalidDavRootElement") + rootElement.getName()); //$NON-NLS-1$

            // Now process the responses
            Vector children = rootElement.getChildrenNamed("response", rootElement.getNamespace()); //$NON-NLS-1$
            Vector responses = new Vector();

            for (Enumeration e = children.elements(); e.hasMoreElements();) {
                responses.addElement(new MultiStatusResponse((IXMLElement) e.nextElement()));
            }
View Full Code Here

      return ret;
  }
 
  public ConfigNode fetchFirst(String string) {
      if (root == null) return null;
      IXMLElement kid = root.getFirstChildNamed(string);
      if (kid == null) return null;
      return new XmlConfigNode(kid);
  }
View Full Code Here

        throws Exception {
        StdXMLReader xr = new StdXMLReader(in);
        IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
        parser.setReader(xr);
        TestSetSpecification res;
        IXMLElement root = (IXMLElement) parser.parse();
        if (root.getName().equals("testSpec")) {
            res = new TestSetSpecification("", base);
            res.addTestSpec(parseTestSpecification(root));
        } else if (root.getName().equals("testSet")) {
            String title = extractAttribute(root, "title");
            res = new TestSetSpecification(title, base);
            for (Object obj : root.getChildren()) {
                if (obj instanceof IXMLElement) {
                    IXMLElement argChild = (IXMLElement) obj;
                    String name = argChild.getName();
                    if (name.equals("testSpec")) {
                        // (directly recursive)
                        res.addTestSpec(parseTestSpecification(argChild));
                    } else if (name.equals("plugin")) {
                        res.addPluginSpec(parsePluginSpecification(argChild));
View Full Code Here

        TestSpecification res = new TestSpecification(
                runMode, command, scriptContent, inputContent, outputContent, errorContent,
                title, rc, exception);
        for (Object obj : elem.getChildren()) {
            if (obj instanceof IXMLElement) {
                IXMLElement child = (IXMLElement) obj;
                String name = child.getName();
                if (name.equals("arg")) {
                    res.addArg(child.getContent());
                } else if (name.equals("plugin")) {
                    res.addPlugin(parsePluginSpecification(child));
                } else if (name.equals("file")) {
                    parseFile(child, res);
                }
View Full Code Here

TOP

Related Classes of net.n3.nanoxml.IXMLElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.