01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/publishing/markups/TKDefinedMarkupParam.java,v 1.6 2000/06/01 15:02:56 alex Exp $
03: *
04: */
05: package com.teamkonzept.publishing.markups;
06:
07: import com.teamkonzept.lib.*;
08:
09: public class TKDefinedMarkupParam extends TKMarkupParam {
10:
11: public boolean defaulted;
12: public TKMarkupParamClass typeClass;
13: public TKVector optionList;
14:
15: public TKMarkupParamCall definition;
16:
17: public TKDefinedMarkupParam(String name, String value,
18: TKMarkupParamCall definition) {
19:
20: super (name, value);
21:
22: this .definition = definition;
23: this .defaulted = false;
24: this .typeClass = definition.param.typeClass;
25: this .optionList = null;
26: }
27:
28: public TKDefinedMarkupParam(TKMarkupParamCall definition) {
29:
30: super (definition.name, null);
31:
32: this .definition = definition;
33: this .defaulted = false;
34: this .typeClass = definition.param.typeClass;
35: this .optionList = null;
36: }
37:
38: public TKDefinedMarkupParam(TKMarkupParam param,
39: TKMarkupParamCall definition) {
40:
41: super (param);
42:
43: this .definition = definition;
44: this .defaulted = false;
45: this .typeClass = definition.param.typeClass;
46: this .optionList = null;
47: }
48:
49: public void complete() throws Exception {
50:
51: if (!definition.useDefault || (value() != null))
52: ;
53: else if (definition.defaultValue() != null)
54: setValue(definition.defaultValue());
55: else if (definition.param.defaultValue() != null)
56: setValue(definition.param.defaultValue());
57:
58: if (!definition.param.isCaseSensitive && (value() != null))
59: setValue(value().toUpperCase());
60:
61: if (!definition.useDefault || (value() == null))
62: defaulted = false;
63: else if (definition.defaultValue() != null)
64: defaulted = value().equals(definition.defaultValue());
65: else if (definition.param.defaultValue() != null)
66: defaulted = value().equals(definition.param.defaultValue());
67: else
68: defaulted = false;
69:
70: typeClass = definition.param.typeClass;
71: optionList = definition.param.optionList;
72:
73: setValue(definition.param.checkValue(value(),
74: definition.editable));
75:
76: if ((value() == null) && !definition.isOptional)
77: throw new Exception("Parameter " + name + ": Wert ("
78: + typeClass.name + ") fehlt");
79: }
80:
81: public String wrapValue() {
82:
83: if (value() == null)
84: return null;
85: else if (definition != null)
86: return definition.param.typeClass.wrapValue(value());
87: else
88: return super .wrapValue();
89: }
90: //{{DECLARE_CONTROLS
91: //}}
92: }
|