Search in sources :

Example 26 with WOAssociation

use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.

the class WOHelperFunctionParser method createDeclaration.

public static WODeclaration createDeclaration(String declarationName, String declarationType, NSMutableDictionary associations) {
    WODeclaration declaration = new WODeclaration(declarationName, declarationType, associations);
    if (WOHelperFunctionParser._debugSupport && associations != null && associations.objectForKey(WOHTMLAttribute.Debug) == null) {
        // associations.setObjectForKey(new WOConstantValueAssociation(Boolean.TRUE), WOHTMLAttribute.Debug);
        Enumeration associationsEnum = associations.keyEnumerator();
        while (associationsEnum.hasMoreElements()) {
            String bindingName = (String) associationsEnum.nextElement();
            WOAssociation association = (WOAssociation) associations.objectForKey(bindingName);
            association.setDebugEnabledForBinding(bindingName, declarationName, declarationType);
            association._setDebuggingEnabled(false);
        }
    }
    return declaration;
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation) Enumeration(java.util.Enumeration) WODeclaration(com.webobjects.appserver._private.WODeclaration) WOHTMLCommentString(com.webobjects.appserver._private.WOHTMLCommentString)

Example 27 with WOAssociation

use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.

the class WOHelperFunctionDeclarationParser method _associationsForDictionaryString.

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);
    // }
    return associations;
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation) Enumeration(java.util.Enumeration) NSArray(com.webobjects.foundation.NSArray) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Aggregations

WOAssociation (com.webobjects.appserver.WOAssociation)27 NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)10 Enumeration (java.util.Enumeration)10 WOHTMLCommentString (com.webobjects.appserver._private.WOHTMLCommentString)8 WOComponent (com.webobjects.appserver.WOComponent)4 WOConstantValueAssociation (com.webobjects.appserver._private.WOConstantValueAssociation)4 NSDictionary (com.webobjects.foundation.NSDictionary)4 WOKeyValueAssociation (com.webobjects.appserver._private.WOKeyValueAssociation)3 NSArray (com.webobjects.foundation.NSArray)3 WODeclaration (com.webobjects.appserver._private.WODeclaration)2 WOResponse (com.webobjects.appserver.WOResponse)1 WOBindingNameAssociation (com.webobjects.appserver._private.WOBindingNameAssociation)1 ERXMutableURL (er.extensions.foundation.ERXMutableURL)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1