Package de.cxp.ocs.preprocessor.util
Class CategorySearchData
- java.lang.Object
-
- de.cxp.ocs.preprocessor.util.CategorySearchData
-
public class CategorySearchData extends Object
Takes a list of/separated category paths and splits them into separate levels. Also saves all leaf paths.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCATEGORY_LEAF_SUFFIXstatic StringCATEGORY_LVL_SUFFIXstatic StringPATH_SEPARATOR
-
Constructor Summary
Constructors Constructor Description CategorySearchData()Creates a new instance and splits the category paths into levels and leafs.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Collection<String[]> categoryPaths)Collection<String>getCategory(int lvl)Returns a category by level.Collection<String>getCategoryLeaf()Returns the leaf entries of each path.intgetCategoryLvlDepth()Returns the number of the deepest category level from the path list.voidtoSourceItem(Map<String,Object> sourceData, String categoryFieldName)Copies the data of this instance into the sourceData map.
-
-
-
Field Detail
-
CATEGORY_LEAF_SUFFIX
public static final String CATEGORY_LEAF_SUFFIX
- See Also:
- Constant Field Values
-
CATEGORY_LVL_SUFFIX
public static final String CATEGORY_LVL_SUFFIX
- See Also:
- Constant Field Values
-
PATH_SEPARATOR
public static final String PATH_SEPARATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
add
public void add(Collection<String[]> categoryPaths)
-
getCategoryLvlDepth
public int getCategoryLvlDepth()
Returns the number of the deepest category level from the path list.- Returns:
- the category depth.
-
getCategory
public Collection<String> getCategory(int lvl)
Returns a category by level.- Parameters:
lvl- the level of the category to return.- Returns:
- the category.
- Throws:
IndexOutOfBoundsException- if the level is lower than 0 or greater thangetCategoryLvlDepth()
-
getCategoryLeaf
public Collection<String> getCategoryLeaf()
Returns the leaf entries of each path.- Returns:
- the leaf entries.
-
toSourceItem
public void toSourceItem(Map<String,Object> sourceData, String categoryFieldName)
Copies the data of this instance into the sourceData map. The name of the category field is used as prefix, followed by either- _lvl_x
- _leaf
- Parameters:
sourceData- the source item where the data will be stored.categoryFieldName- the category field which is used to obtain the name of the stored fields.
-
-