protected static NSDictionary expansionLookup() {
    if (RuleModelUtilities.expansionLookup == null) {
      NSDictionary lookupDictionary = RuleModelUtilities.compressionLookup();
      Enumeration keys = lookupDictionary.keyEnumerator();
      NSMutableDictionary lookup = new NSMutableDictionary(lookupDictionary.count());

      while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = lookupDictionary.objectForKey(key);

        lookup.setObjectForKey(key, value);
      }

      // Direct To Web rule editor compatibility
      lookup.setObjectForKey(
          BooleanAssignment.class.getName(), "com.webobjects.directtoweb.BooleanAssignment");
      lookup.setObjectForKey(Rule.class.getName(), "com.webobjects.directtoweb.Rule");
      lookup.setObjectForKey(
          SimpleAssignment.class.getName(), "com.webobjects.directtoweb.Assignment");
      lookup.setObjectForKey(
          KeyValueAssignment.class.getName(), "com.webobjects.directtoweb.KeyValueAssignment");

      RuleModelUtilities.expansionLookup = lookup;
    }

    return RuleModelUtilities.expansionLookup;
  }
Пример #2
0
 @Override
 public EOQualifier qualifierWithBindings(NSDictionary arg0, boolean arg1) {
   if (arg0 != null && arg0.count() > 0) {
     throw new IllegalStateException(getClass().getName() + " doesn't support bindings");
   }
   return this;
 }
Пример #3
0
  /**
   * @param d dictionary to sort keys from
   * @return keys from d sorted by ascending value they are mapped to
   */
  public static <T> NSArray<T> keysSortedByValueAscending(final NSDictionary<T, ?> d) {
    NSArray<T> result = null;

    if (d != null && d.count() > 0) {
      final NSArray<T> keys = d.allKeys();
      result =
          ERXArrayUtilities.sortedArrayUsingComparator(keys, new NSDictionaryKeyValueComparator(d));
    }

    return result != null ? result : NSArray.EmptyArray;
  }
Пример #4
0
  // if you're keys are not all strings, this method will throw.
  public static NSArray<String> stringKeysSortedAscending(final NSDictionary<String, ?> d) {
    NSArray<String> result = null;

    if (d != null && d.count() > 0) {
      final NSArray<String> keys = d.allKeys();
      result =
          ERXArrayUtilities.sortedArrayUsingComparator(
              keys, NSComparator.AscendingStringComparator);
    }

    return result != null ? result : NSArray.EmptyArray;
  }
  protected static NSDictionary transformDictionary(NSDictionary dictionary, NSDictionary lookup) {
    NSMutableDictionary transformedDictionary = new NSMutableDictionary(dictionary.count());
    Enumeration keys = dictionary.keyEnumerator();

    while (keys.hasMoreElements()) {
      Object key = keys.nextElement();
      Object value = dictionary.objectForKey(key);

      transformedDictionary.setObjectForKey(RuleModelUtilities.transform(value, lookup), key);
    }

    return transformedDictionary;
  }