01: /*
02: * JFolder, Copyright 2001-2006 Gary Steinmetz
03: *
04: * Distributable under LGPL license.
05: * See terms of license at gnu.org.
06: */
07:
08: package org.jfolder.web.page.v1;
09:
10: //base classes
11:
12: //project specific classes
13: import org.jfolder.common.UnexpectedSystemException;
14: import org.jfolder.common.files.WebPageTagMacro;
15: import org.jfolder.common.files.WebPageTagMacroHelper;
16: import org.jfolder.common.function.BaseWebPageTag;
17: import org.jfolder.common.function.WebPageTagInstanceViewContext;
18: import org.jfolder.common.tagging.AppraiseConceptTagContext;
19: import org.jfolder.common.tagging.ConceptTagCharacteristic;
20: import org.jfolder.common.tagging.ConceptTagConstraint;
21: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
22: import org.jfolder.common.tagging.ConceptTagPreferences;
23: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
24: import org.jfolder.common.tagging.DynamicConceptTagValidator;
25: import org.jfolder.common.tagging.InitializeConceptTagContext;
26: import org.jfolder.common.tagging.PreValidatorForConceptTagConstraint;
27: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
28: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
29: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
30:
31: //other classes
32:
33: public class PreConstraintValidatorForMacroParams implements
34: PreValidatorForConceptTagConstraint {
35:
36: //
37: private ConceptTagConstraint nameCtcon = null;
38:
39: //
40: private PreConstraintValidatorForMacroParams(
41: ConceptTagConstraint inNameCtcon) {
42: //
43: this .nameCtcon = inNameCtcon;
44: }
45:
46: //
47: protected final static PreConstraintValidatorForMacroParams newInstance(
48: ConceptTagConstraint inNameCtcon) {
49: //
50: PreConstraintValidatorForMacroParams outValue = null;
51:
52: outValue = new PreConstraintValidatorForMacroParams(inNameCtcon);
53:
54: return outValue;
55: }
56:
57: //
58: public void preValidate(InitializeConceptTagContext inIctc,
59: ConceptTagConstraint inCtcon) {
60: //
61: ConceptTagCharacteristic nameCtchar = this .nameCtcon
62: .getCharacteristic();
63: if (nameCtchar.getValueLength() > 0
64: && nameCtchar.isStatic(0, inIctc)
65: && !inCtcon.isParentErrorPresent()) {
66: preValidateWithValidData(inIctc, inCtcon);
67: }
68: }
69:
70: //
71: public void preValidateWithValidData(
72: InitializeConceptTagContext inIctc,
73: ConceptTagConstraint inCtcon) {
74: //
75: //
76: ConceptTagCharacteristic nameCtchar = this .nameCtcon
77: .getCharacteristic();
78: String macroHandle = nameCtchar.getValueAsString(0, inIctc);
79: WebPageTagMacro macro = WebPageTagMacroHelper
80: .getMacroFromMacroHandle(macroHandle);
81: inCtcon.setMinimumLength(macro.getParameterCount());
82: inCtcon.setMaximumLength(macro.getParameterCount());
83: }
84: }
|