Package org.rssowl.core.tests.controller

Source Code of org.rssowl.core.tests.controller.InMemoryProtocolHandler

/*   **********************************************************************  **
**   Copyright notice                                                       **
**                                                                          **
**   (c) 2005-2006 RSSOwl Development Team                                  **
**   http://www.rssowl.org/                                                 **
**                                                                          **
**   All rights reserved                                                    **
**                                                                          **
**   This program and the accompanying materials are made available under   **
**   the terms of the Eclipse Public License v1.0 which accompanies this    **
**   distribution, and is available at:                                     **
**   http://www.rssowl.org/legal/epl-v10.html                               **
**                                                                          **
**   A copy is found in the file epl-v10.html and important notices to the  **
**   license from the team is found in the textfile LICENSE.txt distributed **
**   in this package.                                                       **
**                                                                          **
**   This copyright notice MUST APPEAR in all copies of the file!           **
**                                                                          **
**   Contributors:                                                          **
**     RSSOwl Development Team - initial API and implementation             **
**                                                                          **
**  **********************************************************************  */

package org.rssowl.core.tests.controller;

import org.osgi.service.url.AbstractURLStreamHandlerService;
import org.osgi.service.url.URLStreamHandlerService;
import org.rssowl.core.connection.ConnectionException;
import org.rssowl.core.connection.IProtocolHandler;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Map;

/**
* Protocol-Handler to return a Feed from In-Memory.
*
* @author bpasero
*/
public class InMemoryProtocolHandler implements IProtocolHandler {
  static String FEED;

  /*
   * @see org.rssowl.core.connection.IProtocolHandler#load(java.net.URL)
   */
  public InputStream load(URL url) throws ConnectionException {
    return load(url, null);
  }

  /*
   * @see org.rssowl.core.connection.IProtocolHandler#load(java.net.URL,
   * java.util.Map)
   */
  @SuppressWarnings("unused")
  public InputStream load(URL url, Map<Object, Object> properties) throws ConnectionException {
    if (FEED != null)
      return new ByteArrayInputStream(FEED.getBytes());

    return null;
  }

  /*
   * @see org.rssowl.core.connection.IProtocolHandler#getURLStreamHandler()
   */
  @SuppressWarnings("unused")
  public URLStreamHandlerService getURLStreamHandler() throws ConnectionException {
    return new AbstractURLStreamHandlerService() {

      @SuppressWarnings("unused")
      @Override
      public URLConnection openConnection(URL u) throws IOException {
        return null;
      }
    };
  }
}
TOP

Related Classes of org.rssowl.core.tests.controller.InMemoryProtocolHandler

TOP
Copyright © 2018 www.massapi.com. 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.