View Javadoc

1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.core.util;
11  
12  /**
13   * Various utility methods for processing strings representing context types.
14   * 
15   * @author Ceki Gulcu
16   * 
17   */
18  public class ContentTypeUtil {
19  
20    public static boolean isTextual(String contextType) {
21      if (contextType == null) {
22        return false;
23      }
24      return contextType.startsWith("text");
25    }
26  
27    public static String getSubType(String contextType) {
28      if (contextType == null) {
29        return null;
30      }
31      int index = contextType.indexOf('/');
32      if (index == -1) {
33        return null;
34      } else {
35        int subTypeStartIndex = index + 1;
36        if (subTypeStartIndex < contextType.length()) {
37          return contextType.substring(subTypeStartIndex);
38        } else {
39          return null;
40        }
41      }
42    }
43  }