[Minor] code cleanup, and fixes in StringListParameter

This commit is contained in:
Robert von Burg 2012-11-25 18:08:56 +01:00
parent 054aa7706e
commit 6b5860c05f
17 changed files with 207 additions and 100 deletions

View File

@ -44,6 +44,19 @@ public abstract class AbstractStrolchElement implements StrolchElement {
// //
} }
/**
* Default constructor
*
* @param id
* id of this {@link StrolchElement}
* @param name
* name of this {@link StrolchElement}
*/
public AbstractStrolchElement(String id, String name) {
setId(id);
setName(name);
}
@Override @Override
public long getDbid() { public long getDbid() {
return this.dbid; return this.dbid;

View File

@ -46,20 +46,21 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
protected String type; protected String type;
/** /**
* Default constructor * Empty constructor
*/ */
protected GroupedParameterizedElement() { protected GroupedParameterizedElement() {
// //
} }
/** /**
* Default Constructor
*
* @param id * @param id
* @param name * @param name
* @param type * @param type
*/ */
protected GroupedParameterizedElement(String id, String name, String type) { protected GroupedParameterizedElement(String id, String name, String type) {
setId(id); super(id, name);
setName(name);
setType(type); setType(type);
} }
@ -82,8 +83,8 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
} }
/** /**
* Returns the {@link Parameter} with the given key from the {@link ParameterBag} with the given bagKey, or * Returns the {@link Parameter} with the given key from the {@link ParameterBag} with the given bagKey, or null if
* null if the {@link Parameter} or the {@link ParameterBag} does not exist * the {@link Parameter} or the {@link ParameterBag} does not exist
* *
* @param bagKey * @param bagKey
* the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned * the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned
@ -186,17 +187,17 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
} }
/** /**
* Returns true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the * Returns true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the given
* given bagKey * bagKey
* *
* @param bagKey * @param bagKey
* the key of the {@link ParameterBag} on which to find the {@link Parameter} * the key of the {@link ParameterBag} on which to find the {@link Parameter}
* @param paramKey * @param paramKey
* the key of the {@link Parameter} to be found * the key of the {@link Parameter} to be found
* *
* @return true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the * @return true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the given
* given bagKey. False is returned if the {@link ParameterBag} does not exist, or the * bagKey. False is returned if the {@link ParameterBag} does not exist, or the {@link Parameter} does not
* {@link Parameter} does not exist on the {@link ParameterBag} * exist on the {@link ParameterBag}
*/ */
public boolean hasParameter(String bagKey, String paramKey) { public boolean hasParameter(String bagKey, String paramKey) {
if (this.parameterBagMap == null) if (this.parameterBagMap == null)

View File

@ -55,6 +55,9 @@ public class Locator {
*/ */
public static final String PATH_SEPARATOR = "/"; public static final String PATH_SEPARATOR = "/";
/**
* {@link List} of path elements, with the first being the top level or root element
*/
private final List<String> pathElements; private final List<String> pathElements;
/** /**

View File

@ -54,7 +54,7 @@ public class Order extends GroupedParameterizedElement {
} }
/** /**
* Default constructor for an {@link Order} * Default Constructor
* *
* @param id * @param id
* @param name * @param name
@ -68,7 +68,7 @@ public class Order extends GroupedParameterizedElement {
} }
/** /**
* Constructor with date and {@link State} * Extended Constructor for date and {@link State}
* *
* @param id * @param id
* @param name * @param name
@ -84,7 +84,7 @@ public class Order extends GroupedParameterizedElement {
} }
/** /**
* From DOM Constructor * DOM Constructor
* *
* @param element * @param element
*/ */

View File

@ -31,7 +31,7 @@ public class ParameterBag extends ParameterizedElement {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* Constructor for special cases * Empty Constructor
*/ */
public ParameterBag() { public ParameterBag() {
// //
@ -49,7 +49,7 @@ public class ParameterBag extends ParameterizedElement {
} }
/** /**
* Constructor from DOM * DOM Constructor
* *
* @param bagElement * @param bagElement
*/ */

View File

@ -54,13 +54,15 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
protected String type; protected String type;
/** /**
* Empty constructor * Empty Constructor
*/ */
protected ParameterizedElement() { protected ParameterizedElement() {
// //
} }
/** /**
* Default Constructor
*
* @param id * @param id
* @param name * @param name
* @param type * @param type

View File

@ -28,7 +28,6 @@ import org.dom4j.tree.DefaultElement;
/** /**
* @author Robert von Burg <eitch@eitchnet.ch> * @author Robert von Burg <eitch@eitchnet.ch>
*
*/ */
public class Resource extends GroupedParameterizedElement { public class Resource extends GroupedParameterizedElement {
@ -37,13 +36,14 @@ public class Resource extends GroupedParameterizedElement {
/** /**
* Empty constructor * Empty constructor
*
*/ */
protected Resource() { public Resource() {
super(); //
} }
/** /**
* Default constructor
*
* @param id * @param id
* @param name * @param name
* @param type * @param type
@ -53,6 +53,8 @@ public class Resource extends GroupedParameterizedElement {
} }
/** /**
* DOM Constructor
*
* @param element * @param element
*/ */
public Resource(Element element) { public Resource(Element element) {

View File

@ -23,21 +23,23 @@ package li.strolch.model;
/** /**
* @author Robert von Burg <eitch@eitchnet.ch> * @author Robert von Burg <eitch@eitchnet.ch>
*
*/ */
public enum State { public enum State {
CREATED("Created"), CREATED("Created"), OPEN("Open"), EXECUTION("Execution"), CLOSED("Closed");
OPEN("Open"),
EXECUTION("Execution"),
CLOSED("Closed");
private String state; private String state;
/**
* @param state
*/
private State(String state) { private State(String state) {
this.state = state; this.state = state;
} }
/**
* @return
*/
public String getStateName() { public String getStateName() {
return this.state; return this.state;
} }

View File

@ -48,6 +48,23 @@ public abstract class AbstractParameter<T> extends AbstractStrolchElement implem
protected ParameterizedElement parent; protected ParameterizedElement parent;
/**
* Empty constructor
*/
protected AbstractParameter() {
//
}
/**
* Default constructor
*
* @param id
* @param name
*/
public AbstractParameter(String id, String name) {
super(id, name);
}
@Override @Override
public boolean isHidden() { public boolean isHidden() {
return this.hidden; return this.hidden;

View File

@ -35,18 +35,31 @@ public class BooleanParameter extends AbstractParameter<Boolean> {
public static final String TYPE = "Boolean"; public static final String TYPE = "Boolean";
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;
private Boolean value = Boolean.FALSE; private Boolean value = Boolean.FALSE;
/** /**
* Empty constructor * Empty constructor
*
*/ */
public BooleanParameter() { public BooleanParameter() {
// //
} }
/** /**
* Default constructors
*
* @param id
* @param name
* @param value
*/
public BooleanParameter(String id, String name, Boolean value) {
super(id, name);
setValue(value);
}
/**
* DOM Constructor
*
* @param element * @param element
*/ */
public BooleanParameter(Element element) { public BooleanParameter(Element element) {
@ -60,17 +73,6 @@ public class BooleanParameter extends AbstractParameter<Boolean> {
setValue(Boolean.valueOf(valueS)); setValue(Boolean.valueOf(valueS));
} }
/**
* @param id
* @param name
* @param value
*/
public BooleanParameter(String id, String name, Boolean value) {
setId(id);
setName(name);
setValue(value);
}
@Override @Override
public String getValueAsString() { public String getValueAsString() {
return this.value.toString(); return this.value.toString();

View File

@ -42,13 +42,27 @@ public class DateParameter extends AbstractParameter<Long> {
private Long value; private Long value;
/** /**
* Default constructor * Empty constructor
*/ */
public DateParameter() { public DateParameter() {
// //
} }
/** /**
* Default Constructor
*
* @param id
* @param name
* @param value
*/
public DateParameter(String id, String name, Long value) {
super(id, name);
setValue(value);
}
/**
* DOM Constructor
*
* @param element * @param element
*/ */
public DateParameter(Element element) { public DateParameter(Element element) {
@ -62,17 +76,6 @@ public class DateParameter extends AbstractParameter<Long> {
setValue(Long.valueOf(valueS)); setValue(Long.valueOf(valueS));
} }
/**
* @param id
* @param name
* @param value
*/
public DateParameter(String id, String name, Long value) {
setId(id);
setName(name);
setValue(value);
}
@Override @Override
public String getValueAsString() { public String getValueAsString() {
// TODO the format should be globally configured // TODO the format should be globally configured

View File

@ -41,13 +41,27 @@ public class FloatParameter extends AbstractParameter<Double> {
/** /**
* Empty constructor * Empty constructor
*
*/ */
public FloatParameter() { public FloatParameter() {
// //
} }
/** /**
* Default constructor
*
* @param id
* @param name
* @param value
*/
public FloatParameter(String id, String name, Double value) {
super(id, name);
setValue(value);
}
/**
* DOM Constructor
*
* @param element * @param element
*/ */
public FloatParameter(Element element) { public FloatParameter(Element element) {
@ -61,17 +75,6 @@ public class FloatParameter extends AbstractParameter<Double> {
setValue(Double.valueOf(valueS)); setValue(Double.valueOf(valueS));
} }
/**
* @param id
* @param name
* @param value
*/
public FloatParameter(String id, String name, Double value) {
setId(id);
setName(name);
setValue(value);
}
@Override @Override
public String getValueAsString() { public String getValueAsString() {
return Double.toString(this.value); return Double.toString(this.value);

View File

@ -40,14 +40,27 @@ public class IntegerParameter extends AbstractParameter<Integer> {
private Integer value = Integer.MAX_VALUE; private Integer value = Integer.MAX_VALUE;
/** /**
* Default constructor * Empty constructor
*
*/ */
public IntegerParameter() { public IntegerParameter() {
// //
} }
/** /**
* Default constructor
*
* @param id
* @param name
* @param value
*/
public IntegerParameter(String id, String name, Integer value) {
super(id, name);
setValue(value);
}
/**
* DOM Constructor
*
* @param element * @param element
*/ */
public IntegerParameter(Element element) { public IntegerParameter(Element element) {
@ -61,17 +74,6 @@ public class IntegerParameter extends AbstractParameter<Integer> {
setValue(Integer.valueOf(valueS)); setValue(Integer.valueOf(valueS));
} }
/**
* @param id
* @param name
* @param value
*/
public IntegerParameter(String id, String name, Integer value) {
setId(id);
setName(name);
setValue(value);
}
@Override @Override
public String getType() { public String getType() {
return IntegerParameter.TYPE; return IntegerParameter.TYPE;

View File

@ -37,7 +37,7 @@ public interface ListParameter<E> extends Parameter<List<E>> {
* @param value * @param value
* the value to add * the value to add
*/ */
public abstract void addValue(E value); public void addValue(E value);
/** /**
* Removes a single value from the {@link List} of values * Removes a single value from the {@link List} of values
@ -47,5 +47,5 @@ public interface ListParameter<E> extends Parameter<List<E>> {
* *
* @return true if the value was removed, false if it did not exist * @return true if the value was removed, false if it did not exist
*/ */
public abstract boolean removeValue(E value); public boolean removeValue(E value);
} }

View File

@ -40,13 +40,27 @@ public class LongParameter extends AbstractParameter<Long> {
protected Long value; protected Long value;
/** /**
* Default constructor * Empty constructor
*/ */
public LongParameter() { public LongParameter() {
// //
} }
/** /**
* Default constructor
*
* @param id
* @param name
* @param value
*/
public LongParameter(String id, String name, Long value) {
super(id, name);
setValue(Long.valueOf(value));
}
/**
* DOM Constructor
*
* @param element * @param element
*/ */
public LongParameter(Element element) { public LongParameter(Element element) {
@ -60,17 +74,6 @@ public class LongParameter extends AbstractParameter<Long> {
setValue(Long.valueOf(valueS)); setValue(Long.valueOf(valueS));
} }
/**
* @param id
* @param name
* @param value
*/
public LongParameter(String id, String name, Long value) {
setId(id);
setName(name);
setValue(Long.valueOf(value));
}
@Override @Override
public String getValueAsString() { public String getValueAsString() {
return this.value.toString(); return this.value.toString();

View File

@ -22,11 +22,18 @@
package li.strolch.model.parameter; package li.strolch.model.parameter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import li.strolch.exception.StrolchException;
import li.strolch.model.StrolchElement; import li.strolch.model.StrolchElement;
import org.dom4j.Element;
import ch.eitchnet.utils.helper.StringHelper;
/** /**
* @author Robert von Burg <eitch@eitchnet.ch> * @author Robert von Burg <eitch@eitchnet.ch>
*/ */
@ -37,6 +44,50 @@ public class StringListParameter extends AbstractParameter<List<String>> impleme
protected List<String> value; protected List<String> value;
/**
* Empty constructor
*/
public StringListParameter() {
//
}
/**
* Default constructor
*
* @param id
* @param name
* @param value
*/
public StringListParameter(String id, String name, List<String> value) {
super(id, name);
setValue(value);
}
/**
* DOM Constructor
*
* @param element
*/
public StringListParameter(Element element) {
super.fromDom(element);
String valueS = element.attributeValue("Value");
if (StringHelper.isEmpty(valueS)) {
throw new StrolchException("No value defined for " + this.id);
}
setValue(parse(valueS));
}
private List<String> parse(String value) {
if (value.isEmpty())
return Collections.emptyList();
String[] valueArr = value.split(";");
return Arrays.asList(valueArr);
}
@Override @Override
public String getValueAsString() { public String getValueAsString() {
if (this.value.isEmpty()) if (this.value.isEmpty())

View File

@ -48,6 +48,20 @@ public class StringParameter extends AbstractParameter<String> {
} }
/** /**
* Default constructor
*
* @param id
* @param name
* @param value
*/
public StringParameter(String id, String name, String value) {
super(id, name);
setValue(value);
}
/**
* DOM Constructor
*
* @param element * @param element
*/ */
public StringParameter(Element element) { public StringParameter(Element element) {
@ -61,17 +75,6 @@ public class StringParameter extends AbstractParameter<String> {
setValue(valueS); setValue(valueS);
} }
/**
* @param id
* @param name
* @param value
*/
public StringParameter(String id, String name, String value) {
setId(id);
setName(name);
setValue(value);
}
@Override @Override
public String getType() { public String getType() {
return StringParameter.TYPE; return StringParameter.TYPE;