Search in sources :

Example 1 with WODeclaration

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

the class WOHelperFunctionParser method processDeclaration.

protected void processDeclaration(WODeclaration declaration) {
    NSMutableDictionary associations = (NSMutableDictionary) declaration.associations();
    Enumeration bindingNameEnum = associations.keyEnumerator();
    while (bindingNameEnum.hasMoreElements()) {
        String bindingName = (String) bindingNameEnum.nextElement();
        WOAssociation association = (WOAssociation) associations.valueForKey(bindingName);
        WOAssociation helperAssociation = parserHelperAssociation(association);
        if (helperAssociation != association) {
            associations.setObjectForKey(helperAssociation, bindingName);
        }
    }
    // This will replace constant associations with ognl associations
    // when needed.
    WOOgnl.factory().convertOgnlConstantAssociations(associations);
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation) Enumeration(java.util.Enumeration) WOHTMLCommentString(com.webobjects.appserver._private.WOHTMLCommentString) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 2 with WODeclaration

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

the class WOHelperFunctionParser method prettyDeclaration.

protected String prettyDeclaration(WODeclaration declaration) {
    StringBuilder declarationStr = new StringBuilder();
    if (declaration == null) {
        declarationStr.append("[none]");
    } else {
        declarationStr.append("Component Type = " + declaration.type());
        declarationStr.append(", Bindings = { ");
        Enumeration keyEnum = declaration.associations().keyEnumerator();
        while (keyEnum.hasMoreElements()) {
            String key = (String) keyEnum.nextElement();
            Object assoc = declaration.associations().objectForKey(key);
            if (assoc instanceof WOKeyValueAssociation) {
                declarationStr.append(key + "=" + ((WOKeyValueAssociation) assoc).keyPath());
            } else if (assoc instanceof WOConstantValueAssociation) {
                declarationStr.append(key + "='" + ((WOConstantValueAssociation) assoc).valueInComponent(null) + "'");
            } else {
                declarationStr.append(key + "=" + assoc);
            }
            if (keyEnum.hasMoreElements()) {
                declarationStr.append(", ");
            }
        }
        declarationStr.append(" }");
    }
    return declarationStr.toString();
}
Also used : Enumeration(java.util.Enumeration) WOConstantValueAssociation(com.webobjects.appserver._private.WOConstantValueAssociation) WOKeyValueAssociation(com.webobjects.appserver._private.WOKeyValueAssociation) WOHTMLCommentString(com.webobjects.appserver._private.WOHTMLCommentString)

Example 3 with WODeclaration

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

the class WOHTMLWebObjectTag method _componentReferenceWithClassNameDeclarationAndTemplate.

private static WOElement _componentReferenceWithClassNameDeclarationAndTemplate(String s, WODeclaration wodeclaration, WOElement woelement, NSArray nsarray) throws ClassNotFoundException {
    WOComponentReference wocomponentreference = null;
    WOComponentDefinition wocomponentdefinition = WOApplication.application()._componentDefinition(s, nsarray);
    if (wocomponentdefinition != null) {
        NSDictionary nsdictionary = wodeclaration.associations();
        wocomponentreference = wocomponentdefinition.componentReferenceWithAssociations(nsdictionary, woelement);
    } else {
        throw new ClassNotFoundException("Cannot find class or component named \'" + s + "\" in runtime or in a loadable bundle");
    }
    return wocomponentreference;
}
Also used : WOComponentDefinition(com.webobjects.appserver._private.WOComponentDefinition) NSDictionary(com.webobjects.foundation.NSDictionary) WOComponentReference(com.webobjects.appserver._private.WOComponentReference)

Example 4 with WODeclaration

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

the class WOHelperFunctionParser method didParseOpeningWebObjectTag.

public void didParseOpeningWebObjectTag(String s, WOHelperFunctionHTMLParser htmlParser) throws WOHelperFunctionHTMLFormatException {
    if (WOHelperFunctionTagRegistry.allowInlineBindings()) {
        int spaceIndex = s.indexOf(' ');
        int colonIndex;
        if (spaceIndex != -1) {
            colonIndex = s.substring(0, spaceIndex).indexOf(':');
        } else {
            colonIndex = s.indexOf(':');
        }
        if (colonIndex != -1) {
            WODeclaration declaration = parseInlineBindings(s, colonIndex);
            s = "<wo name = \"" + declaration.name() + "\"";
        }
    }
    _currentWebObjectTag = new WOHTMLWebObjectTag(s, _currentWebObjectTag);
    log.debug("Inserted WebObject with Name '{}'.", _currentWebObjectTag.name());
}
Also used : WODeclaration(com.webobjects.appserver._private.WODeclaration)

Example 5 with WODeclaration

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

the class WOHelperFunctionDeclarationParser method parseDeclarationsWithoutComments.

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;
}
Also used : Enumeration(java.util.Enumeration) WODeclaration(com.webobjects.appserver._private.WODeclaration) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Aggregations

WODeclaration (com.webobjects.appserver._private.WODeclaration)12 Enumeration (java.util.Enumeration)10 WOHTMLCommentString (com.webobjects.appserver._private.WOHTMLCommentString)8 WOElement (com.webobjects.appserver.WOElement)6 NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)6 WOAssociation (com.webobjects.appserver.WOAssociation)4 WOConstantValueAssociation (com.webobjects.appserver._private.WOConstantValueAssociation)4 WOHTMLBareString (com.webobjects.appserver._private.WOHTMLBareString)4 WOComponentDefinition (com.webobjects.appserver._private.WOComponentDefinition)2 WOComponentReference (com.webobjects.appserver._private.WOComponentReference)2 WOKeyValueAssociation (com.webobjects.appserver._private.WOKeyValueAssociation)2 NSDictionary (com.webobjects.foundation.NSDictionary)2