Class TagsProcessor

java.lang.Object
org.pipservices4.commons.data.TagsProcessor

public class TagsProcessor extends Object
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 Details

    • TagsProcessor

      public TagsProcessor()
  • Method Details

    • normalizeTag

      public static String normalizeTag(String tag)
      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

      public static String compressTag(String tag)
      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

      public static Boolean equalTags(String tag1, String tag2)
      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

      public static List<String> normalizeTags(List<String> tags)
      Normalizes a list of tags.
      Parameters:
      tags - the tags to normalize.
      Returns:
      a list with normalized tags.
    • normalizeTagList

      public static List<String> normalizeTagList(String tagList)
      Normalizes a comma-separated list of tags.
      Parameters:
      tagList - a comma-separated list of tags to normalize.
      Returns:
      a list with normalized tags.
    • compressTags

      public static List<String> compressTags(List<String> tags)
      Compresses a list of tags.
      Parameters:
      tags - the tags to compress.
      Returns:
      a list with normalized tags.
    • compressTagList

      public static List<String> compressTagList(String tagList)
      Compresses a comma-separated list of tags.
      Parameters:
      tagList - a comma-separated list of tags to compress.
      Returns:
      a list with compressed tags.
    • extractHashTags

      public static List<String> extractHashTags(String text)
      Extracts hash tags from a text.
      Parameters:
      text - a text that contains hash tags
      Returns:
      a list with extracted and compressed tags.
    • extractHashTagsFromValue

      public static List<String> extractHashTagsFromValue(Object obj, List<String> searchFields)
      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.