1 package net.sf.msplice.model;
2
3 import net.sf.msplice.SpliceException;
4 import net.sf.msplice.model.value.AbstractValue;
5 import net.sf.msplice.model.value.NoValue;
6 import net.sf.msplice.visitor.IVisitor;
7
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10
11 public class DefaultValueHolder implements ISpliceElement {
12
13 private final static Log LOG = LogFactory.getLog(DefaultValueHolder.class);
14
15 public static final AbstractValue FALLBACK_VALUE = new NoValue();
16
17 private AbstractValue defaultValue = FALLBACK_VALUE;
18
19
20
21
22
23 public Object accept(IVisitor visitor) throws SpliceException {
24 return visitor.visit(this);
25 }
26
27
28
29
30
31 public AbstractValue getDefaultValue() {
32 return defaultValue;
33 }
34
35 public void setDefaultValue(AbstractValue defaultValue) {
36 if (defaultValue == null) {
37 LOG.warn("Impossible to set a \"null\" defaultValue");
38 this.defaultValue = FALLBACK_VALUE;
39 } else {
40 this.defaultValue = defaultValue;
41 }
42 }
43
44 }