package chat.module.friendcircle;
|
|
import java.util.HashSet;
|
import java.util.Set;
|
|
import frame.util.ContentBuilder;
|
|
public class LabeList {
|
|
public static String Spliter = "#";
|
private Set<String> items;
|
private String value;
|
|
|
public LabeList() {
|
items = new HashSet<String>();
|
value = null;
|
}
|
|
public void addone(String label) {
|
if (label == null) {
|
return;
|
}
|
|
items.add(label);
|
value = null;
|
}
|
|
public synchronized String getValue() {
|
if (value == null) {
|
value = createValue();
|
}
|
|
return value;
|
}
|
|
private String createValue() {
|
if (items.isEmpty()) {
|
return "";
|
}
|
|
ContentBuilder builder = new ContentBuilder(Spliter);
|
|
for (String label: items) {
|
builder.append(label);
|
}
|
|
return Spliter + builder.toString();
|
}
|
|
public void load(String value) {
|
if (value == null) {
|
return;
|
}
|
|
value = value.trim();
|
|
String[] segments = value.split("#");
|
|
for (String segment: segments) {
|
segment = segment.trim();
|
|
if ("".equals(segment)) {
|
continue;
|
}
|
|
items.add(segment);
|
}
|
}
|
}
|