org.eclipse.osgi_3.7.2.v20120110-1415

(patLen == 0) {
      return false;
    }
    if (dnPattern.get(0).equals("*"))
    {
      patStart = 1;
      patLen--;
    }
    if (dn.size() < patLen) {
      return false;
    }
    if (dn.size() > patLen)
    {
      if (!dnPattern.get(0).equals("*")) {
        return false;
      }
      dnStart = dn.size() - patLen;
    }
    for (int i = 0; i < patLen; i++) {
      if (!rdnmatch((List)dn.get(i + dnStart), 
      
        (List)dnPattern.get(i + patStart))) {
        return false;
      }
    }
    return true;
  }
  
  private static List<Object> parseDNchainPattern(String dnChain)
  {
    if (dnChain == null) {
      throw new IllegalArgumentException(
        "The DN chain must not be null.");
    }
    List<Object> parsed = new ArrayList();
    int startIndex = 0;
    startIndex = skipSpaces(dnChain, startIndex);
    label124:
    while (startIndex < dnChain.length())
    {
      int endIndex = startIndex;
      boolean inQuote = false;
      while (endIndex < dnChain.length())
      {
        char c = dnChain.charAt(endIndex);
        switch (c)
        {
        case '"': 
          inQuote = !inQuote;
          break;
        case '\\': 
          endIndex++;
          break;
        case ';': 
          if (!inQuote) {
            break label124;
          }
        }
        endIndex++;
      }
      if (endIndex > dnChain.length()) {
        throw new IllegalArgumentException("unterminated escape");
      }
      parsed.add(dnChain.substring(startIndex, endIndex));
      startIndex = endIndex + 1;
      startIndex = skipSpaces(dnChain, startIndex);
    }
    for (int i = 0; i < parsed.size(); i++)
    {
      String dn = (String)parsed.get(i);
      if ((!dn.equals("*")) && (!dn.equals("-")))
      {
        List<Object> rdns = new ArrayList();
        if (dn.charAt(0) == '*')
        {
          if (dn.charAt(1) != ',') {
            throw new IllegalArgumentException(
              "invalid wildcard prefix");
          }
          rdns.add("*");
          dn = new X500Principal(dn.substring(2))
            .getName("CANONICAL");
        }
        else
        {
          dn = new X500Principal(dn).getName("CANONICAL");
        }
        parseDN(dn, rdns);
        parsed.set(i, rdns);
      }
    }
    if (parsed.size() == 0) {
      throw new IllegalArgumentException("empty DN chain");
    }
    return parsed;
  }
  
  private static List<Object> parseDNchain(List<String> chain)
  {
    if (chain == null) {
      throw new IllegalArgumentException("DN chain must not be null.");
    }
    List<Object> result = new ArrayList(chain.size());
    for (Iterator localIterator = chain.iterator(); localIterator.hasNext();)
    {
      String dn = (String)localIterator.next();
      dn = new X500Principal(dn).getName("CANONICAL");
      
      List<Object> rdns = new ArrayList();
      parseDN(dn, rdns);
      result.add(rdns);
    }
    if (result.size() == 0) {
      throw new IllegalArgumentException("empty DN chain");
    }
    return result;
  }
  
  private static int skipSpaces(String dnChain, int startIndex)
  {
    while ((startIndex < dnChain.length()) && 
      (dnChain.charAt(startIndex) == ' ')) {
      startIndex++;
    }
    return startIndex;
  }
  
  private static void parseDN(String dn, List<Object> rdn)
  {
    int startIndex = 0;
    char c = '\000';
    List<String> nameValues = new ArrayList();
    while (startIndex < dn.length())
    {
      for (int endIndex = startIndex; endIndex < dn.length(); endIndex++)
      {
        c = dn.charAt(endIndex);
        if ((c == ',') || (c == '+')) {
          break;
        }
        if (c == '\\') {
          endIndex++;
        }
      }
      if (endIndex > dn.length()) {
        throw new IllegalArgumentException("unterminated escape " + 
          dn);
      }
      nameValues.add(dn.substring(startIndex, endIndex));
      if (c != '+')
      {
        rdn.add(nameValues);
        if (endIndex != dn.length()) {
          nameValues = new ArrayList();
        } else {
          nameValues = null;
        }
      }
      startIndex = endIndex + 1;
    }
    if (nameValues != null) {
      throw new IllegalArgumentException("improperly terminated DN " + 
        dn);
    }
  }
  
  private static int skipWildCards(List<Object> dnChainPattern, int dnChainPatternIndex)
  {
    for (int i = dnChainPatternIndex; i < dnChainPattern.size(); i++)
    {
      Object dnPattern = dnChainPattern.get(i);
      if ((dnPattern instanceof String))
      {
        if ((!dnPattern.equals("*")) && 
          (!dnPattern.equals("-"))) {
          throw new IllegalArgumentException(
            "expected wildcard in DN pattern");
        }
      }
      else
      {
        if ((dnPattern instanceof List)) {
          break;
        }
        throw new IllegalArgumentException(
          "expected String or List in DN Pattern");
      }
    }
    return i;
  }
  
  private static boolean dnChainMatch(List<Object> dnChain, int dnChainIndex, List<Object> dnChainPattern, int dnChainPatternIndex)
    throws IllegalArgumentException
  {
    if (dnChainIndex >= dnChain.size()) {
      return false;
    }
    if (dnChainPatternIndex >= dnChainPattern.size()) {
      return false;
    }
    Object dnPattern = dnChainPattern.get(dnChainPatternIndex);
    if ((dnPattern instanceof String))
    {
      if ((!dnPattern.equals("*")) && 
        (!dnPattern.equals("-"))) {
        throw new IllegalArgumentException(
          "expected wildcard in DN pattern");
      }
      if (dnPattern.equals("-")) {
        dnChainPatternIndex = skipWildCards(dnChainPattern, 
          dnChainPatternIndex);
      } else {
        dnChainPatternIndex++;
      }
      if (dnChainPatternIndex >= dnChainPattern.size()) {
        return dnPattern.equals("-");
      }
      if (dnPattern.equals("*"))
      {
        if (!dnChainMatch(dnChain, dnChainIndex, dnChainPattern, 
          dnChainPatternIndex)) {
          if (!dnChainMatch(dnChain, dnChainIndex + 1, 
            dnChainPattern, dnChainPatternIndex)) {
            return false;
          }
        }
        return 
        
          true;
      }
      for (int i = dnChainIndex; i < dnChain.size(); i++) {
        if (dnChainMatch(dnChain, i, dnChainPattern, 
          dnChainPatternIndex)) {
          return true;
        }
      }
    }
    else
    {
      if ((dnPattern instanceof List))
      {
        do
        {
          if (!dnmatch((List)dnChain.get(dnChainIndex), 
            (List)dnPattern)) {
            return false;
          }
          dnChainIndex++;
          dnChainPatternIndex++;
          if (dnChainIndex >= dnChain.size()) {
            if (dnChainPatternIndex >= dnChainPattern.size()) {
              return true;
            }
          }
          if (dnChainIndex >= dnChain.size())
          {
            dnChainPatternIndex = skipWildCards(dnChainPattern, 
              dnChainPatternIndex);
            
            return dnChainPatternIndex >= dnChainPattern.size();
          }
          if (dnChainPatternIndex >= dnChainPattern.size()) {
            return false;
          }
          dnPattern = dnChainPattern.get(dnChainPatternIndex);
          if ((dnPattern instanceof String))
          {
            if ((!dnPattern.equals("*")) && 
              (!dnPattern.equals("-"))) {
              throw new IllegalArgumentException(
                "expected wildcard in DN pattern");
            }
            return dnChainMatch(dnChain, dnChainIndex, 
              dnChainPattern, dnChainPatternIndex);
          }
        } while ((dnPattern instanceof List));
        throw new IllegalArgumentException(
          "expected String or List in DN Pattern");
      }
      throw new IllegalArgumentException(
        "expected String or List in DN Pattern");
    }
    return false;
  }
  
  static boolean match(String pattern, List<String> dnChain)
  {
    try
    {
      parsedDNChain = parseDNchain(dnChain);
    }
    catch (RuntimeException e)
    {
      List<Object> parsedDNChain;
      IllegalArgumentException iae = new IllegalArgumentException(
        "Invalid DN chain: " + toString(dnChain));
      iae.initCause(e);
      throw iae;
    }
    List<Object> parsedDNChain;
    try
    {
      parsedDNPattern = parseDNchainPattern(pattern);
    }
    catch (RuntimeException e)
    {
      List<Object> parsedDNPattern;
      IllegalArgumentException iae = new IllegalArgumentException(
        "Invalid match pattern: " + pattern);
      iae.initCause(e);
      throw iae;
    }
    List<Object> parsedDNPattern;
    return dnChainMatch(parsedDNChain, 0, parsedDNPattern, 0);
  }
  
  private static String toString(List<?> dnChain)
  {
    if (dnChain == null) {
      return null;
    }
    StringBuffer sb = new StringBuffer();
    for (Iterator<?> iChain = dnChain.iterator(); iChain.hasNext();)
    {
      sb.append(iChain.next());
      if (iChain.hasNext()) {
        sb.append("; ");
      }
    }
    return sb.toString();
  }
}

/* Location:
 * Qualified Name:     org.osgi.framework.FrameworkUtil.DNChainMatching
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

import java.util.ArrayList;
import java.util.List;

final class FrameworkUtil$FilterImpl$Parser
{
  private final String filterstring;
  private final char[] filterChars;
  private int pos;
  
  FrameworkUtil$FilterImpl$Parser(String filterstring)
  {
    this.filterstring = filterstring;
    filterChars = filterstring.toCharArray();
    pos = 0;
  }
  
  FrameworkUtil.FilterImpl parse()
    throws InvalidSyntaxException
  {
    try
    {
      filter = parse_filter();
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      FrameworkUtil.FilterImpl filter;
      throw new InvalidSyntaxException("Filter ended abruptly", 
        filterstring, e);
    }
    FrameworkUtil.FilterImpl filter;
    if (pos != filterChars.length) {
      throw new InvalidSyntaxException(
        "Extraneous trailing characters: " + 
        filterstring.substring(pos), filterstring);
    }
    return filter;
  }
  
  private FrameworkUtil.FilterImpl parse_filter()
    throws InvalidSyntaxException
  {
    skipWhiteSpace();
    if (filterChars[pos] != '(') {
      throw new InvalidSyntaxException("Missing '(': " + 
        filterstring.substring(pos), filterstring);
    }
    pos += 1;
    
    FrameworkUtil.FilterImpl filter = parse_filtercomp();
    
    skipWhiteSpace();
    if (filterChars[pos] != ')') {
      throw new InvalidSyntaxException("Missing ')': " + 
        filterstring.substring(pos), filterstring);
    }
    pos += 1;
    
    skipWhiteSpace();
    
    return filter;
  }
  
  private FrameworkUtil.FilterImpl parse_filtercomp()
    throws InvalidSyntaxException
  {
    skipWhiteSpace();
    
    char c = filterChars[pos];
    switch (c)
    {
    case '&': 
      pos += 1;
      return parse_and();
    case '|': 
      pos += 1;
      return parse_or();
    case '!': 
      pos += 1;
      return parse_not();
    }
    return parse_item();
  }
  
  private FrameworkUtil.FilterImpl parse_and()
    throws InvalidSyntaxException
  {
    int lookahead = pos;
    skipWhiteSpace();
    if (filterChars[pos] != '(')
    {
      pos = (lookahead - 1);
      return parse_item();
    }
    List<FrameworkUtil.FilterImpl> operands = new ArrayList(10);
    while (filterChars[pos] == '(')
    {
      FrameworkUtil.FilterImpl child = parse_filter();
      operands.add(child);
    }
    return new FrameworkUtil.FilterImpl(7, null, operands
      .toArray(new FrameworkUtil.FilterImpl[operands.size()]));
  }
  
  private FrameworkUtil.FilterImpl parse_or()
    throws InvalidSyntaxException
  {
    int lookahead = pos;
    skipWhiteSpace();
    if (filterChars[pos] != '(')
    {
      pos = (lookahead - 1);
      return parse_item();
    }
    List<FrameworkUtil.FilterImpl> operands = new ArrayList(10);
    while (filterChars[pos] == '(')
    {
      FrameworkUtil.FilterImpl child = parse_filter();
      operands.add(child);
    }
    return new FrameworkUtil.FilterImpl(8, null, operands
      .toArray(new FrameworkUtil.FilterImpl[operands.size()]));
  }
  
  private FrameworkUtil.FilterImpl parse_not()
    throws InvalidSyntaxException
  {
    int lookahead = pos;
    skipWhiteSpace();
    if (filterChars[pos] != '(')
    {
      pos = (lookahead - 1);
      return parse_item();
    }
    FrameworkUtil.FilterImpl child = parse_filter();
    
    return new FrameworkUtil.FilterImpl(9, null, child);
  }
  
  private FrameworkUtil.FilterImpl parse_item()
    throws InvalidSyntaxException
  {
    String attr = parse_attr();
    
    skipWhiteSpace();
    switch (filterChars[pos])
    {
    case '~': 
      if (filterChars[(pos + 1)] == '=')
      {
        pos += 2;
        return new FrameworkUtil.FilterImpl(2, attr, 
          parse_value());
      }
      break;
    case '>': 
      if (filterChars[(pos + 1)] == '=')
      {
        pos += 2;
        return new FrameworkUtil.FilterImpl(3, attr, 
          parse_value());
      }
      break;
    case '<': 
      if (filterChars[(pos + 1)] == '=')
      {
        pos += 2;
        return new FrameworkUtil.FilterImpl(4, attr, 
          parse_value());
      }
      break;
    case '=': 
      if (filterChars[(pos + 1)] == '*')
      {
        int oldpos = pos;
        pos += 2;
        skipWhiteSpace();
        if (filterChars[pos] == ')') {
          return new FrameworkUtil.FilterImpl(5, attr, 
            null);
        }
        pos = oldpos;
      }
      pos += 1;
      Object string = parse_substring();
      if ((string instanceof String)) {
        return new FrameworkUtil.FilterImpl(1, attr, 
          string);
      }
      return new FrameworkUtil.FilterImpl(6, attr, 
        string);
    }
    throw new InvalidSyntaxException("Invalid operator: " + 
      filterstring.substring(pos), filterstring);
  }
  
  private String parse_attr()
    throws InvalidSyntaxException
  {
    skipWhiteSpace();
    
    int begin = pos;
    int end = pos;
    
    char c = filterChars[pos];
    while ((c != '~') && (c != '<') && (c != '>') && (c != '=') && (c != '(') && 
      (c != ')'))
    {
      pos += 1;
      if (!Character.isWhitespace(c)) {
        end = pos;
      }
      c = filterChars[pos];
    }
    int length = end - begin;
    if (length == 0) {
      throw new InvalidSyntaxException("Missing attr: " + 
        filterstring.substring(pos), filterstring);
    }
    return new String(filterChars, begin, length);
  }
  
  private String parse_value()
    throws InvalidSyntaxException
  {
    StringBuffer sb = new StringBuffer(filterChars.length - pos);
    for (;;)
    {
      char c = filterChars[pos];
      switch (c)
      {
      case ')': 
        break;
      case '(': 
        throw new InvalidSyntaxException("Invalid value: " + 
          filterstring.substring(pos), filterstring);
      case '\\': 
        pos += 1;
        c = filterChars[pos];
      default: 
        sb.append(c);
        pos += 1;
      }
    }
    if (sb.length() == 0) {
      throw new InvalidSyntaxException("Missing value: " + 
        filterstring.substring(pos), filterstring);
    }
    return sb.toString();
  }
  
  private Object parse_substring()
    throws InvalidSyntaxException
  {
    StringBuffer sb = new StringBuffer(filterChars.length - pos);
    
    List<String> operands = new ArrayList(10);
    for (;;)
    {
      char c = filterChars[pos];
      switch (c)
      {
      case ')': 
        if (sb.length() <= 0) {
          break label222;
        }
        operands.add(sb.toString());
        
        break;
      case '(': 
        throw new InvalidSyntaxException("Invalid value: " + 
          filterstring.substring(pos), filterstring);
      case '*': 
        if (sb.length() > 0) {
          operands.add(sb.toString());
        }
        sb.setLength(0);
        
        operands.add(null);
        pos += 1;
        
        break;
      case '\\': 
        pos += 1;
        c = filterChars[pos];
      default: 
        sb.append(c);
        pos += 1;
      }
    }
    label222:
    int size = operands.size();
    if (size == 0) {
      return "";
    }
    if (size == 1)
    {
      Object single = operands.get(0);
      if (single != null) {
        return single;
      }
    }
    return operands.toArray(new String[size]);
  }
  
  private void skipWhiteSpace()
  {
    for (int length = filterChars.length; (pos < length) && (
          Character.isWhitespace(filterChars[pos]));) {
      pos += 1;
    }
  }
}

/* Location:
 * Qualified Name:     org.osgi.framework.FrameworkUtil.FilterImpl.Parser
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Dictionary;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

final class FrameworkUtil$FilterImpl
  implements Filter
{
  private static final int EQUAL = 1;
  private static final int APPROX = 2;
  private static final int GREATER = 3;
  private static final int LESS = 4;
  private static final int PRESENT = 5;
  private static final int SUBSTRING = 6;
  private static final int AND = 7;
  private static final int OR = 8;
  private static final int NOT = 9;
  private final int op;
  private final String attr;
  private final Object value;
  private transient String filterString;
  
  static FilterImpl newInstance(String filterString)
    throws InvalidSyntaxException
  {
    return new Parser(filterString).parse();
  }
  
  FrameworkUtil$FilterImpl(int operation, String attr, Object value)
  {
    op = operation;
    this.attr = attr;
    this.value = value;
    filterString = null;
  }
  
  public boolean match(ServiceReference<?> reference)
  {
    return matches(new FrameworkUtil.ServiceReferenceMap(reference));
  }
  
  public boolean match(Dictionary<String, ?> dictionary)
  {
    return matches(new FrameworkUtil.CaseInsensitiveMap(dictionary));
  }
  
  public boolean matchCase(Dictionary<String, ?> dictionary)
  {
    FilterImpl[] arrayOfFilterImpl1;
    int j;
    int i;
    switch (op)
    {
    case 7: 
      FilterImpl[] filters = (FilterImpl[])value;
      j = (arrayOfFilterImpl1 = filters).length;
      for (i = 0; i < j; i++)
      {
        FilterImpl f = arrayOfFilterImpl1[i];
        if (!f.matchCase(dictionary)) {
          return false;
        }
      }
      return true;
    case 8: 
      FilterImpl[] filters = (FilterImpl[])value;
      j = (arrayOfFilterImpl1 = filters).length;
      for (i = 0; i < j; i++)
      {
        FilterImpl f = arrayOfFilterImpl1[i];
        if (f.matchCase(dictionary)) {
          return true;
        }
      }
      return false;
    case 9: 
      FilterImpl filter = (FilterImpl)value;
      return !filter.matchCase(dictionary);
    case 1: 
    case 2: 
    case 3: 
    case 4: 
    case 6: 
      Object prop = dictionary == null ? null : dictionary
        .get(attr);
      return compare(op, prop, value);
    case 5: 
      Object prop = dictionary == null ? null : dictionary
        .get(attr);
      return prop != null;
    }
    return false;
  }
  
  public boolean matches(Map<String, ?> map)
  {
    FilterImpl[] arrayOfFilterImpl1;
    int j;
    int i;
    switch (op)
    {
    case 7: 
      FilterImpl[] filters = (FilterImpl[])value;
      j = (arrayOfFilterImpl1 = filters).length;
      for (i = 0; i < j; i++)
      {
        FilterImpl f = arrayOfFilterImpl1[i];
        if (!f.matches(map)) {
          return false;
        }
      }
      return true;
    case 8: 
      FilterImpl[] filters = (FilterImpl[])value;
      j = (arrayOfFilterImpl1 = filters).length;
      for (i = 0; i < j; i++)
      {
        FilterImpl f = arrayOfFilterImpl1[i];
        if (f.matches(map)) {
          return true;
        }
      }
      return false;
    case 9: 
      FilterImpl filter = (FilterImpl)value;
      return !filter.matches(map);
    case 1: 
    case 2: 
    case 3: 
    case 4: 
    case 6: 
      Object prop = map == null ? null : map.get(attr);
      return compare(op, prop, value);
    case 5: 
      Object prop = map == null ? null : map.get(attr);
      return prop != null;
    }
    return false;
  }
  
  public String toString()
  {
    String result = filterString;
    if (result == null) {
      filterString = (result = normalize().toString());
    }
    return result;
  }
  
  private StringBuffer normalize()
  {
    StringBuffer sb = new StringBuffer();
    sb.append('(');
    Object localObject;
    int j;
    int i;
    switch (op)
    {
    case 7: 
      sb.append('&');
      
      FilterImpl[] filters = (FilterImpl[])value;
      j = (localObject = filters).length;
      for (i = 0; i < j; i++)
      {
        FilterImpl f = localObject[i];
        sb.append(f.normalize());
      }
      break;
    case 8: 
      sb.append('|');
      
      FilterImpl[] filters = (FilterImpl[])value;
      j = (localObject = filters).length;
      for (i = 0; i < j; i++)
      {
        FilterImpl f = localObject[i];
        sb.append(f.normalize());
      }
      break;
    case 9: 
      sb.append('!');
      FilterImpl filter = (FilterImpl)value;
      sb.append(filter.normalize());
      
      break;
    case 6: 
      sb.append(attr);
      sb.append('=');
      
      String[] substrings = (String[])value;
      
      j = (localObject = substrings).length;
      for (i = 0; i < j; i++)
      {
        String substr = localObject[i];
        if (substr == null) {
          sb.append('*');
        } else {
          sb.append(encodeValue(substr));
        }
      }
      break;
    case 1: 
      sb.append(attr);
      sb.append('=');
      sb.append(encodeValue((String)value));
      
      break;
    case 3: 
      sb.append(attr);
      sb.append(">=");
      sb.append(encodeValue((String)value));
      
      break;
    case 4: 
      sb.append(attr);
      sb.append("<=");
      sb.append(encodeValue((String)value));
      
      break;
    case 2: 
      sb.append(attr);
      sb.append("~=");
      sb.append(encodeValue(approxString((String)value)));
      
      break;
    case 5: 
      sb.append(attr);
      sb.append("=*");
    }
    sb.append(')');
    
    return sb;
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof Filter)) {
      return false;
    }
    return toString().equals(obj.toString());
  }
  
  public int hashCode()
  {
    return toString().hashCode();
  }
  
  private static String encodeValue(String value)
  {
    boolean encoded = false;
    int inlen = value.length();
    int outlen = inlen << 1;
    
    char[] output = new char[outlen];
    value.getChars(0, inlen, output, inlen);
    
    int cursor = 0;
    for (int i = inlen; i < outlen; i++)
    {
      char c = output[i];
      switch (c)
      {
      case '(': 
      case ')': 
      case '*': 
      case '\\': 
        output[cursor] = '\\';
        cursor++;
        encoded = true;
      }
      output[cursor] = c;
      cursor++;
    }
    return encoded ? new String(output, 0, cursor) : value;
  }
  
  private boolean compare(int operation, Object value1, Object value2)
  {
    if (value1 == null) {
      return false;
    }
    if ((value1 instanceof String)) {
      return compare_String(operation, (String)value1, value2);
    }
    Class<?> clazz = value1.getClass();
    if (clazz.isArray())
    {
      Class<?> type = clazz.getComponentType();
      if (type.isPrimitive()) {
        return compare_PrimitiveArray(operation, type, value1, 
          value2);
      }
      return compare_ObjectArray(operation, (Object[])value1, value2);
    }
    if ((value1 instanceof Collection)) {
      return compare_Collection(operation, (Collection)value1, 
        value2);
    }
    if ((value1 instanceof Integer)) {
      return compare_Integer(operation, 
        ((Integer)value1).intValue(), value2);
    }
    if ((value1 instanceof Long)) {
      return compare_Long(operation, ((Long)value1).longValue(), 
        value2);
    }
    if ((value1 instanceof Byte)) {
      return compare_Byte(operation, ((Byte)value1).byteValue(), 
        value2);
    }
    if ((value1 instanceof Short)) {
      return compare_Short(operation, ((Short)value1).shortValue(), 
        value2);
    }
    if ((value1 instanceof Character)) {
      return compare_Character(operation, ((Character)value1)
        .charValue(), value2);
    }
    if ((value1 instanceof Float)) {
      return compare_Float(operation, ((Float)value1).floatValue(), 
        value2);
    }
    if ((value1 instanceof Double)) {
      return compare_Double(operation, ((Double)value1)
        .doubleValue(), value2);
    }
    if ((value1 instanceof Boolean)) {
      return compare_Boolean(operation, ((Boolean)value1)
        .booleanValue(), value2);
    }
    if ((value1 instanceof Comparable))
    {
      Comparable<Object> comparable = (Comparable)value1;
      return compare_Comparable(operation, comparable, value2);
    }
    return compare_Unknown(operation, value1, value2);
  }
  
  private boolean compare_Collection(int operation, Collection<?> collection, Object value2)
  {
    for (Iterator localIterator = collection.iterator(); localIterator.hasNext();)
    {
      Object value1 = localIterator.next();
      if (compare(operation, value1, value2)) {
        return true;
      }
    }
    return false;
  }
  
  private boolean compare_ObjectArray(int operation, Object[] array, Object value2)
  {
    Object[] arrayOfObject;
    int j = (arrayOfObject = array).length;
    for (int i = 0; i < j; i++)
    {
      Object value1 = arrayOfObject[i];
      if (compare(operation, value1, value2)) {
        return true;
      }
    }
    return false;
  }
  
  private boolean compare_PrimitiveArray(int operation, Class<?> type, Object primarray, Object value2)
  {
    int j;
    int i;
    if (Integer.TYPE.isAssignableFrom(type))
    {
      int[] array = (int[])primarray;
      int[] arrayOfInt1;
      j = (arrayOfInt1 = array).length;
      for (i = 0; i < j; i++)
      {
        int value1 = arrayOfInt1[i];
        if (compare_Integer(operation, value1, value2)) {
          return true;
        }
      }
      return false;
    }
    Object localObject2;
    if (Long.TYPE.isAssignableFrom(type))
    {
      long[] array = (long[])primarray;
      int k = (localObject2 = array).length;
      for (j = 0; j < k; j++)
      {
        long value1 = localObject2[j];
        if (compare_Long(operation, value1, value2)) {
          return true;
        }
      }
      return false;
    }
    Object localObject1;
    if (Byte.TYPE.isAssignableFrom(type))
    {
      byte[] array = (byte[])primarray;
      j = (localObject1 = array).length;
      for (i = 0; i < j; i++)
      {
        byte value1 = localObject1[i];
        if (compare_Byte(operation, value1, value2)) {
          return true;
        }
      }
      return false;
    }
    if (Short.TYPE.isAssignableFrom(type))
    {
      short[] array = (short[])primarray;
      j = (localObject1 = array).length;
      for (i = 0; i < j; i++)
      {
        short value1 = localObject1[i];
        if (compare_Short(operation, value1, value2)) {
          return true;
        }
      }
      return false;
    }
    if (Character.TYPE.isAssignableFrom(type))
    {
      char[] array = (char[])primarray;
      j = (localObject1 = array).length;
      for (i = 0; i < j; i++)
      {
        char value1 = localObject1[i];
        if (compare_Character(operation, value1, value2)) {
          return true;
        }
      }
      return false;
    }
    if (Float.TYPE.isAssignableFrom(type))
    {
      float[] array = (float[])primarray;
      j = (localObject1 = array).length;
      for (i = 0; i < j; i++)
      {
        float value1 = localObject1[i];
        if (compare_Float(operation, value1, value2)) {
          return true;
        }
      }
      return false;
    }
    if (Double.TYPE.isAssignableFrom(type))
    {
      double[] array = (double[])primarray;
      int m = (localObject2 = array).length;
      for (j = 0; j < m; j++)
      {
        double value1 = localObject2[j];
        if (compare_Double(operation, value1, value2)) {
          return true;
        }
      }
      return false;
    }
    if (Boolean.TYPE.isAssignableFrom(type))
    {
      boolean[] array = (boolean[])primarray;
      boolean[] arrayOfBoolean1;
      j = (arrayOfBoolean1 = array).length;
      for (i = 0; i < j; i++)
      {
        boolean value1 = arrayOfBoolean1[i];
        if (compare_Boolean(operation, value1, value2)) {
          return true;
        }
      }
      return false;
    }
    return false;
  }
  
  private boolean compare_String(int operation, String string, Object value2)
  {
    switch (operation)
    {
    case 6: 
      String[] substrings = (String[])value2;
      int pos = 0;
      int i = 0;
      for (int size = substrings.length; i < size; i++)
      {
        String substr = substrings[i];
        if (i + 1 < size)
        {
          if (substr == null)
          {
            String substr2 = substrings[(i + 1)];
            if (substr2 != null)
            {
              int index = string.indexOf(substr2, pos);
              if (index == -1) {
                return false;
              }
              pos = index + substr2.length();
              if (i + 2 < size) {
                i++;
              }
            }
          }
          else
          {
            int len = substr.length();
            if (string.regionMatches(pos, substr, 0, len)) {
              pos += len;
            } else {
              return false;
            }
          }
        }
        else
        {
          if (substr == null) {
            return true;
          }
          return string.endsWith(substr);
        }
      }
      return true;
    case 1: 
      return string.equals(value2);
    case 2: 
      string = approxString(string);
      String string2 = approxString((String)value2);
      
      return string.equalsIgnoreCase(string2);
    case 3: 
      return string.compareTo((String)value2) >= 0;
    case 4: 
      return string.compareTo((String)value2) <= 0;
    }
    return false;
  }
  
  private boolean compare_Integer(int operation, int intval, Object value2)
  {
    if (operation == 6) {
      return false;
    }
    try
    {
      intval2 = Integer.parseInt(((String)value2).trim());
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      int intval2;
      return false;
    }
    int intval2;
    switch (operation)
    {
    case 1: 
    case 2: 
      return intval == intval2;
    case 3: 
      return intval >= intval2;
    case 4: 
      return intval <= intval2;
    }
    return false;
  }
  
  private boolean compare_Long(int operation, long longval, Object value2)
  {
    if (operation == 6) {
      return false;
    }
    try
    {
      longval2 = Long.parseLong(((String)value2).trim());
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      long longval2;
      return false;
    }
    long longval2;
    switch (operation)
    {
    case 1: 
    case 2: 
      return longval == longval2;
    case 3: 
      return longval >= longval2;
    case 4: 
      return longval <= longval2;
    }
    return false;
  }
  
  private boolean compare_Byte(int operation, byte byteval, Object value2)
  {
    if (operation == 6) {
      return false;
    }
    try
    {
      byteval2 = Byte.parseByte(((String)value2).trim());
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      byte byteval2;
      return false;
    }
    byte byteval2;
    switch (operation)
    {
    case 1: 
    case 2: 
      return byteval == byteval2;
    case 3: 
      return byteval >= byteval2;
    case 4: 
      return byteval <= byteval2;
    }
    return false;
  }
  
  private boolean compare_Short(int operation, short shortval, Object value2)
  {
    if (operation == 6) {
      return false;
    }
    try
    {
      shortval2 = Short.parseShort(((String)value2).trim());
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      short shortval2;
      return false;
    }
    short shortval2;
    switch (operation)
    {
    case 1: 
    case 2: 
      return shortval == shortval2;
    case 3: 
      return shortval >= shortval2;
    case 4: 
      return shortval <= shortval2;
    }
    return false;
  }
  
  private boolean compare_Character(int operation, char charval, Object value2)
  {
    if (operation == 6) {
      return false;
    }
    try
    {
      charval2 = ((String)value2).charAt(0);
    }
    catch (IndexOutOfBoundsException localIndexOutOfBoundsException)
    {
      char charval2;
      return false;
    }
    char charval2;
    switch (operation)
    {
    case 1: 
      return charval == charval2;
    case 2: 
      if ((charval != charval2) && 
        (Character.toUpperCase(charval) != 
        Character.toUpperCase(charval2))) {
        if (Character.toLowerCase(charval) != 
          Character.toLowerCase(charval2)) {
          return false;
        }
      }
      return 
      
        true;
    case 3: 
      return charval >= charval2;
    case 4: 
      return charval <= charval2;
    }
    return false;
  }
  
  private boolean compare_Boolean(int operation, boolean boolval, Object value2)
  {
    if (operation == 6) {
      return false;
    }
    boolean boolval2 = Boolean.valueOf(((String)value2).trim())
      .booleanValue();
    switch (operation)
    {
    case 1: 
    case 2: 
    case 3: 
    case 4: 
      return boolval == boolval2;
    }
    return false;
  }
  
  private boolean compare_Float(int operation, float floatval, Object value2)
  {
    if (operation == 6) {
      return false;
    }
    try
    {
      floatval2 = Float.parseFloat(((String)value2).trim());
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      float floatval2;
      return false;
    }
    float floatval2;
    switch (operation)
    {
    case 1: 
    case 2: 
      return Float.compare(floatval, floatval2) == 0;
    case 3: 
      return Float.compare(floatval, floatval2) >= 0;
    case 4: 
      return Float.compare(floatval, floatval2) <= 0;
    }
    return false;
  }
  
  private boolean compare_Double(int operation, double doubleval, Object value2)
  {
    if (operation == 6) {
      return false;
    }
    try
    {
      doubleval2 = Double.parseDouble(((String)value2).trim());
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      double doubleval2;
      return false;
    }
    double doubleval2;
    switch (operation)
    {
    case 1: 
    case 2: 
      return Double.compare(doubleval, doubleval2) == 0;
    case 3: 
      return Double.compare(doubleval, doubleval2) >= 0;
    case 4: 
      return Double.compare(doubleval, doubleval2) <= 0;
    }
    return false;
  }
  
  static
  {
    Class[] tmp4_1 = new Class[1]; Class tmp9_6 = FrameworkUtil.class$0;
    if (tmp9_6 == null)
    {
      tmp9_6;
      try
      {
        tmpTernaryOp = (FrameworkUtil.class$0 = Class.forName("java.lang.String"));
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
      }
    }
    tmp4_1[0] = tmp9_6;
  }
  
  private static final Class<?>[] constructorType = tmp4_1;
  
  private boolean compare_Comparable(int operation, Comparable<Object> value1, Object value2)
  {
    if (operation == 6) {
      return false;
    }
    try
    {
      constructor = value1.getClass().getConstructor(constructorType);
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
      Constructor<?> constructor;
      return false;
    }
    try
    {
      Constructor<?> constructor;
      if (!constructor.isAccessible()) {
        AccessController.doPrivileged(new FrameworkUtil.SetAccessibleAction(
          constructor));
      }
      value2 = 
        constructor.newInstance(new Object[] { ((String)value2).trim() });
    }
    catch (IllegalAccessException localIllegalAccessException)
    {
      return false;
    }
    catch (InvocationTargetException localInvocationTargetException)
    {
      return false;
    }
    catch (InstantiationException localInstantiationException)
    {
      return false;
    }
    try
    {
      switch (operation)
      {
      case 1: 
      case 2: 
        return value1.compareTo(value2) == 0;
      case 3: 
        return value1.compareTo(value2) >= 0;
      case 4: 
        return value1.compareTo(value2) <= 0;
      }
    }
    catch (Exception localException)
    {
      return false;
    }
    return false;
  }
  
  private boolean compare_Unknown(int operation, Object value1, Object value2)
  {
    if (operation == 6) {
      return false;
    }
    try
    {
      constructor = value1.getClass().getConstructor(constructorType);
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
      Constructor<?> constructor;
      return false;
    }
    try
    {
      Constructor<?> constructor;
      if (!constructor.isAccessible()) {
        AccessController.doPrivileged(new FrameworkUtil.SetAccessibleAction(
          constructor));
      }
      value2 = 
        constructor.newInstance(new Object[] { ((String)value2).trim() });
    }
    catch (IllegalAccessException localIllegalAccessException)
    {
      return false;
    }
    catch (InvocationTargetException localInvocationTargetException)
    {
      return false;
    }
    catch (InstantiationException localInstantiationException)
    {
      return false;
    }
    try
    {
      switch (operation)
      {
      case 1: 
      case 2: 
      case 3: 
      case 4: 
        return value1.equals(value2);
      }
    }
    catch (Exception localException)
    {
      return false;
    }
    return false;
  }
  
  private static String approxString(String input)
  {
    boolean changed = false;
    char[] output = input.toCharArray();
    int cursor = 0;
    char[] arrayOfChar1;
    int j = (arrayOfChar1 = output).length;
    for (int i = 0; i < j; i++)
    {
      char c = arrayOfChar1[i];
      if (Character.isWhitespace(c))
      {
        changed = true;
      }
      else
      {
        output[cursor] = c;
        cursor++;
      }
    }
    return changed ? new String(output, 0, cursor) : input;
  }
  
  private static final class Parser
  {
    private final String filterstring;
    private final char[] filterChars;
    private int pos;
    
    Parser(String filterstring)
    {
      this.filterstring = filterstring;
      filterChars = filterstring.toCharArray();
      pos = 0;
    }
    
    FrameworkUtil.FilterImpl parse()
      throws InvalidSyntaxException
    {
      try
      {
        filter = parse_filter();
      }
      catch (ArrayIndexOutOfBoundsException e)
      {
        FrameworkUtil.FilterImpl filter;
        throw new InvalidSyntaxException("Filter ended abruptly", 
          filterstring, e);
      }
      FrameworkUtil.FilterImpl filter;
      if (pos != filterChars.length) {
        throw new InvalidSyntaxException(
          "Extraneous trailing characters: " + 
          filterstring.substring(pos), filterstring);
      }
      return filter;
    }
    
    private FrameworkUtil.FilterImpl parse_filter()
      throws InvalidSyntaxException
    {
      skipWhiteSpace();
      if (filterChars[pos] != '(') {
        throw new InvalidSyntaxException("Missing '(': " + 
          filterstring.substring(pos), filterstring);
      }
      pos += 1;
      
      FrameworkUtil.FilterImpl filter = parse_filtercomp(
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd