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.ConceptTagCharacteristic;
021: import org.jfolder.common.tagging.ConceptTagConstraint;
022: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
023: import org.jfolder.common.tagging.ConceptTagFlagsHelper;
024: import org.jfolder.common.tagging.ConceptTagHelper;
025: import org.jfolder.common.tagging.DetermineClassConceptTagContext;
026: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
027: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagException;
028: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
029: import org.jfolder.common.tagging.InitializeConceptTagContext;
030: import org.jfolder.common.tagging.ReturnableConceptTag;
031: import org.jfolder.common.tagging.SelectionCriteriaForReturnableConceptTag;
032: import org.jfolder.common.tagging.StudioConceptTagCreParInfoContext;
033: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
034: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
035: import org.jfolder.common.tagging.ValueAndClassForConceptTag;
036:
037: //other classes
038:
039: public class CommonFunctionLogCompNotTag extends
040: BaseCommonFunctionCompatibilityTag implements
041: SelfArgumentlessConstructor {
042:
043: //characteristics
044: private ConceptTagCharacteristic operandCtchar = null;
045:
046: //caller details
047: private final static String OPERAND_CTCON = "operand";
048: private final static String OPERAND_TITLE = "Operand";
049: private final static String OPERAND_SHORT_DESCRIPTION = "Value to be inverted (true to false, or false to true)";
050:
051: public void initialize(InitializeConceptTagContext inIctc) {
052:
053: //
054: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
055: .newInstance(inIctc);
056:
057: //constrain "operand"
058: ConceptTagConstraint operandCtcon = ConceptTagConstraint
059: .newInstance(OPERAND_CTCON, rootCtconh);
060: operandCtcon.setTitle(OPERAND_TITLE);
061: operandCtcon.setShortDescription(OPERAND_SHORT_DESCRIPTION);
062: operandCtcon.setMinimumLength(1);
063: operandCtcon.setMaximumLength(1);
064: //
065: DynamicConceptTagConstraintContext operandDctcc = DynamicConceptTagConstraintContext
066: .newInstance(operandCtcon);
067: operandDctcc.getValidator().allowReturnOfOnlyBoolean();
068: operandDctcc.getValidator().filterDirectChildOfRootAndHtml();
069: //
070: //operandDctcc.addDefaultValue(
071: // GetApplicationAttributeWorkflowTemplateTag.class);
072:
073: //
074: ConceptTagFlagsHelper
075: .pushNonIterativeCommonFunctionDepth(inIctc);
076: inIctc.initialize();
077: ConceptTagFlagsHelper
078: .popNonIterativeCommonFunctionDepth(inIctc);
079:
080: //initialize characteristics
081: this .operandCtchar = operandCtcon.getCharacteristic();
082:
083: }
084:
085: public void appraise(AppraiseConceptTagContext inActc) {
086:
087: if (inActc instanceof StudioConceptTagInstanceInfoContext) {
088:
089: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inActc;
090:
091: sctiic.setInstanceTitle("Not");
092: sctiic.setInstanceDescription("Reverses a logical result");
093: } else if (inActc instanceof StudioConceptTagTypeInfoContext) {
094:
095: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inActc;
096:
097: scttic.setTypeTitle("Not");
098: scttic.setTypeDescription("Reverses a logical result");
099: } else if (inActc instanceof WebPageTagInstanceViewContext) {
100:
101: WebPageTagInstanceViewContext wptivc = (WebPageTagInstanceViewContext) inActc;
102:
103: WebPageTagInstanceViewContextInfo info = wptivc
104: .getInfoAsNonHtml();
105:
106: info.setNonHtmlContent("NOT(", ")");
107: WebPageTagInstanceViewContext.displayView(
108: this .operandCtchar, info, wptivc, "???");
109: //info.setEndContent(")");
110: //wptivc.getInfo().setStartContent("");
111: //wptivc.getInfo().setMiddleContent("");
112: //wptivc.getInfo().setEndContent("");
113: } else if (inActc instanceof SelectionCriteriaForReturnableConceptTag) {
114:
115: SelectionCriteriaForReturnableConceptTag scfrct = (SelectionCriteriaForReturnableConceptTag) inActc;
116:
117: scfrct.canReturnBoolean();
118: scfrct.declareFormatAsPlain();
119: } else if (inActc instanceof StudioConceptTagCreParInfoContext) {
120:
121: StudioConceptTagCreParInfoContext scpc = (StudioConceptTagCreParInfoContext) inActc;
122: }
123: }
124:
125: public void determineValueAndClass(
126: DetermineValueAndClassConceptTagContext inDvacctc) {
127:
128: try {
129: ValueAndClassForConceptTag vacfct = null;
130:
131: ValueAndClassForConceptTag operandVac = this .operandCtchar
132: .getDetermineValueAndClass(0, inDvacctc);
133: boolean result = ((Boolean) operandVac.getValue())
134: .booleanValue();
135: vacfct = ValueAndClassForConceptTag.newBoolean(new Boolean(
136: !result));
137:
138: inDvacctc.setDetermineValueAndClass(vacfct);
139: } catch (DetermineValueAndClassConceptTagException dvaccte) {
140: inDvacctc.setDetermineException(dvaccte);
141: }
142: }
143:
144: public void determineClass(DetermineClassConceptTagContext inDcctc) {
145: inDcctc.setDetermineClass(StandardDataTypes.getBooleanClass());
146: }
147:
148: public Object createUninitializedSelf() {
149: return new CommonFunctionLogCompNotTag();
150: }
151: }
|