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; }
public int compare(Tag a, Tag b) { return a.normalizedValue().compareTo(b.normalizedValue()); }