Examples of NSMutableDictionary


Examples of com.webobjects.foundation.NSMutableDictionary

   */
  @Override
  protected void addRequiredWebResources(WOResponse res) {
    addScriptResourceInHead(res, "jsonrpc.js");

    NSMutableDictionary userInfo = ERXWOContext.contextDictionary();
    String name = (String) valueForBinding("name");
    String key = "JSONRPC_" + name;
    Object oldValue = userInfo.objectForKey(key);
    Object bridge = valueForBinding("JSONRPCBridge");
    if (bridge == null) {
      bridge = NSKeyValueCoding.NullValue;
    }
    if (oldValue == null) {
      // add the javascript variable 'name' only if not already in the
      // response
      userInfo.setObjectForKey(bridge, key);
      String jsonRpcJavascript;
      if (booleanValueForBinding("lazy", false)) {
          String varName = "_" + name;
          jsonRpcJavascript = "function " + name + "(callback) { if (typeof " + varName + " == 'undefined') { " + varName + "=new JSONRpcClient(callback, '" + AjaxUtils.ajaxComponentActionUrl(context()) + "'); } else { callback(); } }";
      }
View Full Code Here

Examples of com.webobjects.foundation.NSMutableDictionary

    _quotedStrings = new NSMutableDictionary();
  }

  public static NSMutableDictionary declarationsWithString(String declarationStr) throws WOHelperFunctionDeclarationFormatException {
    WOHelperFunctionDeclarationParser declarationParser = new WOHelperFunctionDeclarationParser();
    NSMutableDictionary declarations = declarationParser.parseDeclarations(declarationStr);
    return declarations;
  }
View Full Code Here

Examples of com.webobjects.foundation.NSMutableDictionary

  }

  public NSMutableDictionary parseDeclarations(String declarationStr) throws WOHelperFunctionDeclarationFormatException {
    String strWithoutComments = _removeOldStyleCommentsFromString(declarationStr);
    strWithoutComments = _removeNewStyleCommentsAndQuotedStringsFromString(strWithoutComments);
    NSMutableDictionary declarations = parseDeclarationsWithoutComments(strWithoutComments);
    return declarations;
  }
View Full Code Here

Examples of com.webobjects.foundation.NSMutableDictionary

    }
    return declarationWithoutCommentsBuffer.toString();
  }

  private NSMutableDictionary parseDeclarationsWithoutComments(String declarationWithoutComment) throws WOHelperFunctionDeclarationFormatException {
    NSMutableDictionary declarations = new NSMutableDictionary();
    NSMutableDictionary rawDeclarations = _rawDeclarationsWithoutComment(declarationWithoutComment);
    String tagName;
    WODeclaration declaration;
    Enumeration rawDeclarationHeaderEnum = rawDeclarations.keyEnumerator();
    while (rawDeclarationHeaderEnum.hasMoreElements()) {
      String declarationHeader = (String) rawDeclarationHeaderEnum.nextElement();
      String declarationBody = (String) rawDeclarations.objectForKey(declarationHeader);
      int colonIndex = declarationHeader.indexOf(':');
      if (colonIndex < 0) {
        throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Missing ':' for declaration:\n" + declarationHeader + " " + declarationBody);
      }
      tagName = declarationHeader.substring(0, colonIndex).trim();
      if (tagName.length() == 0) {
        throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Missing tag name for declaration:\n" + declarationHeader + " " + declarationBody);
      }
      if (declarations.objectForKey(tagName) != null) {
        throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Duplicate tag name '" + tagName + "' in declaration:\n" + declarationBody);
      }
      String type = declarationHeader.substring(colonIndex + 1).trim();
      if (type.length() == 0) {
        throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Missing element name for declaration:\n" + declarationHeader + " " + declarationBody);
      }
      NSMutableDictionary associations = _associationsForDictionaryString(declarationHeader, declarationBody);
      declaration = WOHelperFunctionParser.createDeclaration(tagName, type, associations);
      declarations.setObjectForKey(declaration, tagName);
    }

    return declarations;
View Full Code Here

Examples of com.webobjects.foundation.NSMutableDictionary

    return declarations;
  }

  private NSMutableDictionary _associationsForDictionaryString(String declarationHeader, String declarationBody) throws WOHelperFunctionDeclarationFormatException {
    NSMutableDictionary associations = new NSMutableDictionary();
    String trimmedDeclarationBody = declarationBody.trim();
    if (!trimmedDeclarationBody.startsWith("{") && !trimmedDeclarationBody.endsWith("}")) {
      throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Internal inconsistency : invalid dictionary for declaration:\n" + declarationHeader + " " + declarationBody);
    }
    int declarationBodyLength = trimmedDeclarationBody.length();
    if (declarationBodyLength <= 2) {
      return associations;
    }
    trimmedDeclarationBody = trimmedDeclarationBody.substring(1, declarationBodyLength - 1).trim();
    NSArray bindings = NSArray.componentsSeparatedByString(trimmedDeclarationBody, ";");
    Enumeration bindingsEnum = bindings.objectEnumerator();
    do {
      if (!bindingsEnum.hasMoreElements()) {
        break;
      }
      String binding = ((String) bindingsEnum.nextElement()).trim();
      if (binding.length() != 0) {
        int equalsIndex = binding.indexOf('=');
        if (equalsIndex < 0) {
          throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Invalid line. No equal in line:\n" + binding + "\nfor declaration:\n" + declarationHeader + " " + declarationBody);
        }
        String key = binding.substring(0, equalsIndex).trim();
        if (key.length() == 0) {
          throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Missing binding in line:\n" + binding + "\nfor declaration:\n" + declarationHeader + " " + declarationBody);
        }
        String value = binding.substring(equalsIndex + 1).trim();
        if (value.length() == 0) {
          throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Missing value in line:\n" + binding + "\nfor declaration:\n" + declarationHeader + " " + declarationBody);
        }
        WOAssociation association = WOHelperFunctionDeclarationParser._associationWithKey(value, _quotedStrings);
        Object quotedString = _quotedStrings.objectForKey(key);
        if (quotedString != null) {
          associations.setObjectForKey(association, quotedString);
        }
        else {
          associations.setObjectForKey(association, key);
        }
      }
    }
    while (true);
    // if (log.isDebugEnabled()) {
View Full Code Here

Examples of com.webobjects.foundation.NSMutableDictionary

    }
    return association;
  }

  private NSMutableDictionary _rawDeclarationsWithoutComment(String declarationStr) {
    NSMutableDictionary declarations = new NSMutableDictionary();
    StringBuilder declarationWithoutCommentBuffer = new StringBuilder(100);
    StringTokenizer tokenizer = new StringTokenizer(declarationStr, "{", true);
    try {
      while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken("{");
        if (token.equals("{")) {
          token = tokenizer.nextToken("}");
          if (token.equals("}")) {
            token = "";
          }
          else {
            tokenizer.nextToken();
          }
          String declarationWithoutComment = declarationWithoutCommentBuffer.toString();
          if (declarationWithoutComment.startsWith(";")) {
            declarationWithoutComment = declarationWithoutComment.substring(1);
          }
          declarations.setObjectForKey("{" + token + "}", declarationWithoutComment.trim());
          declarationWithoutCommentBuffer.setLength(0);
        }
        else {
          declarationWithoutCommentBuffer.append(token);
        }
View Full Code Here

Examples of com.webobjects.foundation.NSMutableDictionary

      return urlForCurrentFile() != null;
    }

    public void editFramework() {
      data = new NSMutableArray<NSMutableDictionary<String, Object>>();
      NSMutableDictionary dataDictionary = new NSMutableDictionary();
         selectedFilename = currentFilename;
         selectedFramework = currentFramework;
      NSMutableSet<String> allKeys = new NSMutableSet<String>();
      for (String language : availableLanguages()) {
      NSArray<String> languageArray = new NSArray<String>(language);
      URL url = ERXFileUtilities.pathURLForResourceNamed(currentFilename, currentFramework, languageArray);
      if (url != null) {
        NSDictionary<String, Object> dict = (NSDictionary<String, Object>)ERXFileUtilities.readPropertyListFromFileInFramework(currentFilename, currentFramework, languageArray);
        allKeys.addObjectsFromArray(dict.allKeys());
        for (String key : dict.allKeys()) {
          NSMutableDictionary<String, Object> entry = (NSMutableDictionary<String, Object>) dataDictionary.objectForKey(key);
          if(entry == null) {
            entry = new NSMutableDictionary<String, Object>();
            entry.setObjectForKey(key, "key");
            dataDictionary.setObjectForKey(entry, key);
            data.addObject(entry);
          }
          entry.setObjectForKey(dict.objectForKey(key), language);
        }
      }
    }
      for (String key : allKeys) {
      NSMutableDictionary<String, Object> entry = (NSMutableDictionary<String, Object>) dataDictionary.objectForKey(key);
      for (String language : availableLanguages()) {
        if (entry.objectForKey(language) == null) {
          entry.setObjectForKey(UNSET, language);
        }
      }
View Full Code Here

Examples of com.webobjects.foundation.NSMutableDictionary

    public void saveFramework() throws IOException {
      for (String language : availableLanguages()) {
      NSArray<String> languageArray = new NSArray<String>(language);
      URL url = ERXFileUtilities.pathURLForResourceNamed(selectedFilename, selectedFramework, languageArray);
      NSMutableDictionary dict = new NSMutableDictionary();
         for (Enumeration entries = data.objectEnumerator(); entries.hasMoreElements();) {
           NSDictionary entry = (NSDictionary) entries.nextElement();
           String key = (String) entry.objectForKey("key");
        Object value = entry.objectForKey(language);
        if (value != null && !value.equals(UNSET)) {
          dict.setObjectForKey(value, key);
        }
      }
         String result = ERXStringUtilities.stringFromDictionary(dict);
         NSDictionary newDict = (NSDictionary) NSPropertyListSerialization.propertyListFromString(result);
         if (!newDict.equals(dict)) {
View Full Code Here

Examples of com.webobjects.foundation.NSMutableDictionary

     *
     * @return current page
     */
    public WOComponent addEntry() {
      if (keyToAdd != null && data != null && displayGroup != null) {
        NSMutableDictionary entry = new NSMutableDictionary();
       
        entry.setObjectForKey(keyToAdd, "key");
       
        for (String language : availableLanguages()) {
          entry.setObjectForKey(UNSET, language);
        }
       
        data.addObject(entry);
        displayGroup.setObjectArray(data);
        displayGroup.qualifyDataSource();
View Full Code Here

Examples of com.webobjects.foundation.NSMutableDictionary

    public NSMutableDictionary errorMessages() {
        if(errorMessages == null) {
            errorMessages = (NSMutableDictionary)valueForBinding("errorMessages");
            if(errorMessages == null) {
                errorMessages = new NSMutableDictionary();
            }
        }
        return errorMessages;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.