All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xq.gwt.mvc.model.StringArrayPropertyModel Maven / Gradle / Ivy

package xq.gwt.mvc.model;

public class StringArrayPropertyModel extends AbstractPropertyModel {
	
	private static final long serialVersionUID = 1326038312150303600L;
	String[] value;
	private String separator = ";";

	@Override
	public Object getObjectValue() {		
		return getValue();
	}

	@Override
	public Class getPropertyType() {		
		return String[].class;
	}

	
	
	public String[] getValue() {
		return value;
	}

	public void setValue(String[] value) {
		String[] oldValue = this.value;
		this.value = value;
		notifyPropertyChanged(oldValue, this.value);
	}

	@Override
	public String getText() {
		if(getValue() == null)
			return null;
		
		if(getValue().length == 0)
			return "";
				
		String text = "";		
		for (int i = 0; i < getValue().length; i++) {
			text += getValue()[i] + separator;
		}		
		text = text.substring(0,text.lastIndexOf(separator));
		return text;
	}

	@Override
	public void setText(String text) throws ConversionException {
		if(text == null){
			setValue(null);
			return;
		}
		String[] val = text.split(separator);
		setValue(val);
	}

	public String getSeparator() {
		return separator;
	}

	public void setSeparator(String separator) {
		this.separator = separator;
	}
	
	
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy