Package org.pipservices4.commons.data
Class TagsProcessor
java.lang.Object
org.pipservices4.commons.data.TagsProcessor
Helper class to extract and process search tags from objects.
The search tags can be kept individually or embedded as hash tags inside text
like "This text has #hash_tag that can be used for search."
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcompressTag(String tag) Compress a tag by removing special symbols like spaces, '_' and '#' and converting the tag to lower case.compressTagList(String tagList) Compresses a comma-separated list of tags.compressTags(List<String> tags) Compresses a list of tags.static BooleanCompares two tags using their compressed form.extractHashTags(String text) Extracts hash tags from a text.extractHashTagsFromValue(Object obj, List<String> searchFields) Extracts hash tags from selected fields in an object.static StringnormalizeTag(String tag) Normalizes a tag by replacing special symbols like '_' and '#' with spaces.normalizeTagList(String tagList) Normalizes a comma-separated list of tags.normalizeTags(List<String> tags) Normalizes a list of tags.
-
Constructor Details
-
TagsProcessor
public TagsProcessor()
-
-
Method Details
-
normalizeTag
Normalizes a tag by replacing special symbols like '_' and '#' with spaces. When tags are normalized then can be presented to user in similar shape and form.- Parameters:
tag- the tag to normalize.- Returns:
- a normalized tag.
-
compressTag
Compress a tag by removing special symbols like spaces, '_' and '#' and converting the tag to lower case. When tags are compressed they can be matched in search queries.- Parameters:
tag- the tag to compress.- Returns:
- a compressed tag.
-
equalTags
Compares two tags using their compressed form.- Parameters:
tag1- the first tag.tag2- the second tag.- Returns:
- true if the tags are equal and false otherwise.
-
normalizeTags
Normalizes a list of tags.- Parameters:
tags- the tags to normalize.- Returns:
- a list with normalized tags.
-
normalizeTagList
Normalizes a comma-separated list of tags.- Parameters:
tagList- a comma-separated list of tags to normalize.- Returns:
- a list with normalized tags.
-
compressTags
Compresses a list of tags.- Parameters:
tags- the tags to compress.- Returns:
- a list with normalized tags.
-
compressTagList
Compresses a comma-separated list of tags.- Parameters:
tagList- a comma-separated list of tags to compress.- Returns:
- a list with compressed tags.
-
extractHashTags
Extracts hash tags from a text.- Parameters:
text- a text that contains hash tags- Returns:
- a list with extracted and compressed tags.
-
extractHashTagsFromValue
Extracts hash tags from selected fields in an object.- Parameters:
obj- an object which contains hash tags.searchFields- a list of fields in the objects where to extract tags- Returns:
- a list of extracted and compressed tags.
-