Search in sources :

Example 51 with NSMutableDictionary

use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.

the class WOHelperFunctionDeclarationParser method declarationsWithString.

public static NSMutableDictionary declarationsWithString(String declarationStr) throws WOHelperFunctionDeclarationFormatException {
    WOHelperFunctionDeclarationParser declarationParser = new WOHelperFunctionDeclarationParser();
    NSMutableDictionary declarations = declarationParser.parseDeclarations(declarationStr);
    return declarations;
}
Also used : NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 52 with NSMutableDictionary

use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.

the class WOHelperFunctionDeclarationParser method parseDeclarations.

public NSMutableDictionary parseDeclarations(String declarationStr) throws WOHelperFunctionDeclarationFormatException {
    String strWithoutComments = _removeOldStyleCommentsFromString(declarationStr);
    strWithoutComments = _removeNewStyleCommentsAndQuotedStringsFromString(strWithoutComments);
    NSMutableDictionary declarations = parseDeclarationsWithoutComments(strWithoutComments);
    return declarations;
}
Also used : NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 53 with NSMutableDictionary

use of com.webobjects.foundation.NSMutableDictionary 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)

Example 54 with NSMutableDictionary

use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.

the class ERXMessageEncoding method setDefaultEncodingForAllLanguages.

public static void setDefaultEncodingForAllLanguages(String newDefaultEncoding) {
    // This statement may throw an IllegalArgumentException when
    // newDefaultEncoding isn't supported.
    setDefaultEncoding(newDefaultEncoding);
    final NSMutableDictionary d = new NSMutableDictionary(_languagesAndDefaultEncodings());
    final Enumeration e = d.keyEnumerator();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        d.setObjectForKey(newDefaultEncoding, key);
    }
    _setLanguagesAndDefaultEncodings(d);
}
Also used : Enumeration(java.util.Enumeration) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 55 with NSMutableDictionary

use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.

the class WOHelperFunctionParser method parseInlineBindings.

protected WODeclaration parseInlineBindings(String tag, int colonIndex) throws WOHelperFunctionHTMLFormatException {
    StringBuffer keyBuffer = new StringBuffer();
    StringBuffer valueBuffer = new StringBuffer();
    StringBuffer elementTypeBuffer = new StringBuffer();
    NSMutableDictionary associations = new NSMutableDictionary();
    StringBuffer currentBuffer = elementTypeBuffer;
    boolean changeBuffers = false;
    boolean inQuote = false;
    int length = tag.length();
    for (int index = colonIndex + 1; index < length; index++) {
        char ch = tag.charAt(index);
        if (!inQuote && (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')) {
            changeBuffers = true;
        } else if (!inQuote && ch == '=') {
            changeBuffers = true;
        } else if (inQuote && ch == '\\') {
            index++;
            if (index == length) {
                throw new WOHelperFunctionHTMLFormatException("'" + tag + "' has a '\\' as the last character.");
            }
            if (tag.charAt(index) == '\"') {
                currentBuffer.append("\"");
            } else if (tag.charAt(index) == 'n') {
                currentBuffer.append('\n');
            } else if (tag.charAt(index) == 'r') {
                currentBuffer.append('\r');
            } else if (tag.charAt(index) == 't') {
                currentBuffer.append('\t');
            } else {
                currentBuffer.append('\\');
                currentBuffer.append(tag.charAt(index));
            }
        } else {
            if (changeBuffers) {
                if (currentBuffer == elementTypeBuffer) {
                    currentBuffer = keyBuffer;
                } else if (currentBuffer == keyBuffer) {
                    currentBuffer = valueBuffer;
                } else if (currentBuffer == valueBuffer) {
                    parseInlineAssociation(keyBuffer, valueBuffer, associations);
                    currentBuffer = keyBuffer;
                }
                currentBuffer.setLength(0);
                changeBuffers = false;
            }
            if (ch == '"') {
                inQuote = !inQuote;
            }
            currentBuffer.append(ch);
        }
    }
    if (inQuote) {
        throw new WOHelperFunctionHTMLFormatException("'" + tag + "' has a quote left open.");
    }
    if (keyBuffer.length() > 0) {
        if (valueBuffer.length() > 0) {
            parseInlineAssociation(keyBuffer, valueBuffer, associations);
        } else {
            throw new WOHelperFunctionHTMLFormatException("'" + tag + "' defines a key but no value.");
        }
    }
    String elementType = elementTypeBuffer.toString();
    String shortcutType = (String) WOHelperFunctionTagRegistry.tagShortcutMap().objectForKey(elementType);
    if (shortcutType != null) {
        elementType = shortcutType;
    } else if (elementType.startsWith(WO_REPLACEMENT_MARKER)) {
        // Acts only on tags, where we have "dynamified" inside the tag parser
        // this takes the value found after the "wo:" part in the element and generates a WOGenericContainer with that value
        // as the elementName binding
        elementType = elementType.replaceAll(WO_REPLACEMENT_MARKER, "");
        associations.setObjectForKey(WOHelperFunctionAssociation.associationWithValue(elementType), "elementName");
        elementType = "WOGenericContainer";
    }
    String elementName;
    synchronized (this) {
        elementName = "_" + elementType + "_" + _inlineBindingCount;
        _inlineBindingCount++;
    }
    WOTagProcessor tagProcessor = (WOTagProcessor) WOHelperFunctionTagRegistry.tagProcessorMap().objectForKey(elementType);
    WODeclaration declaration;
    if (tagProcessor == null) {
        declaration = WOHelperFunctionParser.createDeclaration(elementName, elementType, associations);
    } else {
        declaration = tagProcessor.createDeclaration(elementName, elementType, associations);
    }
    _declarations.setObjectForKey(declaration, elementName);
    processDeclaration(declaration);
    return declaration;
}
Also used : WODeclaration(com.webobjects.appserver._private.WODeclaration) WOHTMLCommentString(com.webobjects.appserver._private.WOHTMLCommentString) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Aggregations

NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)59 Enumeration (java.util.Enumeration)12 WOAssociation (com.webobjects.appserver.WOAssociation)10 WOComponent (com.webobjects.appserver.WOComponent)8 NSDictionary (com.webobjects.foundation.NSDictionary)7 NSMutableArray (com.webobjects.foundation.NSMutableArray)6 WOConstantValueAssociation (com.webobjects.appserver._private.WOConstantValueAssociation)5 NSArray (com.webobjects.foundation.NSArray)5 WODeclaration (com.webobjects.appserver._private.WODeclaration)4 WOHTMLCommentString (com.webobjects.appserver._private.WOHTMLCommentString)4 NoSuchElementException (java.util.NoSuchElementException)4 StringTokenizer (java.util.StringTokenizer)4 NSForwardException (com.webobjects.foundation.NSForwardException)2 ERXMutableURL (er.extensions.foundation.ERXMutableURL)2 MalformedURLException (java.net.MalformedURLException)2 JSONObject (org.json.JSONObject)2 WOActionResults (com.webobjects.appserver.WOActionResults)1 WOContext (com.webobjects.appserver.WOContext)1 WODynamicElementCreationException (com.webobjects.appserver._private.WODynamicElementCreationException)1 NSBundle (com.webobjects.foundation.NSBundle)1