Пример #1
0
 public static Tagset parseTags(String tags) {
   Tagset set = new Tagset();
   for (String tag : tags.split("[\\n\\r\\s,]+")) {
     if (tag.length() != 0) {
       set.add(tag);
     }
   }
   return set;
 }
Пример #2
0
 @Override
 public boolean equals(Object o) {
   if (o == null) return false;
   if (o == this) return true;
   if (o instanceof Tagset) {
     Tagset set = (Tagset) o;
     if (set.size() != size()) {
       return false;
     }
     return set.set.equals(this.set);
   }
   return false;
 }
Пример #3
0
 public Tagset filterPrefix(String prefix, boolean positive, boolean removePrefix) {
   if (prefix == null) {
     throw new IllegalArgumentException("prefix == null");
   }
   Tagset set = new Tagset();
   for (Tag tag : this) {
     if (tag.normalizedValue().startsWith(prefix) == positive) {
       if (positive && removePrefix) {
         String str = tag.normalizedValue().substring(prefix.length());
         if (str.length() != 0) set.add(str);
       } else {
         set.add(tag);
       }
     }
   }
   return set;
 }