001    package railo.transformer.cfml.evaluator.impl;
002    
003    import railo.runtime.config.Config;
004    import railo.runtime.exp.TemplateException;
005    import railo.runtime.op.Caster;
006    import railo.transformer.bytecode.statement.tag.Tag;
007    import railo.transformer.bytecode.util.ASMUtil;
008    import railo.transformer.cfml.evaluator.EvaluatorSupport;
009    import railo.transformer.library.function.FunctionLib;
010    import railo.transformer.library.tag.TagLib;
011    import railo.transformer.library.tag.TagLibTag;
012    import railo.transformer.util.CFMLString;
013    
014    /**
015     * Pr�ft den Kontext des Tag <code>catch</code>.
016     * Das Tag darf sich nur direkt innerhalb des Tag <code>try</code> befinden.
017     */ 
018    public final class ProcessingDirective extends EvaluatorSupport {
019        
020        public TagLib execute(Config config, Tag tag, TagLibTag libTag, FunctionLib[] flibs, CFMLString cfml) throws TemplateException {
021            String encoding=null;
022            Boolean exeLog=null;
023            if(tag.containsAttribute("pageencoding")) {
024                encoding=ASMUtil.getAttributeString(tag, "pageencoding",null);
025                if(encoding==null)
026                    throw new TemplateException(cfml,"attribute [pageencoding] of the tag [processingdirective] must be a constant value");
027                
028                if(encoding.equalsIgnoreCase(cfml.getCharset()) || "UTF-8".equalsIgnoreCase(cfml.getCharset())) {
029                            encoding=null;
030                    }
031            }
032            if(tag.containsAttribute("executionlog")) {
033                    String strExeLog=ASMUtil.getAttributeString(tag, "executionlog",null);
034                exeLog=Caster.toBoolean(strExeLog,null);
035                if(exeLog==null)
036                    throw new TemplateException(cfml,"attribute [executionlog] of the tag [processingdirective] must be a constant boolean value");
037                if(exeLog.booleanValue()==cfml.getWriteLog())
038                    exeLog=null;
039            }
040            
041            if(encoding!=null || exeLog!=null){
042                    if(encoding==null)      encoding=cfml.getCharset();
043                    if(exeLog==null)exeLog=cfml.getWriteLog()?Boolean.TRUE:Boolean.FALSE;
044                    throw new ProcessingDirectiveException(cfml,encoding,exeLog);
045            }
046            
047            
048            return null;    //�
049            }
050    }