Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
 
 package ch.qos.logback.core.pattern.parser;
 
 import java.util.Map;
 
 
 class Compiler<E> extends ContextAwareBase {
 
   Converter<E> head;
   Converter<E> tail;
   final Node top;
   final Map converterMap;
 
   Compiler(final Node topfinal Map converterMap) {
     this. = top;
     this. = converterMap;
   }
 
   Converter<E> compile() {
      =  = null;
     for (Node n = n != nulln = n.next) {
       switch (n.type) {
         case .:
           addToList(new LiteralConverter<E>((Stringn.getValue()));
           break;
         case .:
           CompositeNode cn = (CompositeNoden;
           CompositeConverter<E> compositeConverter = createCompositeConverter(cn);
           if(compositeConverter == null) {
             addError("Failed to create converter for [%"+cn.getValue()+"] keyword");
             addToList(new LiteralConverter<E>("%PARSER_ERROR["+cn.getValue()+"]"));
             break;
           }
           compositeConverter.setFormattingInfo(cn.getFormatInfo());
           compositeConverter.setOptionList(cn.getOptions());
           Compiler<E> childCompiler = new Compiler<E>(cn.getChildNode(),
                   );
           childCompiler.setContext();
           Converter<E> childConverter = childCompiler.compile();
           compositeConverter.setChildConverter(childConverter);
           addToList(compositeConverter);
           break;
         case .:
           SimpleKeywordNode kn = (SimpleKeywordNoden;
           DynamicConverter<E> dynaConverter = createConverter(kn);
           if (dynaConverter != null) {
             dynaConverter.setFormattingInfo(kn.getFormatInfo());
             dynaConverter.setOptionList(kn.getOptions());
             addToList(dynaConverter);
           } else {
             // if the appropriate dynaconverter cannot be found, then replace
             // it with a dummy LiteralConverter indicating an error.
             Converter<E> errConveter = new LiteralConverter<E>("%PARSER_ERROR["
                     + kn.getValue() + "]");
             addStatus(new ErrorStatus("[" + kn.getValue()
                     + "] is not a valid conversion word"this));
             addToList(errConveter);
           }
 
       }
     }
     return ;
   }
 
   private void addToList(Converter<E> c) {
     if ( == null) {
        =  = c;
     } else {
       .setNext(c);
        = c;
     }
   }

  
Attempt to create a converter using the information found in 'converterMap'.

Parameters:
kn
Returns:
 
  @SuppressWarnings("unchecked")
    String keyword = (Stringkn.getValue();
    String converterClassStr = (String.get(keyword);
    if (converterClassStr != null) {
      try {
        return (DynamicConverter) OptionHelper.instantiateByClassName(
                converterClassStrDynamicConverter.class);
      } catch (Exception e) {
        addError("Failed to instantiate converter class [" + converterClassStr
                + "] for keyword ["+keyword+"]"e);
        return null;
      }
    } else {
      addError("There is no conversion class registered for conversion word ["
              + keyword + "]");
      return null;
    }
  }

  
Attempt to create a converter using the information found in 'compositeConverterMap'.

Parameters:
cn
Returns:
  @SuppressWarnings("unchecked")
    String keyword = (Stringcn.getValue();
    String converterClassStr = (String.get(keyword);
    if (converterClassStr != null) {
      try {
        return (CompositeConverter) OptionHelper.instantiateByClassName(
                converterClassStrCompositeConverter.class);
      } catch (Exception e) {
        addError("Failed to instantiate converter class [" + converterClassStr
                + "] as a composite converter for keyword ["+keyword+"]"e);
        return null;
      }
    } else {
      addError("There is no conversion class registered for composite conversion word ["
              + keyword + "]");
      return null;
    }
  }
  // public void setStatusManager(StatusManager statusManager) {
  // this.statusManager = statusManager;
  // }
  //  
  // void addStatus(Status status) {
  // if(statusManager != null) {
  // statusManager.add(status);
  // }
  // }
New to GrepCode? Check out our FAQ X