Package de.nava.informa.core

Examples of de.nava.informa.core.ChannelIF


    if (this == o)
      return true;
    if (!(o instanceof ChannelIF))
      return false;

    final ChannelIF channel = (ChannelIF) o;

    final String channelTitle = channel.getTitle();
    if (title != null ? !title.equals(channelTitle) : channelTitle != null)
      return false;

    // Comparison of links uses synchronized code of Java-NET.
    // This may hurt multi-threaded applications. So, please think twice
    // before using direct comparison of links.
    final URL channelLocation = channel.getLocation();
    if (location != null ? channelLocation == null
        || !location.toString().equalsIgnoreCase(channelLocation.toString())
        : channelLocation != null)
      return false;

    final String channelDescription = channel.getDescription();
    if (description != null ? !description.equals(channelDescription)
        : channelDescription != null)
      return false;

    return true;
View Full Code Here


   * Processes record.
   *
   * @param record record to process.
   */
  protected final void processRecord(ChannelRecord record) {
    final ChannelIF channel = record.getChannel();

    // Notify observer
    observer.pollStarted(channel);

    try {
View Full Code Here

   * @throws UnsupportedFormatException
   */
  private void resolveFormat(ChannelRecord record)
    throws IOException, UnsupportedFormatException {
    // Resolve channel format.
    final ChannelIF channel = record.getChannel();

    InputStream in = getInputStream(channel, "Detecting format");
    if (in != null) {
      try {
        channel.setFormat(FormatDetector.getFormat(in));
        record.setFormatResolved(true);
      } catch (EOFException e) {
        // It can happen if the file stream is empty (from the start or as result of
        // ifModifiedSince server check) -- not an error in our case.
      }
View Full Code Here

   * @throws ParseException
   */
  private void checkContents(ChannelRecord record)
    throws IOException, ParseException {
    // Read channel from URL.
    final ChannelIF channel = record.getChannel();
    URL baseUrl = channel.getLocation();

    InputStream in = getInputStream(channel, "Fetching");
    if (in != null) {
      try {
        ChannelIF tempChannel = FeedParser.parse(BUILDER, createInputSource(in), baseUrl);

        // Copy channel information from newly retreived instance.
        if (!record.isCanceled() && channelHasChanged(channel, tempChannel)) {
          InformaUtils.copyChannelProperties(tempChannel, channel);
          observer.channelChanged(channel);
View Full Code Here

   *
   * @param newChannel      new channel taken from web.
   * @param record          record about currently existing channel to match against.
   */
  final void checkItems(ChannelIF newChannel, ChannelRecord record) {
    ChannelIF existingChannel = record.getChannel();
    Collection<ItemIF> items = newChannel.getItems();
    final ItemIF[] newItems = (ItemIF[]) items.toArray(new ItemIF[items.size()]);
    final Collection currentItems = existingChannel.getItems();

    boolean finish = false;
    for (int i = 0; !record.isCanceled() && !finish && i < newItems.length; i++) {
      final ItemIF newItem = newItems[i];

View Full Code Here

   * @param active - wether regular updates should be executed.
   */
  public ChannelIF addChannel(URL url, Collection<CategoryIF> categories,
                              int interval, boolean active) {

    ChannelIF channel = builder.createChannel("[uninitialized channel]");
    channel.setCategories(categories);
    channel.setLocation(url);

    channel = addChannel(channel, active, interval);
    return channel;
  }
View Full Code Here

  }

  public ChannelIF getById(long id) {
    Iterator it = channels.iterator();
    while (it.hasNext()) {
      ChannelIF channel = (ChannelIF) it.next();
      if (channel.getId() == id) {
        return channel;
      }
    }
    return null;
  }
View Full Code Here

 
  /**
   * May throw runtime HibernateException
   */
  public ChannelIF createChannel(Element channelElement, String title, String location) {
    ChannelIF obj = null;
    if (location != null) {
      Query query = session.createQuery("from Channel as channel where channel.locationString = ? ");
      query.setString(0, location);
      obj = (ChannelIF) query.uniqueResult();
    }
View Full Code Here

  public void testaddFeed() throws Exception {
    FeedManager FM = new FeedManager();

    File inpFile = new File(getDataDir(), "xmlhack-0.91.xml");
    ChannelIF channel = FeedParser.parse(new ChannelBuilder(), inpFile);
    String url = new Feed(channel).getLocation().toString();
    FeedIF feed = FM.addFeed(url);
    assertEquals(feed, FM.addFeed(url)); // same reference
  }
View Full Code Here

    FeedManager FM = new FeedManager();

    File inpFile = new File(getDataDir(), "xmlhack-0.91.xml");
    assertFalse(FM.hasFeed(""));

    ChannelIF channel = FeedParser.parse(new ChannelBuilder(), inpFile);

    String url = new Feed(channel).getLocation().toString();

    assertFalse(FM.hasFeed(url));
View Full Code Here

TOP

Related Classes of de.nava.informa.core.ChannelIF

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.