Package com.sun.syndication.io

Examples of com.sun.syndication.io.WireFeedInput


        feed.setFeedType(FEED_TYPE);
        WireFeedOutput wireFeedOutput = new WireFeedOutput();
        Document feedDoc = wireFeedOutput.outputJDom(feed);
        feedDoc.getRootElement().addContent(fetchedEntryElement);
               
        WireFeedInput input = new WireFeedInput();
        Feed parsedFeed = (Feed)input.build(feedDoc);
        return (Entry)parsedFeed.getEntries().get(0);
    }
View Full Code Here


            Annotation annotations[],
            MediaType mediaType,
            MultivaluedMap<String, String> httpHeaders,
            InputStream entityStream) throws IOException {
        try {
            WireFeedInput input = new WireFeedInput();                     
            WireFeed wireFeed = input.build(new InputStreamReader(entityStream));   
            if (!(wireFeed instanceof Feed)) {
                throw new IOException(ImplMessages.ERROR_NOT_ATOM_FEED(type));
            }
            return (Feed)wireFeed;
        } catch (FeedException cause) {
View Full Code Here

      this.timeToLoad = "Quad Tree fully loaded from index files in "
          + Double.toString((endTime - startTime) / 1000L) + " seconds";
      System.out.println("[INFO] Finished loading tree from stored index");
    } else {
      startTime = System.currentTimeMillis();
      WireFeedInput wf = new WireFeedInput(true);
      // read quad tree properties set in config xml file
      InputStream configStream = null;
      try {
        configStream = new FileInputStream(this.context
            .getInitParameter("org.apache.sis.services.config.filePath"));
      } catch (Exception e) {
        e.printStackTrace();
      }

      if (configStream != null) {
        DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
        try {
          DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
          Document configDoc = docBuilder.parse(configStream);
          NodeList capacityNode = configDoc.getElementsByTagName("capacity");
          if (capacityNode.item(0) != null) {
            capacity = Integer.parseInt(capacityNode.item(0).getFirstChild()
                .getNodeValue());
          }

          NodeList depthNode = configDoc.getElementsByTagName("depth");
          if (depthNode.item(0) != null) {
            depth = Integer.parseInt(depthNode.item(0).getFirstChild()
                .getNodeValue());
          }
          this.tree = new QuadTree(capacity, depth); // TODO make this
          // configurable

          NodeList urlNodes = configDoc.getElementsByTagName("url");
          for (int i = 0; i < urlNodes.getLength(); i++) {
            // read in georss and build tree
            String georssUrlStr = urlNodes.item(i).getFirstChild()
                .getNodeValue();
            WireFeed feed = null;
            try {
              feed = wf.build(new XmlReader(new URL(georssUrlStr)));
            } catch (Exception e) {
              System.out.println("[ERROR] Error obtaining geodata url: ["
                  + georssUrlStr + "]: Message: "+e.getMessage()+": skipping and continuing");
              continue;
            }
View Full Code Here

      this.timeToLoad = "Quad Tree fully loaded from index files in "
          + Double.toString((endTime - startTime) / 1000L) + " seconds";
      System.out.println("[INFO] Finished loading tree from stored index");
    } else {
      startTime = System.currentTimeMillis();
      WireFeedInput wf = new WireFeedInput(true);
      // read quad tree properties set in config xml file
      InputStream configStream = null;
      try {
        configStream = new FileInputStream(this.context
            .getInitParameter("org.apache.sis.services.config.filePath"));
      } catch (Exception e) {
        e.printStackTrace();
      }

      if (configStream != null) {
        DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
        try {
          DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
          Document configDoc = docBuilder.parse(configStream);
          NodeList capacityNode = configDoc.getElementsByTagName("capacity");
          if (capacityNode.item(0) != null) {
            capacity = Integer.parseInt(capacityNode.item(0).getFirstChild()
                .getNodeValue());
          }

          NodeList depthNode = configDoc.getElementsByTagName("depth");
          if (depthNode.item(0) != null) {
            depth = Integer.parseInt(depthNode.item(0).getFirstChild()
                .getNodeValue());
          }
          this.tree = new QuadTree(capacity, depth); // TODO make this
          // configurable

          NodeList urlNodes = configDoc.getElementsByTagName("url");
          for (int i = 0; i < urlNodes.getLength(); i++) {
            // read in georss and build tree
            String georssUrlStr = urlNodes.item(i).getFirstChild()
                .getNodeValue();
            WireFeed feed = null;
            try {
              feed = wf.build(new XmlReader(new URL(georssUrlStr)));
            } catch (Exception e) {
              System.out.println("[ERROR] Error obtaining geodata url: ["
                  + georssUrlStr + "]: Message: "+e.getMessage()+": skipping and continuing");
              continue;
            }
View Full Code Here

  @Override
  @SuppressWarnings("unchecked")
  protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
      throws IOException, HttpMessageNotReadableException {
    WireFeedInput feedInput = new WireFeedInput();
    MediaType contentType = inputMessage.getHeaders().getContentType();
    Charset charset;
    if (contentType != null && contentType.getCharSet() != null) {
      charset = contentType.getCharSet();
    } else {
      charset = DEFAULT_CHARSET;
    }
    try {
      Reader reader = new InputStreamReader(inputMessage.getBody(), charset);
      return (T) feedInput.build(reader);
    }
    catch (FeedException ex) {
      throw new HttpMessageNotReadableException("Could not read WireFeed: " + ex.getMessage(), ex);
    }
  }
View Full Code Here

        Element rollerElement = fetchedEntryElement.getChild("atom-draft", ns);
        if (rollerElement == null) {
            mLogger.debug("Client is NOT preserving foreign markup");
        }
       
        WireFeedInput input = new WireFeedInput();
        Feed parsedFeed = (Feed)input.build(feedDoc);
        return (Entry)parsedFeed.getEntries().get(0);
    }
View Full Code Here

        SAXBuilder saxBuilder = new SAXBuilder(false);
        return saxBuilder.build(getFeedReader());
    }

    protected WireFeed getWireFeed() throws Exception {
        WireFeedInput in = new WireFeedInput();
        return in.build(getFeedReader());
    }
View Full Code Here

        assertEquals(1, hellos); // if content:encoded is more than one this should fail
    }

    public void testRead() throws Exception {
        Reader r = new StringReader(createFeed());
        WireFeedInput input = new WireFeedInput();
        Channel ch = (Channel) input.build(r);
    }
View Full Code Here

        Channel ch = (Channel) input.build(r);
    }

    public void testReadWrite() throws Exception {
        Reader r = new StringReader(createFeed());
        WireFeedInput input = new WireFeedInput();
        Channel channel = (Channel) input.build(r);
        StringWriter sw = new StringWriter();
        WireFeedOutput output = new WireFeedOutput();
        output.output(channel, sw);
        sw.close();
        r = new StringReader(sw.toString());
        channel = (Channel) input.build(r);
        sw = new StringWriter();
        output.output(channel, sw);
        sw.close();
        System.out.println(sw);
    }
View Full Code Here

    public static void main(String[] args) {
        boolean ok = false;
        if (args.length==1) {
            try {
                URL feedUrl = new URL(args[0]);
                WireFeedInput input = new WireFeedInput();

                WireFeed feed = input.build(new XmlReader(feedUrl));

                System.out.println(feed);

                ok = true;
            }
View Full Code Here

TOP

Related Classes of com.sun.syndication.io.WireFeedInput

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.