CommonFunctionCompIsNotNullTag.java :  » Workflow-Engines » JFolder » org » jfolder » common » function » v1 » Java Open Source

Java Open Source » Workflow Engines » JFolder 
JFolder » org » jfolder » common » function » v1 » CommonFunctionCompIsNotNullTag.java
/*
 * JFolder, Copyright 2001-2006 Gary Steinmetz
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package org.jfolder.common.function.v1;

//base classes
import javax.servlet.jsp.PageContext;

//project specific classes
import org.jfolder.common.SelfArgumentlessConstructor;
import org.jfolder.common.StandardDataTypes;
import org.jfolder.common.UnexpectedSystemException;
import org.jfolder.common.function.BaseCommonFunctionCompatibilityTag;
import org.jfolder.common.function.ComponentsForReturnableWebPageTag;
import org.jfolder.common.function.WebPageTagHelper;
import org.jfolder.common.function.WebPageTagInstanceViewContext;
import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
import org.jfolder.common.tagging.AppraiseConceptTagContext;
import org.jfolder.common.tagging.ConceptTagCharacteristic;
import org.jfolder.common.tagging.ConceptTagConstraint;
import org.jfolder.common.tagging.ConceptTagConstraintHolder;
import org.jfolder.common.tagging.ConceptTagFlagsHelper;
import org.jfolder.common.tagging.DetermineClassConceptTagContext;
import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
import org.jfolder.common.tagging.DetermineValueAndClassConceptTagException;
import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
import org.jfolder.common.tagging.InitializeConceptTagContext;
import org.jfolder.common.tagging.SelectionCriteriaForReturnableConceptTag;
import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
import org.jfolder.common.tagging.StudioConceptTagCreParInfoContext;
import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
import org.jfolder.common.tagging.ValueAndClassForConceptTag;
import org.jfolder.common.utils.misc.MiscHelper;
//import org.jfolder.workflow.model.attributes.AttributeSet;
//import org.jfolder.workflow.model.instance.WorkflowInstance;

//other classes

public class CommonFunctionCompIsNotNullTag
    extends BaseCommonFunctionCompatibilityTag
    implements SelfArgumentlessConstructor {
    
    //
    private ConceptTagCharacteristic valueCtchar = null;
    
    //value details
    private final static String VALUE_CTCON = "value";
    private final static String VALUE_TITLE = "Value";
    private final static String VALUE_SHORT_DESCRIPTION =
        "Value of this string";
    //
    
    public void initialize(InitializeConceptTagContext inIctc) {
        
        //
        ConceptTagConstraintHolder rootCtconh =
            ConceptTagConstraintHolder.newInstance(inIctc);
        //
        //rootCtconh.getAttributes().setStudioVisibleOnlyOnError(true);
        //rootCtconh.getStyles().setStudioVisibleOnlyOnError(true);
        
        //constrain "value"
        ConceptTagConstraint valueCtcon =
            ConceptTagConstraint.newInstance(VALUE_CTCON, rootCtconh);
        valueCtcon.setTitle(VALUE_TITLE);
        valueCtcon.setShortDescription(VALUE_SHORT_DESCRIPTION);
        valueCtcon.setMinimumLength(1);
        valueCtcon.setMaximumLength(1);
        //
        DynamicConceptTagConstraintContext valueDctcc =
            DynamicConceptTagConstraintContext.newInstance(valueCtcon);
        valueDctcc.getValidator().filterDirectChildOfRootAndHtml();
        //
        //valueDctcc.addDefaultValue(
        //    TaglibLiteralBooleanWebPageTag.class);
        
        //
        ConceptTagConstraint unconstrainedCtcon =
            rootCtconh.getUndefinedConstraint();
        //unconstrainedCtcon.setStudioVisibleOnlyOnError(true);
        
        //
        ConceptTagFlagsHelper.pushNonIterativeCommonFunctionDepth(inIctc);
        inIctc.initialize();
        ConceptTagFlagsHelper.popNonIterativeCommonFunctionDepth(inIctc);
        
        //
        //post initialization validation
        //TO DO: compare class against value
        
        //
        this.valueCtchar = valueCtcon.getCharacteristic();
    }
    
    public void appraise(AppraiseConceptTagContext inActc) {
        
        if (inActc instanceof StudioConceptTagInstanceInfoContext) {
            
            StudioConceptTagInstanceInfoContext sctiic =
                (StudioConceptTagInstanceInfoContext)inActc;
            
            sctiic.setInstanceTitle("Is Not Null");
            sctiic.setInstanceDescription("Is Not Null");
        }
        else if (inActc instanceof StudioConceptTagTypeInfoContext) {
            
            StudioConceptTagTypeInfoContext scttic =
                (StudioConceptTagTypeInfoContext)inActc;
            
            scttic.setTypeTitle("Is Not Null");
            scttic.setTypeDescription("Is Not Null");
        }
        else if (inActc instanceof WebPageTagInstanceViewContext) {
            
            WebPageTagInstanceViewContext wptivc =
                (WebPageTagInstanceViewContext)inActc;
            
            WebPageTagInstanceViewContextInfo info = wptivc.getInfoAsNonHtml();
            
            //if (this.valueCtchar.getValueLength() == 1) {
                WebPageTagInstanceViewContext.displayView(
                    this.valueCtchar, info, wptivc, "???");
                info.setNonHtmlContent("", " IS NOT NULL");
            //}
            //else {
            //    info.setNonHtmlContent("??? IS NOT NULL");
            //}
        }
        else if (inActc instanceof SelectionCriteriaForReturnableConceptTag) {
            
            SelectionCriteriaForReturnableConceptTag scfrct =
                (SelectionCriteriaForReturnableConceptTag)inActc;
            
            scfrct.canReturnBoolean();
            scfrct.declareFormatAsPlain();
        }
        else if (inActc instanceof StudioConceptTagCreParInfoContext) {
            
            StudioConceptTagCreParInfoContext scpc =
                (StudioConceptTagCreParInfoContext)inActc;
        }
    }
    
    public void determineValueAndClass(
        DetermineValueAndClassConceptTagContext inDvacctc) {
        
        try {
            ValueAndClassForConceptTag vacfct = null;
            
            ValueAndClassForConceptTag valueVac =
                this.valueCtchar.getDetermineValueAndClass(0, inDvacctc);
            
            vacfct = ValueAndClassForConceptTag.newBoolean(
                new Boolean(valueVac.getValue() != null));
            
            inDvacctc.setDetermineValueAndClass(vacfct);
        }
        catch (DetermineValueAndClassConceptTagException dvaccte) {
            inDvacctc.setDetermineException(dvaccte);
        }
    }
    
    public void determineClass(DetermineClassConceptTagContext inDcctc) {
        
        inDcctc.setDetermineClass(StandardDataTypes.getBooleanClass());
    }
    
    
    public Object createUninitializedSelf() {
        return new CommonFunctionCompIsNotNullTag();
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.