Package org.apache.lucene.facet.index.attributes

Examples of org.apache.lucene.facet.index.attributes.CategoryAttribute


     * This method is a special case of addCategory with multiple
     * properties, but it is kept here for two reasons: 1) Using the array
     * version has some performance cost, and 2) it is expected that most
     * calls will be for this version (single property).
     */
    CategoryAttribute ca = mapCategoryAttribute(categoryPath);
    ca.addProperty(property);
    return ca;
  }
View Full Code Here


   *             one of the new properties, and merging for this property type
   *             is prohibited.
   */
  public CategoryAttribute addCategory(CategoryPath categoryPath,
      CategoryProperty... properties) throws FacetException {
    CategoryAttribute ca = mapCategoryAttribute(categoryPath);
    for (CategoryProperty attribute : properties) {
      ca.addProperty(attribute);
    }
    return ca;
  }
View Full Code Here

   *         from the one provided).
   * @throws FacetException
   */
  public CategoryAttribute addCategory(CategoryAttribute categoryAttribute)
  throws FacetException {
    CategoryAttribute ca = mapCategoryAttribute(categoryAttribute
        .getCategoryPath());
    Set<Class<? extends CategoryProperty>> propertyClasses = categoryAttribute
    .getPropertyClasses();
    if (propertyClasses != null) {
      for (Class<? extends CategoryProperty> propertyClass : propertyClasses) {
        ca.addProperty(categoryAttribute.getProperty(propertyClass));
      }
    }
    return ca;
  }
View Full Code Here

   * Get the {@link CategoryAttribute} object for a specific
   * {@link CategoryPath}, from the map.
   */
  private final CategoryAttribute mapCategoryAttribute(
      CategoryPath categoryPath) {
    CategoryAttribute ca = map.get(categoryPath);
    if (ca == null) {
      ca = new CategoryAttributeImpl(categoryPath);
      map.put(categoryPath, ca);
    }
    return ca;
View Full Code Here

    // count the number of tokens, and check there is one DummyAttribute
    int nCategories;
    int nProperties = 0;
    for (nCategories = 0; iterator.hasNext(); nCategories++) {
      CategoryAttribute attribute = iterator.next();
      if (attribute.getProperty(DummyProperty.class) != null) {
        nProperties++;
      }
    }
    assertEquals("Wrong number of tokens", 3, nCategories);
    assertEquals("Wrong number of tokens with properties", 1, nProperties);
View Full Code Here

    // count the number of tokens, and check there is one DummyAttribute
    int nCategories;
    int nDummyAttributes = 0;
    int nAssocAttributes = 0;
    for (nCategories = 0; iterator.hasNext(); nCategories++) {
      CategoryAttribute attribute = iterator.next();
      if (attribute.getProperty(DummyProperty.class) != null) {
        nDummyAttributes++;
      }
      if (attribute.getProperty(AssociationIntProperty.class) != null) {
        nAssocAttributes++;
      }
    }
    assertEquals("Wrong number of tokens", 5, nCategories);
    assertEquals("Wrong number of tokens with dummy properties", 3,
View Full Code Here

    // count the number of tokens, and check there is one DummyAttribute
    int nCategories;
    int nProperties = 0;
    for (nCategories = 0; iterator.hasNext(); nCategories++) {
      CategoryAttribute attribute = iterator.next();
      if (attribute.getProperty(DummyProperty.class) != null) {
        nProperties++;
      }
    }
    assertEquals("Wrong number of tokens", 4, nCategories);
    assertEquals("Wrong number of tokens with properties", 1, nProperties);
View Full Code Here

   * @throws FacetException
   */
  @Test
  public void testAddCategoryAttributeWithoutProperties()
      throws FacetException {
    CategoryAttribute newCA = new CategoryAttributeImpl(new CategoryPath(
        "seven", "eight"));
    categoryContainer.addCategory(newCA);
  }
View Full Code Here

   *
   * @throws FacetException
   */
  @Test
  public void testAddCategoryAttributeWithProperty() throws FacetException {
    CategoryAttribute newCA = new CategoryAttributeImpl(new CategoryPath(
        "seven", "eight"));
    newCA.addProperty(new DummyProperty());
    categoryContainer.addCategory(newCA);
    Iterator<CategoryAttribute> iterator = categoryContainer.iterator();

    // count the number of tokens, and check there is one DummyAttribute
    int nCategories;
    int nProperties = 0;
    for (nCategories = 0; iterator.hasNext(); nCategories++) {
      CategoryAttribute attribute = iterator.next();
      if (attribute.getProperty(DummyProperty.class) != null) {
        nProperties++;
      }
    }
    assertEquals("Wrong number of tokens", 4, nCategories);
    assertEquals("Wrong number of tokens with properties", 1, nProperties);
View Full Code Here

    Iterator<CategoryAttribute> iterator = categoryContainer.iterator();

    int nCategories;
    int nAssociations = 0;
    for (nCategories = 0; iterator.hasNext(); nCategories++) {
      CategoryAttribute ca = iterator.next();
      AssociationProperty aa = (AssociationProperty) ca
          .getProperty(AssociationIntProperty.class);
      if (aa != null) {
        assertEquals("Wrong association value", 17, aa.getAssociation());
        nAssociations++;
      }
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.index.attributes.CategoryAttribute

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.