Package org.jdom2.input

Examples of org.jdom2.input.StAXStreamBuilder

From a JDOM perspective XMLStreamReaders are more efficient than XMLEventReaders. Where possible use an XMLStreamReader.

If you happen to be looking at the source code, pay careful attention to the imports so you know what type of instance is being processed, whether it is a StAX class, or a JDOM class, because there are name conflicts. @author Rolf Lear


        public Date getRevisionTimestamp() {
            return revisionTimestamp;
        }

        public ParsePage invoke() throws JDOMException, IOException {
            SAXBuilder builder = new SAXBuilder();
            Document doc = builder.build(new ByteArrayInputStream(pageString.getBytes()));
            pageTitle = textToString(titleXPath.evaluateFirst(doc));
            wikitext = textToString(textXPath.evaluate(doc));
            sourceUrl = "http://en.wikipedia.org/wiki/" + pageTitle;
            String revisionTimestampString = textToString(revisionTimestampXPath.evaluateFirst(doc));
            revisionTimestamp = null;
View Full Code Here


            } else {
                update.offer("device" + UDN + "/value/" + "lightON.png");
            }
        } else if(variable.contentEquals("LastChange")){
          
            SAXBuilder sxb = new SAXBuilder();
            try {
                Document document = sxb.build(new InputSource(new StringReader(value)));
                Element root = document.getRootElement();
                List<Element> children = root.getChildren();
                Iterator<Element> iterator = children.iterator();
                while (iterator.hasNext()) { //for each instanceID
                    Element current = iterator.next();
View Full Code Here

    }

    @Override
    public HierarchicalStreamReader createReader(final Reader reader) {
        try {
            final SAXBuilder builder = new SAXBuilder();
            final Document document = builder.build(reader);
            return new JDom2Reader(document, getNameCoder());
        } catch (final IOException e) {
            throw new StreamException(e);
        } catch (final JDOMException e) {
            throw new StreamException(e);
View Full Code Here

    }

    @Override
    public HierarchicalStreamReader createReader(final InputStream in) {
        try {
            final SAXBuilder builder = new SAXBuilder();
            final Document document = builder.build(in);
            return new JDom2Reader(document, getNameCoder());
        } catch (final IOException e) {
            throw new StreamException(e);
        } catch (final JDOMException e) {
            throw new StreamException(e);
View Full Code Here

    }

    @Override
    public HierarchicalStreamReader createReader(final URL in) {
        try {
            final SAXBuilder builder = new SAXBuilder();
            final Document document = builder.build(in);
            return new JDom2Reader(document, getNameCoder());
        } catch (final IOException e) {
            throw new StreamException(e);
        } catch (final JDOMException e) {
            throw new StreamException(e);
View Full Code Here

    }

    @Override
    public HierarchicalStreamReader createReader(final File in) {
        try {
            final SAXBuilder builder = new SAXBuilder();
            final Document document = builder.build(in);
            return new JDom2Reader(document, getNameCoder());
        } catch (final IOException e) {
            throw new StreamException(e);
        } catch (final JDOMException e) {
            throw new StreamException(e);
View Full Code Here

    protected List<String> trans = null;

    public KeyboardLayout(InputStream is) throws Exception
    {
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(is);
        loadData(document.getRootElement());
    }
View Full Code Here

    this.annotatorNames = annotatorNames;
  }

  public Collection<KnowtatorAnnotation> parse(URI knowtatorXML) throws JDOMException, IOException {

    Element annotationsElem = new SAXBuilder().build(knowtatorXML.toURL()).getRootElement();

    // parse <annotation> elements
    Set<String> ignoredAnnotators = new HashSet<String>();
    Map<String, KnowtatorAnnotation> annotations = new HashMap<String, KnowtatorAnnotation>();
    for (Element annotationElem : annotationsElem.getChildren("annotation")) {
View Full Code Here

   * @param url Target URL.
   * @return The HTML document.
   * @throws Exception
   */
  Document loadURL(URL url) throws Exception{
    SAXBuilder builder=new SAXBuilder();
    Document xml=null;
    HttpURLConnection con=(HttpURLConnection) url.openConnection();
    con.setInstanceFollowRedirects(true);
   
    InputStream in;
    try
    {
       in = con.getInputStream();
    }
    catch(Exception e)
    {
      in=con.getErrorStream();
    }
    String encoding = con.getContentEncoding();
    encoding = encoding == null ? "UTF-8" : encoding;
    if(encoding.equals("gzip"))
    {
      in=new GZIPInputStream(con.getInputStream());
      encoding="UTF-8";
    }
   
    String body = IOUtils.toString(in, encoding).replace(" & ", "&amp;");
    for(int i=0;i<this.attempts;i++)
    {
      try
      {
        xml=(Document) builder.build(new StringReader(body));
        i+=this.attempts+1;
      }
      catch(JDOMParseException ex)
      {
        int line=ex.getLineNumber();
View Full Code Here

  /**
   *
   */
  private void openSQList()
  {
    SAXBuilder sxb = new SAXBuilder();
    try {
      this.root = sxb.build(new File(SQCalculator.xmlPath)).getRootElement();
    } catch (JDOMException | IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

TOP

Related Classes of org.jdom2.input.StAXStreamBuilder

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.