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.List;
 
 
 import static ch.qos.logback.core.CoreConstants.CURLY_RIGHT;
 
 
 import static ch.qos.logback.core.CoreConstants.ESCAPE_CHAR;
 import static ch.qos.logback.core.CoreConstants.COMMA_CHAR;
 import static ch.qos.logback.core.CoreConstants.SINGLE_QUOTE_CHAR;
 import static ch.qos.logback.core.CoreConstants.DOUBLE_QUOTE_CHAR;
 
 
 
 public class OptionTokenizer {
 
   private final static int EXPECTING_STATE = 0;
   private final static int RAW_COLLECTING_STATE = 1;
   private final static int QUOTED_COLLECTING_STATE = 2;
 
 
   final IEscapeUtil escapeUtil;
   final TokenStream tokenStream;
   final String pattern;
   final int patternLength;
 
   char quoteChar;
   int state = ;
 
   OptionTokenizer(TokenStream tokenStream) {
     this(tokenStreamnew AsIsEscapeUtil());
   }
 
   OptionTokenizer(TokenStream tokenStreamIEscapeUtil escapeUtil) {
     this. = tokenStream;
     this. = tokenStream.pattern;
     this. = tokenStream.patternLength;
     this. = escapeUtil;
   }
 
   void tokenize(char firstCharList<TokentokenListthrows ScanException {
     StringBuffer buf = new StringBuffer();
     List<StringoptionList = new ArrayList<String>();
     char c = firstChar;
 
     while (. < ) {
       switch () {
         case :
           switch (c) {
             case ' ':
             case '\t':
             case '\r':
             case '\n':
             case :
               break;
             case :
             case :
                = ;
                = c;
               break;
             case :
               emitOptionToken(tokenListoptionList);
               return;
             default:
               buf.append(c);
                = ;
           }
           break;
         case :
           switch (c) {
             case :
               optionList.add(buf.toString().trim());
               buf.setLength(0);
                = ;
               break;
             case :
               optionList.add(buf.toString().trim());
               emitOptionToken(tokenListoptionList);
               return;
             default:
              buf.append(c);
          }
          break;
        case :
          if (c == ) {
            optionList.add(buf.toString());
            buf.setLength(0);
             = ;
          } else if (c == ) {
            escape(String.valueOf(), buf);
          } else {
            buf.append(c);
          }
          break;
      }
      c = .charAt(.);
      .++;
    }
    // EOS
    if (c == ) {
      if( == ) {
        emitOptionToken(tokenListoptionList);
      } else if( == ){
        optionList.add(buf.toString().trim());
        emitOptionToken(tokenListoptionList);
      } else {
        throw new ScanException("Unexpected end of pattern string in OptionTokenizer");
      }
    } else {
      throw new ScanException("Unexpected end of pattern string in OptionTokenizer");
    }
  }
  void emitOptionTokenList<TokentokenListList<StringoptionList) {
     tokenList.add(new Token(.optionList));
  }
  void escape(String escapeCharsStringBuffer buf) {
    if ((. < )) {
      char next = .charAt(.++);
      .escape(escapeCharsbufnext.);
    }
  }
New to GrepCode? Check out our FAQ X