001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.common.function.v1;
009:
010: //base classes
011:
012: //project specific classes
013: import org.jfolder.common.SelfArgumentlessConstructor;
014: import org.jfolder.common.StandardDataTypes;
015: import org.jfolder.common.UnexpectedSystemException;
016: import org.jfolder.common.function.BaseCommonFunctionCompatibilityTag;
017: import org.jfolder.common.function.WebPageTagInstanceViewContext;
018: import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
019: import org.jfolder.common.tagging.AppraiseConceptTagContext;
020: import org.jfolder.common.tagging.ConceptTag;
021: import org.jfolder.common.tagging.ConceptTagCharacteristic;
022: import org.jfolder.common.tagging.ConceptTagConstraint;
023: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
024: import org.jfolder.common.tagging.ConceptTagFlagsHelper;
025: import org.jfolder.common.tagging.ConceptTagHelper;
026: import org.jfolder.common.tagging.DetermineClassConceptTagContext;
027: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
028: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagException;
029: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
030: import org.jfolder.common.tagging.InitializeConceptTagContext;
031: import org.jfolder.common.tagging.ReturnableConceptTag;
032: import org.jfolder.common.tagging.SelectionCriteriaForReturnableConceptTag;
033: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
034: import org.jfolder.common.tagging.StudioConceptTagCreParInfoContext;
035: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
036: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
037: import org.jfolder.common.tagging.ValueAndClassForConceptTag;
038: import org.jfolder.common.utils.misc.CommonExpressions;
039: import org.jfolder.common.utils.misc.MiscHelper;
040:
041: //other classes
042:
043: public class CommonFunctionMapPlaceValueTag extends
044: BaseCommonFunctionCompatibilityTag implements
045: SelfArgumentlessConstructor {
046:
047: //characteristics
048: private ConceptTagCharacteristic mapCtchar = null;
049: private ConceptTagCharacteristic keyCtchar = null;
050: private ConceptTagCharacteristic valueCtchar = null;
051:
052: //map details
053: private final static String MAP_CTCON = "map";
054: private final static String MAP_TITLE = "Map";
055: private final static String MAP_SHORT_DESCRIPTION = "Map";
056:
057: //key details
058: private final static String KEY_CTCON = "key";
059: private final static String KEY_TITLE = "Key";
060: private final static String KEY_SHORT_DESCRIPTION = "Key";
061: //
062: private final static String VALUE_CTCON = "value";
063: private final static String VALUE_TITLE = "Value";
064: private final static String VALUE_SHORT_DESCRIPTION = "Value";
065:
066: public void initialize(InitializeConceptTagContext inIctc) {
067:
068: //
069: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
070: .newInstance(inIctc);
071:
072: //constrain "map"
073: ConceptTagConstraint mapCtcon = ConceptTagConstraint
074: .newInstance(MAP_CTCON, rootCtconh);
075: //
076: mapCtcon.setTitle(MAP_TITLE);
077: mapCtcon.setShortDescription(MAP_SHORT_DESCRIPTION);
078: //
079: //
080: mapCtcon.setMinimumLength(1);
081: mapCtcon.setMaximumLength(1);
082: //
083: DynamicConceptTagConstraintContext mapDctcc = DynamicConceptTagConstraintContext
084: .newInstance(mapCtcon);
085: mapDctcc.getValidator().allowReturnOfOnlyMap();
086: mapDctcc.getValidator().filterDirectChildOfRootAndHtml();
087: //
088:
089: //constrain "key"
090: ConceptTagConstraint keyCtcon = ConceptTagConstraint
091: .newInstance(KEY_CTCON, rootCtconh);
092: //
093: keyCtcon.setTitle(KEY_TITLE);
094: keyCtcon.setShortDescription(KEY_SHORT_DESCRIPTION);
095: //
096: //
097: keyCtcon.setMinimumLength(1);
098: keyCtcon.setMaximumLength(1);
099: //
100: DynamicConceptTagConstraintContext keyDctcc = DynamicConceptTagConstraintContext
101: .newInstance(keyCtcon);
102: keyDctcc.getValidator().allowReturnOfAnythingExceptNothing();
103: keyDctcc.getValidator().filterDirectChildOfRootAndHtml();
104: //
105: //StaticConceptTagConstraintContext keySctcc =
106: // StaticConceptTagConstraintContext.newInstance(keyCtcon);
107:
108: //constrain "value"
109: ConceptTagConstraint valueCtcon = ConceptTagConstraint
110: .newInstance(VALUE_CTCON, rootCtconh);
111: //
112: valueCtcon.setTitle(VALUE_TITLE);
113: valueCtcon.setShortDescription(VALUE_SHORT_DESCRIPTION);
114: //
115: //
116: valueCtcon.setMinimumLength(1);
117: valueCtcon.setMaximumLength(1);
118: //
119: DynamicConceptTagConstraintContext valueDctcc = DynamicConceptTagConstraintContext
120: .newInstance(valueCtcon);
121: valueDctcc.getValidator().allowReturnOfAnythingExceptNothing();
122: valueDctcc.getValidator().filterDirectChildOfRootAndHtml();
123: //
124:
125: //
126: ConceptTagFlagsHelper
127: .pushNonIterativeCommonFunctionDepth(inIctc);
128: inIctc.initialize();
129: ConceptTagFlagsHelper
130: .popNonIterativeCommonFunctionDepth(inIctc);
131:
132: //initialize characteristics
133: this .mapCtchar = mapCtcon.getCharacteristic();
134: this .keyCtchar = keyCtcon.getCharacteristic();
135: this .valueCtchar = valueCtcon.getCharacteristic();
136: }
137:
138: public void appraise(AppraiseConceptTagContext inActc) {
139:
140: if (inActc instanceof StudioConceptTagInstanceInfoContext) {
141:
142: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inActc;
143:
144: //
145: sctiic.setInstanceTitle("Place Value In Map");
146: sctiic.setInstanceDescription("Place Value In Map");
147: } else if (inActc instanceof StudioConceptTagTypeInfoContext) {
148:
149: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inActc;
150:
151: scttic.setTypeTitle("Place Value In Map");
152: scttic.setTypeDescription("Place Value In Map");
153: } else if (inActc instanceof WebPageTagInstanceViewContext) {
154:
155: WebPageTagInstanceViewContext wptivc = (WebPageTagInstanceViewContext) inActc;
156:
157: WebPageTagInstanceViewContextInfo info = wptivc
158: .getInfoAsNonHtml();
159:
160: //
161: WebPageTagInstanceViewContextInfo placeInfo = info
162: .createNonHtmlInfo();
163: placeInfo.setNonHtmlContent("Place Key (");
164: WebPageTagInstanceViewContext.displayView(this .keyCtchar,
165: placeInfo, wptivc, "???");
166: //
167: //
168: WebPageTagInstanceViewContextInfo valueInfo = info
169: .createNonHtmlInfo();
170: valueInfo.setNonHtmlContent(") With Value (");
171: WebPageTagInstanceViewContext.displayView(this .valueCtchar,
172: valueInfo, wptivc, "???");
173: //
174: //
175: WebPageTagInstanceViewContextInfo mapInfo = info
176: .createNonHtmlInfo();
177: mapInfo.setNonHtmlContent(") To Map (", ")");
178: WebPageTagInstanceViewContext.displayView(this .mapCtchar,
179: mapInfo, wptivc, "???");
180: //mapInfo.setEndContent(")");
181: } else if (inActc instanceof SelectionCriteriaForReturnableConceptTag) {
182:
183: SelectionCriteriaForReturnableConceptTag scfrct = (SelectionCriteriaForReturnableConceptTag) inActc;
184:
185: scfrct.canReturnNothing();
186: scfrct.declareFormatAsPlain();
187: } else if (inActc instanceof StudioConceptTagCreParInfoContext) {
188:
189: StudioConceptTagCreParInfoContext scpc = (StudioConceptTagCreParInfoContext) inActc;
190: }
191: }
192:
193: public void determineValueAndClass(
194: DetermineValueAndClassConceptTagContext inDvacctc) {
195:
196: try {
197: //
198: ValueAndClassForConceptTag mapVacfct = this .mapCtchar
199: .getDetermineValueAndClass(0, inDvacctc);
200: //
201: ValueAndClassForConceptTag keyVacfct = this .keyCtchar
202: .getDetermineValueAndClass(0, inDvacctc);
203: //
204: ValueAndClassForConceptTag valueVacfct = this .valueCtchar
205: .getDetermineValueAndClass(0, inDvacctc);
206:
207: StandardDataTypes.placeValueInMap(mapVacfct.getValue(),
208: keyVacfct, valueVacfct);
209: //StandardDataTypes.placeValueInMap(
210: // mapVacfct.getValue(), keyVacfct.getValue(), valueVacfct);
211:
212: inDvacctc
213: .setDetermineValueAndClass(ValueAndClassForConceptTag
214: .newNothing());
215: } catch (DetermineValueAndClassConceptTagException dvaccte) {
216: inDvacctc.setDetermineException(dvaccte);
217: }
218: }
219:
220: public void determineClass(DetermineClassConceptTagContext inDcctc) {
221: inDcctc.setDetermineClass(StandardDataTypes.getNothingClass());
222: }
223:
224: public Object createUninitializedSelf() {
225: return new CommonFunctionMapPlaceValueTag();
226: }
227:
228: }
|