Package com.sun.syndication.feed.module.opensearch

Examples of com.sun.syndication.feed.module.opensearch.OpenSearchModule


   
    @SuppressWarnings("unchecked")
    List<SyndEntry> entries = syndFeed.getEntries();
    assertEquals(1,entries.size());
   
    OpenSearchModule mod = (OpenSearchModule)syndFeed.getModule(OpenSearchModule.URI);
    assertNotNull(mod);
    assertEquals(10,mod.getItemsPerPage());
    assertEquals(0,mod.getStartIndex());
    assertEquals(1,mod.getTotalResults());
  }
View Full Code Here


    assertNotNull(syndFeed);
   
    syndFeed = SyndFeedFactory.addOpenSearchModule(syndFeed, itemsPerPage,
        startIndex, totalResult, searchDescriptionUrl);
 
    OpenSearchModule osm = (OpenSearchModule) syndFeed.getModule(OpenSearchModule.URI);
    assertEquals(itemsPerPage,osm.getItemsPerPage());
    assertEquals(totalResult,osm.getTotalResults());
    assertEquals(startIndex,osm.getStartIndex());
    assertEquals(searchDescriptionUrl,osm.getLink().getHref());
  }
View Full Code Here

    List<Module> mods = null;
    mods = feed.getModules();
    if(mods == null){
      mods = new ArrayList<Module>();
    }
    OpenSearchModule osm = new OpenSearchModuleImpl();
    osm.setItemsPerPage(itemsPerPage);
    osm.setStartIndex(startIdx);
    osm.setTotalResults(totalResult);
    if(searchDescriptionUrl != null){
      Link link = new Link();
      link.setHref(searchDescriptionUrl);
      link.setType("application/opensearchdescription+xml");
      osm.setLink(link);
    }
    mods.add(osm);
    feed.setModules(mods);
    return feed;
  }
View Full Code Here

  public static JSONObject createJsonResult(SyndFeed feed){   
    Map<String,Object> map = new HashMap<String, Object>();
    map.put(KEY_TITLE, feed.getTitle());
    map.put(KEY_LINK,feed.getLink());
    map.put(KEY_ID,feed.getUri());
    OpenSearchModule osMod = (OpenSearchModule) feed.getModule(OpenSearchModule.URI);
    if(osMod != null){
      map.put(KEY_ITEMS_PER_PAGE,osMod.getItemsPerPage());
      map.put(KEY_TOTAL_RESULTS,osMod.getTotalResults());
      map.put(KEY_START_INDEX,osMod.getStartIndex());
    }
    List<Map<String,Object>> entries = new ArrayList<Map<String,Object>>();
    List<SyndEntry> syndEntries = feed.getEntries();
    for(SyndEntry e : syndEntries){
      Map<String, Object> entryMap = new HashMap<String, Object>();
View Full Code Here

     * @param qRes the search results
     * @return module
     */
    private static OpenSearchModule openSearchMarkup(String query, QueryResults qRes)
    {
      OpenSearchModule osMod = new OpenSearchModuleImpl();
      osMod.setTotalResults(qRes.getHitCount());
      osMod.setStartIndex(qRes.getStart());
      osMod.setItemsPerPage(qRes.getPageSize());
      OSQuery osq = new OSQuery();
      osq.setRole("request");
        try
        {
            osq.setSearchTerms(URLEncoder.encode(query, "UTF-8"));
          }
        catch(UnsupportedEncodingException e)
          {
            log.error(e);
          }
        osq.setStartPage(1 + (qRes.getStart() / qRes.getPageSize()));
        osMod.addQuery(osq);
        return osMod;
          }
View Full Code Here

     * @param qRes the search results
     * @return module
     */
    private static OpenSearchModule openSearchMarkup(String query, int totalResults, int start, int pageSize)
    {
      OpenSearchModule osMod = new OpenSearchModuleImpl();
      osMod.setTotalResults(totalResults);
      osMod.setStartIndex(start);
      osMod.setItemsPerPage(pageSize);
      OSQuery osq = new OSQuery();
      osq.setRole("request");
        try
        {
            osq.setSearchTerms(URLEncoder.encode(query, "UTF-8"));
        }
        catch(UnsupportedEncodingException e)
        {
            log.error(e);
        }
        osq.setStartPage(1 + (start / pageSize));
        osMod.addQuery(osq);
        return osMod;
    }
View Full Code Here

TOP

Related Classes of com.sun.syndication.feed.module.opensearch.OpenSearchModule

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.