org.eclipse.osgi_3.8.2.v20130124-134944

    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;
        }
      }
    }
  }
  
  private static final class CaseInsensitiveMap
    extends AbstractMap<String, Object>
    implements Map<String, Object>
  {
    private final Dictionary<String, ?> dictionary;
    private final String[] keys;
    
    CaseInsensitiveMap(Dictionary<String, ?> dictionary)
    {
      if (dictionary == null)
      {
        this.dictionary = null;
        keys = new String[0];
        return;
      }
      this.dictionary = dictionary;
      List<String> keyList = new ArrayList(dictionary.size());
      for (Enumeration<?> e = dictionary.keys(); e.hasMoreElements();)
      {
        Object k = e.nextElement();
        if ((k instanceof String))
        {
          String key = (String)k;
          for (Iterator localIterator = keyList.iterator(); localIterator.hasNext();)
          {
            String i = (String)localIterator.next();
            if (key.equalsIgnoreCase(i)) {
              throw new IllegalArgumentException();
            }
          }
          keyList.add(key);
        }
      }
      keys = ((String[])keyList.toArray(new String[keyList.size()]));
    }
    
    public Object get(Object o)
    {
      String k = (String)o;
      String[] arrayOfString;
      int j = (arrayOfString = keys).length;
      for (int i = 0; i < j; i++)
      {
        String key = arrayOfString[i];
        if (key.equalsIgnoreCase(k)) {
          return dictionary.get(key);
        }
      }
      return null;
    }
    
    public Set<Map.Entry<String, Object>> entrySet()
    {
      throw new UnsupportedOperationException();
    }
  }
  
  private static final class ServiceReferenceMap
    extends AbstractMap<String, Object>
    implements Map<String, Object>
  {
    private final ServiceReference<?> reference;
    
    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();
    }
  }
  
  private static final class SetAccessibleAction
    implements PrivilegedAction<Object>
  {
    private final AccessibleObject accessible;
    
    SetAccessibleAction(AccessibleObject accessible)
    {
      this.accessible = accessible;
    }
    
    public Object run()
    {
      accessible.setAccessible(true);
      return null;
    }
  }
  
  private static final class DNChainMatching
  {
    private static final String MINUS_WILDCARD = "-";
    private static final String STAR_WILDCARD = "*";
    
    private static boolean rdnmatch(List<?> rdn, List<?> rdnPattern)
    {
      if (rdn.size() != rdnPattern.size()) {
        return false;
      }
      for (int i = 0; i < rdn.size(); i++)
      {
        String rdnNameValue = (String)rdn.get(i);
        String patNameValue = (String)rdnPattern.get(i);
        int rdnNameEnd = rdnNameValue.indexOf('=');
        int patNameEnd = patNameValue.indexOf('=');
        if ((rdnNameEnd != patNameEnd) || (!rdnNameValue.regionMatches(0, patNameValue, 0, rdnNameEnd))) {
          return false;
        }
        String patValue = patNameValue.substring(patNameEnd);
        String rdnValue = rdnNameValue.substring(rdnNameEnd);
        if ((!rdnValue.equals(patValue)) && (!patValue.equals("=*")) && (!patValue.equals("=#16012a"))) {
          return false;
        }
      }
      return true;
    }
    
    private static boolean dnmatch(List<?> dn, List<?> dnPattern)
    {
      int dnStart = 0;
      int patStart = 0;
      int patLen = dnPattern.size();
      if (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("*")) {
          return (dnChainMatch(dnChain, dnChainIndex, dnChainPattern, dnChainPatternIndex)) || (dnChainMatch(dnChain, dnChainIndex + 1, dnChainPattern, dnChainPatternIndex));
        }
        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()) && (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
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

public class InvalidSyntaxException
  extends Exception
{
  static final long serialVersionUID = -4295194420816491875L;
  private final String filter;
  
  public InvalidSyntaxException(String msg, String filter)
  {
    super(message(msg, filter));
    this.filter = filter;
  }
  
  public InvalidSyntaxException(String msg, String filter, Throwable cause)
  {
    super(message(msg, filter), cause);
    this.filter = filter;
  }
  
  private static String message(String msg, String filter)
  {
    if ((msg == null) || (filter == null) || (msg.indexOf(filter) >= 0)) {
      return msg;
    }
    return msg + ": " + filter;
  }
  
  public String getFilter()
  {
    return filter;
  }
  
  public Throwable getCause()
  {
    return super.getCause();
  }
  
  public Throwable initCause(Throwable cause)
  {
    return super.initCause(cause);
  }
}

/* Loc
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-2019. Infinite Loop Ltd