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.function.BaseCommonFunctionCompatibilityTag;
016: import org.jfolder.common.function.WebPageTagInstanceViewContext;
017: import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
018: import org.jfolder.common.tagging.AppraiseConceptTagContext;
019: import org.jfolder.common.tagging.ConceptTagCharacteristic;
020: import org.jfolder.common.tagging.ConceptTagConstraint;
021: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
022: import org.jfolder.common.tagging.ConceptTagFlagsHelper;
023: import org.jfolder.common.tagging.DetermineClassConceptTagContext;
024: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
025: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagException;
026: import org.jfolder.common.tagging.InitializeConceptTagContext;
027: import org.jfolder.common.tagging.SelectionCriteriaForReturnableConceptTag;
028: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
029: import org.jfolder.common.tagging.StudioConceptTagCreParInfoContext;
030: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
031: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
032: import org.jfolder.common.tagging.ValueAndClassForConceptTag;
033: import org.jfolder.common.utils.misc.MiscHelper;
034:
035: //other classes
036:
037: public class CommonFunctionLiteralStringTag extends
038: BaseCommonFunctionCompatibilityTag implements
039: SelfArgumentlessConstructor {
040:
041: //
042: private ConceptTagCharacteristic valueCtchar = null;
043:
044: //value details
045: private final static String VALUE_CTCON = "value";
046: private final static String VALUE_TITLE = "Value";
047: private final static String VALUE_SHORT_DESCRIPTION = "Value of this string";
048:
049: public void initialize(InitializeConceptTagContext inIctc) {
050:
051: //
052: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
053: .newInstance(inIctc);
054: //
055: //rootCtconh.getAttributes().setStudioVisibleOnlyOnError(true);
056: //rootCtconh.getStyles().setStudioVisibleOnlyOnError(true);
057:
058: //constrain "value"
059: ConceptTagConstraint valueCtcon = ConceptTagConstraint
060: .newInstance(VALUE_CTCON, rootCtconh);
061: valueCtcon.setTitle(VALUE_TITLE);
062: valueCtcon.setShortDescription(VALUE_SHORT_DESCRIPTION);
063: //
064: StaticConceptTagConstraintContext valueSctcc = StaticConceptTagConstraintContext
065: .newInstance(valueCtcon);
066: //
067: valueSctcc.addDefaultValue("StringValue");
068:
069: //constrain undefined
070: ConceptTagConstraint unconstrainedCtcon = rootCtconh
071: .getUndefinedConstraint();
072: //unconstrainedCtcon.setStudioVisibleOnlyOnError(true);
073:
074: //
075: ConceptTagFlagsHelper
076: .pushNonIterativeCommonFunctionDepth(inIctc);
077: inIctc.initialize();
078: ConceptTagFlagsHelper
079: .popNonIterativeCommonFunctionDepth(inIctc);
080:
081: //
082: this .valueCtchar = valueCtcon.getCharacteristic();
083: }
084:
085: public void appraise(AppraiseConceptTagContext inActc) {
086:
087: if (inActc instanceof StudioConceptTagInstanceInfoContext) {
088:
089: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inActc;
090:
091: String displayValue = "(Unknown)";
092: if (this .valueCtchar.getValueLength() >= 1
093: && this .valueCtchar.isStatic(0, inActc)) {
094: displayValue = this .valueCtchar.getValueAsString(0,
095: inActc);
096: }
097: sctiic.setInstanceTitle(MiscHelper.shortenString(
098: displayValue, 15));
099: sctiic.setInstanceDescription(MiscHelper.shortenString(
100: displayValue, 200));
101: } else if (inActc instanceof StudioConceptTagTypeInfoContext) {
102:
103: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inActc;
104:
105: scttic.setTypeTitle("Literal String");
106: scttic.setTypeDescription("String with fixed value");
107: } else if (inActc instanceof WebPageTagInstanceViewContext) {
108:
109: WebPageTagInstanceViewContext wptivc = (WebPageTagInstanceViewContext) inActc;
110:
111: WebPageTagInstanceViewContextInfo info = wptivc
112: .getInfoAsNonHtml();
113:
114: info.setNonHtmlContent("String(", ")");
115: WebPageTagInstanceViewContext.displayView(this .valueCtchar,
116: info, wptivc, "???");
117: //
118: //info.setEndContent(")");
119: //if (this.valueCtchar.getValueLength() >= 1) {
120: // info.setStartContent("String(");
121: // WebPageTagInstanceViewContext.displayView(
122: // this.valueCtchar, info, wptivc);
123: // info.setEndContent(")");
124: //}
125: //else {
126: // info.setStartContent("String(???Unknown???)");
127: //}
128:
129: } else if (inActc instanceof SelectionCriteriaForReturnableConceptTag) {
130:
131: SelectionCriteriaForReturnableConceptTag scfrct = (SelectionCriteriaForReturnableConceptTag) inActc;
132:
133: scfrct.canReturnString();
134: scfrct.declareFormatAsPlain();
135: } else if (inActc instanceof StudioConceptTagCreParInfoContext) {
136:
137: StudioConceptTagCreParInfoContext scpc = (StudioConceptTagCreParInfoContext) inActc;
138: }
139: }
140:
141: public void determineValueAndClass(
142: DetermineValueAndClassConceptTagContext inDvacctc) {
143:
144: ValueAndClassForConceptTag vacfct = null;
145:
146: vacfct = ValueAndClassForConceptTag.newString(this .valueCtchar
147: .getValueAsString(0, inDvacctc));
148:
149: inDvacctc.setDetermineValueAndClass(vacfct);
150: }
151:
152: public void determineClass(DetermineClassConceptTagContext inDcctc) {
153:
154: inDcctc.setDetermineClass(StandardDataTypes.getStringClass());
155: }
156:
157: public Object createUninitializedSelf() {
158: return new CommonFunctionLiteralStringTag();
159: }
160: }
|