[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
public long getDbid() {
return this.dbid;

View File

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

View File

@ -55,6 +55,9 @@ public class Locator {
*/
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;
/**

View File

@ -54,7 +54,7 @@ public class Order extends GroupedParameterizedElement {
}
/**
* Default constructor for an {@link Order}
* Default Constructor
*
* @param id
* @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 name
@ -84,7 +84,7 @@ public class Order extends GroupedParameterizedElement {
}
/**
* From DOM Constructor
* DOM Constructor
*
* @param element
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,18 +35,31 @@ public class BooleanParameter extends AbstractParameter<Boolean> {
public static final String TYPE = "Boolean";
private static final long serialVersionUID = 0L;
private Boolean value = Boolean.FALSE;
/**
* Empty constructor
*
*/
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
*/
public BooleanParameter(Element element) {
@ -60,17 +73,6 @@ public class BooleanParameter extends AbstractParameter<Boolean> {
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
public String getValueAsString() {
return this.value.toString();

View File

@ -42,13 +42,27 @@ public class DateParameter extends AbstractParameter<Long> {
private Long value;
/**
* Default constructor
* Empty constructor
*/
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
*/
public DateParameter(Element element) {
@ -62,17 +76,6 @@ public class DateParameter extends AbstractParameter<Long> {
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
public String getValueAsString() {
// TODO the format should be globally configured

View File

@ -41,13 +41,27 @@ public class FloatParameter extends AbstractParameter<Double> {
/**
* Empty constructor
*
*/
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
*/
public FloatParameter(Element element) {
@ -61,17 +75,6 @@ public class FloatParameter extends AbstractParameter<Double> {
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
public String getValueAsString() {
return Double.toString(this.value);

View File

@ -40,14 +40,27 @@ public class IntegerParameter extends AbstractParameter<Integer> {
private Integer value = Integer.MAX_VALUE;
/**
* Default constructor
*
* Empty constructor
*/
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
*/
public IntegerParameter(Element element) {
@ -61,17 +74,6 @@ public class IntegerParameter extends AbstractParameter<Integer> {
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
public String getType() {
return IntegerParameter.TYPE;

View File

@ -37,7 +37,7 @@ public interface ListParameter<E> extends Parameter<List<E>> {
* @param value
* 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
@ -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
*/
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;
/**
* Default constructor
* Empty constructor
*/
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
*/
public LongParameter(Element element) {
@ -60,17 +74,6 @@ public class LongParameter extends AbstractParameter<Long> {
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
public String getValueAsString() {
return this.value.toString();

View File

@ -22,11 +22,18 @@
package li.strolch.model.parameter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import li.strolch.exception.StrolchException;
import li.strolch.model.StrolchElement;
import org.dom4j.Element;
import ch.eitchnet.utils.helper.StringHelper;
/**
* @author Robert von Burg <eitch@eitchnet.ch>
*/
@ -37,6 +44,50 @@ public class StringListParameter extends AbstractParameter<List<String>> impleme
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
public String getValueAsString() {
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
*/
public StringParameter(Element element) {
@ -61,17 +75,6 @@ public class StringParameter extends AbstractParameter<String> {
setValue(valueS);
}
/**
* @param id
* @param name
* @param value
*/
public StringParameter(String id, String name, String value) {
setId(id);
setName(name);
setValue(value);
}
@Override
public String getType() {
return StringParameter.TYPE;