예제 #1
0
  // returns whether this item needs to be added (passes filters) or not
  private boolean runFilterOnPost(JDFeedMeFeed feed, JDFeedMePost post, String post_description) {
    // see if we even need to run filters
    if (!feed.getDoFilters()) return true;

    // let's run our filters
    if (feed.getFiltersearchtitle() || feed.getFiltersearchdesc()) {
      // we need to check something, prepare the checker
      FilterChecker filter = new FilterChecker(feed.getFilters());

      // check title if needed
      if (feed.getFiltersearchtitle()) {
        if (filter.match(post.getTitle())) {
          if (JDFeedMe.VERBOSE)
            logger.info("JDFeedMe new item title: [" + post.getTitle() + "] passed filters");
          return true;
        }
      }

      // check description if needed
      if (feed.getFiltersearchdesc()) {
        if (filter.match(post_description)) {
          if (JDFeedMe.VERBOSE)
            logger.info("JDFeedMe new item description: [" + post_description + "] passed filters");
          return true;
        }
      }
    }

    // if here then nothing passed
    return false;
  }
예제 #2
0
  /**
   * Creating a TestEnvironment for the interfaces to be tested. Creates an instance of the service
   * <code>com.sun.star.comp.Chart.XMLExporter</code> with argument which is an implementation of
   * <code>XDocumentHandler</code> and which can check if required tags and character data is
   * exported.
   *
   * <p>The chart document is set as a source document for exporter created. A new 'main title' is
   * set for chart. This made for checking if this title is successfully exported within the
   * document content. Object relations created :
   *
   * <ul>
   *   <li><code>'MediaDescriptor'</code> for {@link ifc.document._XFilter} interface
   *   <li><code>'XFilter.Checker'</code> for {@link ifc.document._XFilter} interface
   *   <li><code>'SourceDocument'</code> for {@link ifc.document._XExporter} interface
   * </ul>
   */
  @Override
  public TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log)
      throws Exception {

    XMultiServiceFactory xMSF = tParam.getMSF();
    XInterface oObj = null;
    final String exportStr = "XMLExporter test.";

    FilterChecker filter = new FilterChecker(log);
    Any arg = new Any(new Type(XDocumentHandler.class), filter);

    oObj =
        (XInterface)
            xMSF.createInstanceWithArguments(
                "com.sun.star.comp.Chart.XMLExporter", new Object[] {arg});
    XExporter xEx = UnoRuntime.queryInterface(XExporter.class, oObj);
    xEx.setSourceDocument(xChartDoc);

    Object oTitle = xChartDoc.getTitle();
    XPropertySet xTitleProp = UnoRuntime.queryInterface(XPropertySet.class, oTitle);
    xTitleProp.setPropertyValue("String", exportStr);

    filter.addTag(new XMLTools.Tag("office:document"));
    filter.addTagEnclosed(new XMLTools.Tag("office:meta"), new XMLTools.Tag("office:document"));
    filter.addTagEnclosed(new XMLTools.Tag("office:body"), new XMLTools.Tag("office:document"));
    filter.addCharactersEnclosed(exportStr, new XMLTools.Tag("chart:title"));

    // create testobject here
    log.println("creating a new environment");
    TestEnvironment tEnv = new TestEnvironment(oObj);

    tEnv.addObjRelation(
        "MediaDescriptor",
        XMLTools.createMediaDescriptor(
            new String[] {"FilterName"}, new Object[] {"schart: StarOffice XML (Chart)"}));
    tEnv.addObjRelation("SourceDocument", xChartDoc);
    tEnv.addObjRelation("XFilter.Checker", filter);
    log.println("Implementation Name: " + util.utils.getImplName(oObj));

    return tEnv;
  }