package com.akjava.lib.common.tag;

public class LabelAndValue {
public LabelAndValue(String value){
	this(null,value,false);
}
public LabelAndValue(String label,String value){
	this(label,value,false);
}
public LabelAndValue(String label, String value,boolean selected) {
	this.label=label;
	this.value=value;
	this.selected=selected;
}
private boolean selected;
public boolean isSelected() {
	return selected;
}
public void setSelected(boolean selected) {
	this.selected = selected;
}
private String label;
private String value;
public String getLabel() {
	return label;
}
public void setLabel(String label) {
	this.label = label;
}
public String getValue() {
	return value;
}
public void setValue(String value) {
	this.value = value;
}

public String getPrintValue(){
	if(label==null){
		return value;
	}else{
		return label;
	}
}

public String toString(){
	String out="";
	if(label!=null){
		out=label+":"+value;
	}else{
		out=value;
	}
	if(selected){
		out+=":"+true;
	}
	return out;
}

public String toOption(){
	String option="<option";
	String outValue=value;
	String selectValue="";
	if(selected){
		selectValue=" selected";
	}
	if(outValue.indexOf('"')!=-1){
		outValue=outValue.replace("\"", "&quot;");
	}
	if(label!=null){
		option+=" value=\""+outValue+"\"";
		option+=selectValue+">";
		option+=label;
	}else{
		option+=selectValue+">"+value;
	}

	return option;
}

//for edit
public LabelAndValue clone(){
	return new LabelAndValue(label,value,selected);
}

}

@@ -27,24 +27,122 @@
 mon.tag;%0D%0A%0D%0A
+import java.util.ArrayList;%0D%0Aimport java.util.List;%0D%0A%0D%0Aimport com.google.common.collect.Lists;%0D%0A%0D%0A
 public class
@@ -1133,32 +1133,523 @@
 turn out;%0D%0A%7D%0D%0A%0D%0A
+public static void selectValues(List%3CLabelAndValue%3E lvalues,String value,String splitValue)%7B%0D%0A%09if(value==null)%7B%0D%0A%09%09return;%0D%0A%09%7D%0D%0A%09List%3CString%3E multipleValue=null;%0D%0A%09if(splitValue==null)%7B%0D%0A%09%09multipleValue=new ArrayList%3CString%3E();%0D%0A%09%09multipleValue.add(value);%0D%0A%09%7Delse%7B%0D%0A%09%09multipleValue= Lists.newArrayList(value.split(splitValue));%0D%0A%09%7D%0D%0A%0D%0A%09for (LabelAndValue lv : lvalues) %7B%0D%0A%09%09for (String v : multipleValue) %7B%0D%0A%09%09%09if (lv.getValue().equals(v)) %7B%0D%0A%09%09%09%09lv.setSelected(true);%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%7D%0D%0A%0D%0A
 public String to

add set method