18 package org.turro.elephant.impl.context;
20 import java.util.ArrayList;
21 import java.util.Date;
22 import java.util.HashSet;
23 import java.util.List;
25 import org.turro.string.ObjectString;
26 import org.turro.string.Strings;
27 import org.turro.elephant.context.IConstructor;
28 import org.turro.util.PhraseBuilder;
35 public static final int
42 public String
name, value, defaultValue;
49 value.booleanValue() ?
"true" :
"false",
51 defaultValue.booleanValue() ?
"true" :
"false");
57 ObjectString.formatNativeObject(value,
true),
59 ObjectString.formatNativeObject(defaultValue,
true));
65 ObjectString.formatObject(value, ObjectString.COMPRESSED_DATE_PATTERN,
true),
67 ObjectString.formatObject(defaultValue, ObjectString.COMPRESSED_DATE_PATTERN,
true));
75 this.defaultValue = defaultValue;
86 if(value ==
null)
return defaultValue;
91 if(value ==
null)
return defaultValue;
100 return ((Double) ObjectString.parseNativeString(
getValue(), Double.class,
true)).doubleValue();
111 return ((Integer) ObjectString.parseNativeString(
getValue(), Integer.class,
true)).intValue();
122 return ((Long) ObjectString.parseNativeString(
getValue(), Long.class,
true)).longValue();
134 return "true".equals(v);
145 this.value = value ?
"true" :
"false";
150 return (Date) ObjectString.parseString(v, ObjectString.COMPRESSED_DATE_PATTERN, Date.class,
false);
164 public <T extends Enum<T>> Set getEnumSet(Class<T> javaClass) {
165 Set
set =
new HashSet();
166 if(javaClass.isEnum() && !Strings.isBlank(value)) {
167 for(Enum enumVal: javaClass.getEnumConstants()) {
168 if(value.contains(enumVal.toString())) {
181 private static String format(String[] values) {
183 PhraseBuilder pb =
new PhraseBuilder();
184 for(String s : values) {
186 pb.addPendingSeparator(
",");
188 return pb.toString();
void setValue(String value)
void addChoice(String choice)
static AttributeItem getFromParameter(IConstructor constructor, String name, String defaultValue)
double getDoubleValue(double defaultValue)
long getLongValue(long defaultValue)
String getValue(String defaultValue)
AttributeItem(String name, Date value, Date defaultValue)
boolean getBooleanValue()
Date getDateValue(Date defaultValue)
void setBooleanValue(boolean value)
AttributeItem(String name, Boolean value, Boolean defaultValue)
int getIntegerValue(int defaultValue)
static final int STRING_ATTR
AttributeItem(String name, String value, int type, String defaultValue)
AttributeItem(String name, Number value, Number defaultValue)
boolean getBooleanValue(boolean defaultValue)
String[] getParameterValues(String param)