[New] added parseFromString()-methods to all Parameter implementations
This commit is contained in:
parent
d043c59910
commit
7289dccdfc
|
@ -72,7 +72,7 @@ public class BooleanParameter extends AbstractParameter<Boolean> {
|
||||||
throw new StrolchException(msg);
|
throw new StrolchException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(Boolean.valueOf(valueS));
|
setValue(parseFromString(valueS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -106,4 +106,8 @@ public class BooleanParameter extends AbstractParameter<Boolean> {
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Boolean parseFromString(String valueS) {
|
||||||
|
return Boolean.valueOf(valueS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class DateParameter extends AbstractParameter<Date> {
|
||||||
throw new StrolchException(msg);
|
throw new StrolchException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(ISO8601FormatFactory.getInstance().getDateFormat().parse(valueS));
|
setValue(parseFromString(valueS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,4 +109,8 @@ public class DateParameter extends AbstractParameter<Date> {
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Date parseFromString(String valueS) {
|
||||||
|
return ISO8601FormatFactory.getInstance().getDateFormat().parse(valueS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class FloatParameter extends AbstractParameter<Double> {
|
||||||
throw new StrolchException(msg);
|
throw new StrolchException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(Double.valueOf(valueS));
|
setValue(parseFromString(valueS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,4 +109,8 @@ public class FloatParameter extends AbstractParameter<Double> {
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Double parseFromString(String valueS) {
|
||||||
|
return Double.valueOf(valueS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class IntegerParameter extends AbstractParameter<Integer> {
|
||||||
throw new StrolchException(msg);
|
throw new StrolchException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(Integer.valueOf(valueS));
|
setValue(parseFromString(valueS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,4 +108,8 @@ public class IntegerParameter extends AbstractParameter<Integer> {
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Integer parseFromString(String valueS) {
|
||||||
|
return Integer.valueOf(valueS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,11 @@ package li.strolch.model.parameter;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
|
|
||||||
import li.strolch.exception.StrolchException;
|
import li.strolch.exception.StrolchException;
|
||||||
import li.strolch.model.Tags;
|
import li.strolch.model.Tags;
|
||||||
|
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import ch.eitchnet.utils.helper.StringHelper;
|
import ch.eitchnet.utils.helper.StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +57,7 @@ public class LongParameter extends AbstractParameter<Long> {
|
||||||
*/
|
*/
|
||||||
public LongParameter(String id, String name, Long value) {
|
public LongParameter(String id, String name, Long value) {
|
||||||
super(id, name);
|
super(id, name);
|
||||||
setValue(Long.valueOf(value));
|
setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,7 +74,7 @@ public class LongParameter extends AbstractParameter<Long> {
|
||||||
throw new StrolchException(msg);
|
throw new StrolchException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(Long.valueOf(valueS));
|
setValue(parseFromString(valueS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,4 +108,8 @@ public class LongParameter extends AbstractParameter<Long> {
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Long parseFromString(String valueS) {
|
||||||
|
return Long.valueOf(valueS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,12 @@ import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
|
|
||||||
import li.strolch.exception.StrolchException;
|
import li.strolch.exception.StrolchException;
|
||||||
import li.strolch.model.StrolchElement;
|
import li.strolch.model.StrolchElement;
|
||||||
import li.strolch.model.Tags;
|
import li.strolch.model.Tags;
|
||||||
|
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import ch.eitchnet.utils.helper.StringHelper;
|
import ch.eitchnet.utils.helper.StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,15 +80,7 @@ public class StringListParameter extends AbstractParameter<List<String>> impleme
|
||||||
throw new StrolchException(msg);
|
throw new StrolchException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(parse(valueS));
|
setValue(parseFromString(valueS));
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> parse(String value) {
|
|
||||||
if (value.isEmpty())
|
|
||||||
return Collections.emptyList();
|
|
||||||
|
|
||||||
String[] valueArr = value.split(VALUE_SEPARATOR);
|
|
||||||
return Arrays.asList(valueArr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -147,4 +140,12 @@ public class StringListParameter extends AbstractParameter<List<String>> impleme
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> parseFromString(String value) {
|
||||||
|
if (value.isEmpty())
|
||||||
|
return Collections.emptyList();
|
||||||
|
|
||||||
|
String[] valueArr = value.split(VALUE_SEPARATOR);
|
||||||
|
return Arrays.asList(valueArr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue