org.eclipse.osgi_3.8.2.v20130124-134944

      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.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
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: 
      return (charval == charval2) || (Character.toUpperCase(charval) == Character.toUpperCase(charval2)) || (Character.toLowerCase(charval) == Character.toLowerCase(charval2));
    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;
  }
  
  private static Object valueOf(Class<?> target, String value2)
  {
    try
    {
      Class[] tmp8_5 = new Class[1]; Class tmp13_10 = FrameworkUtil.class$0;
      if (tmp13_10 == null)
      {
        tmp13_10;
        try
        {
          tmpTernaryOp = (FrameworkUtil.class$0 = Class.forName("java.lang.String"));
        }
        catch (ClassNotFoundException localClassNotFoundException1)
        {
          throw new NoClassDefFoundError(localClassNotFoundException1.getMessage());
        }
      }
      tmp8_5[0] = tmp13_10;method = target.getMethod("valueOf", tmp8_5);
    }
    catch (NoSuchMethodException localNoSuchMethodException1)
    {
      Method method;
      break label103;
    }
    Method method;
    if ((Modifier.isStatic(method.getModifiers())) && (target.isAssignableFrom(method.getReturnType())))
    {
      setAccessible(method);
      try
      {
        return method.invoke(null, new Object[] { value2.trim() });
      }
      catch (IllegalAccessException localIllegalAccessException1)
      {
        return null;
      }
      catch (InvocationTargetException localInvocationTargetException1)
      {
        return null;
      }
    }
    try
    {
      label103:
      tmp108_105 = new Class[1];
      Class tmp113_110 = FrameworkUtil.class$0;
      if (tmp113_110 == null)
      {
        tmp113_110;
        try
        {
          tmpTernaryOp = (FrameworkUtil.class$0 = Class.forName("java.lang.String"));
        }
        catch (ClassNotFoundException localClassNotFoundException2)
        {
          throw new NoClassDefFoundError(localClassNotFoundException2.getMessage());
        }
      }
      tmp108_105[0] = tmp113_110;constructor = target.getConstructor(tmp108_105);
    }
    catch (NoSuchMethodException localNoSuchMethodException2)
    {
      Constructor<?> constructor;
      break label184;
    }
    Constructor<?> constructor;
    setAccessible(constructor);
    try
    {
      return constructor.newInstance(new Object[] { value2.trim() });
    }
    catch (IllegalAccessException localIllegalAccessException2)
    {
      return null;
    }
    catch (InvocationTargetException localInvocationTargetException2)
    {
      return null;
    }
    catch (InstantiationException localInstantiationException)
    {
      return null;
    }
    label184:
    return null;
  }
  
  private static void setAccessible(AccessibleObject accessible)
  {
    if (!accessible.isAccessible()) {
      AccessController.doPrivileged(new FrameworkUtil.SetAccessibleAction(accessible));
    }
  }
  
  private boolean compare_Comparable(int operation, Comparable<Object> value1, Object value2)
  {
    if (operation == 6) {
      return false;
    }
    value2 = valueOf(value1.getClass(), (String)value2);
    if (value2 == null) {
      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;
    }
    value2 = valueOf(value1.getClass(), (String)value2);
    if (value2 == null) {
      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();
      
      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
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

import java.util.AbstractMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

final class FrameworkUtil$ServiceReferenceMap
  extends AbstractMap<String, Object>
  implements Map<String, Object>
{
  private final ServiceReference<?> reference;
  
  FrameworkUtil$ServiceReferenceMap(ServiceReference<?> reference)
  {
    this.reference = reference;
  }
  
  public Object get(Object key)
  {
    if (reference == null) {
      return null;
    }
    return reference.getProperty((String)key);
  }
  
  public Set<Map.Entry<String, Object>> entrySet()
  {
    throw new UnsupportedOperationException();
  }
}

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

import java.lang.reflect.AccessibleObject;
import java.security.PrivilegedAction;

final class FrameworkUtil$SetAccessibleAction
  implements PrivilegedAction<Object>
{
  private final AccessibleObject accessible;
  
  FrameworkUtil$SetAccessibleAction(AccessibleObject accessible)
  {
    this.accessible = accessible;
  }
  
  public Object run()
  {
    accessible.setAccessible(true);
    return null;
  }
}

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

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.security.auth.x500.X500Principal;

public class FrameworkUtil
{
  static Class class$0;
  
  public static Filter createFilter(String filter)
    throws InvalidSyntaxException
  {
    return FilterImpl.newInstance(filter);
  }
  
  public static boolean matchDistinguishedNameChain(String matchPattern, List<String> dnChain)
  {
    return DNChainMatching.match(matchPattern, dnChain);
  }
  
  public static Bundle getBundle(Class<?> classFromBundle)
  {
    Object cl = AccessController.doPrivileged(new PrivilegedAction()
    {
      public Object run()
      {
        return getClassLoader();
      }
    });
    if ((cl instanceof BundleReference)) {
      return ((BundleReference)cl).getBundle();
    }
    return null;
  }
  
  private static final class 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();
    }
    
    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()
    {
  
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 85 86 87

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-2017. Infinite Loop Ltd