Search in sources :

Example 16 with NSArray

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

the class ERXComponentRequestHandler method requestHandlerValuesForRequest.

public static NSDictionary requestHandlerValuesForRequest(WORequest aRequest) {
    NSMutableDictionary aDictionary = new NSMutableDictionary();
    NSArray pathArray = aRequest.requestHandlerPathArray();
    String lastObject = null;
    String penultElement = null;
    String aSessionID = null;
    String aContextID = null;
    String aSenderID = null;
    int p = 0;
    int count = 0;
    int length = 0;
    int pageNameLength = 0;
    boolean _lookForIDsInCookiesFirst = WORequest._lookForIDsInCookiesFirst();
    if (_lookForIDsInCookiesFirst) {
        aSessionID = aRequest.cookieValueForKey(WOApplication.application().sessionIdKey());
    }
    if (pathArray != null) {
        count = pathArray.count();
    }
    if ((pathArray != null) && (count != 0)) {
        lastObject = (String) pathArray.lastObject();
        if (count > 1) {
            penultElement = (String) pathArray.objectAtIndex(count - 2);
        }
        length = lastObject.length();
        while ((p < length) && (Character.isDigit(lastObject.charAt(p)))) {
            p++;
        }
        if ((p < length) && (lastObject.charAt(p) == '.')) {
            aContextID = lastObject.substring(0, p);
            p++;
            aSenderID = lastObject.substring(p);
            if ((penultElement != null) && (penultElement.endsWith(".wo"))) {
                pageNameLength = count - 2;
            } else if (penultElement != null) {
                if ((!_lookForIDsInCookiesFirst) || (aSessionID == null)) {
                    aSessionID = penultElement;
                }
                pageNameLength = count - 2;
            } else {
                pageNameLength = 0;
            }
            if (aContextID != null) {
                aDictionary.setObjectForKey(aContextID, "wocid");
                aDictionary.setObjectForKey(aSenderID, "woeid");
            }
        } else {
            if (lastObject.endsWith(".wo")) {
                pageNameLength = count;
            } else {
                aSessionID = lastObject;
                pageNameLength = count - 1;
            }
        }
        if ((aSessionID == null) && (!_lookForIDsInCookiesFirst)) {
            aSessionID = aRequest.stringFormValueForKey(WOApplication.application().sessionIdKey());
            if (aSessionID == null) {
                aSessionID = aRequest.cookieValueForKey(WOApplication.application().sessionIdKey());
            }
        }
    } else if (WOApplication.application().shouldRestoreSessionOnCleanEntry(aRequest)) {
        aSessionID = aRequest.cookieValueForKey(WOApplication.application().sessionIdKey());
    }
    if ((aSessionID != null) && (aSessionID.length() != 0)) {
        aDictionary.setObjectForKey(aSessionID, WOApplication.application().sessionIdKey());
    }
    return aDictionary;
}
Also used : NSArray(com.webobjects.foundation.NSArray) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 17 with NSArray

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

Example 18 with NSArray

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

the class WOEventSetupPage method _setAllRegisteredEvents.

protected void _setAllRegisteredEvents(boolean tf) {
    NSArray registered;
    int i, n;
    Class c;
    registered = EOEventCenter.registeredEventClasses();
    int count = registered.count();
    for (i = 0, n = count; i < n; i++) {
        c = (Class) registered.objectAtIndex(i);
        EOEventCenter.setRecordsEvents(tf, c);
    }
}
Also used : NSArray(com.webobjects.foundation.NSArray)

Example 19 with NSArray

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

the class WODictionaryRepetition method dictionary.

public NSDictionary dictionary() {
    if (_dictionary == null) {
        _dictionary = (NSDictionary) _WOJExtensionsUtil.valueForBindingOrNull("dictionary", this);
        if (_dictionary == null) {
            _dictionary = NSDictionary.EmptyDictionary;
            _keyList = NSArray.EmptyArray;
        } else {
            _keyList = _dictionary.allKeys();
            _keyList = EOSortOrdering.sortedArrayUsingKeyOrderArray(_keyList, new NSArray<>(new EOSortOrdering("toString", EOSortOrdering.CompareAscending)));
        }
    }
    return _dictionary;
}
Also used : NSArray(com.webobjects.foundation.NSArray) EOSortOrdering(com.webobjects.eocontrol.EOSortOrdering)

Example 20 with NSArray

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

the class ERXWOBrowser method appendChildrenToResponse.

@Override
public void appendChildrenToResponse(WOResponse woresponse, WOContext wocontext) {
    NSArray nsarray = null;
    List vector = null;
    int j = 0;
    Object obj = null;
    NSMutableArray nsmutablearray = null;
    List vector1 = null;
    WOComponent wocomponent = wocontext.component();
    boolean flag1 = true;
    if (_escapeHTML != null) {
        flag1 = _escapeHTML.booleanValueInComponent(wocomponent);
    }
    Object obj1 = _list.valueInComponent(wocomponent);
    if (obj1 != null) {
        if (obj1 instanceof NSArray) {
            nsarray = (NSArray) obj1;
            j = nsarray.count();
        } else if (obj1 instanceof List) {
            vector = (List) obj1;
            j = vector.size();
        } else {
            throw new IllegalArgumentException("<" + getClass().getName() + "> Evaluating 'list' binding returned a " + obj1.getClass().getName() + " when it should return either a com.webobjects.foundation.NSArray, or a java.lang.Vector .");
        }
    }
    obj = selectedValue(wocomponent);
    if (nsarray != null) {
        if (obj != null) {
            if (!(obj instanceof NSArray)) {
                nsmutablearray = new NSMutableArray(obj);
            } else if (!(obj instanceof NSMutableArray)) {
                nsmutablearray = new NSMutableArray((NSArray) obj);
            } else {
                nsmutablearray = (NSMutableArray) obj;
            }
        }
    } else if (obj instanceof List) {
        vector1 = (List) obj;
    }
    for (int i = 0; i < j; i++) {
        String s = null;
        String s1 = null;
        Object obj2 = null;
        if (nsarray != null) {
            obj2 = nsarray.objectAtIndex(i);
        } else {
            obj2 = vector.get(i);
        }
        if (_displayString != null || _value != null) {
            _item.setValue(obj2, wocomponent);
            if (_displayString != null) {
                Object obj3 = _displayString.valueInComponent(wocomponent);
                if (obj3 != null) {
                    s1 = obj3.toString();
                    if (_value != null) {
                        Object obj5 = _value.valueInComponent(wocomponent);
                        if (obj5 != null) {
                            s = obj5.toString();
                        }
                    } else {
                        s = s1;
                    }
                }
            } else {
                Object obj4 = _value.valueInComponent(wocomponent);
                if (obj4 != null) {
                    s = obj4.toString();
                    s1 = s;
                }
            }
        } else {
            s1 = obj2.toString();
            s = s1;
        }
        woresponse._appendContentAsciiString("\n<option");
        if (nsmutablearray != null || vector1 != null) {
            boolean flag2 = false;
            if (_selections != null) {
                flag2 = nsarray == null ? vector1.contains(obj2) : nsmutablearray.containsObject(obj2);
            } else {
                String s3 = null;
                if (_value != null) {
                    s3 = s;
                } else {
                    s3 = WOShared.unsignedIntString(i);
                }
                flag2 = nsarray == null ? vector1.contains(s3) : nsmutablearray.containsObject(s3);
            }
            if (flag2) {
                woresponse.appendContentCharacter(' ');
                woresponse._appendContentAsciiString("selected=\"selected\"");
            }
        }
        if (_value != null) {
            woresponse._appendTagAttributeAndValue("value", s, true);
        } else {
            String s2 = WOShared.unsignedIntString(i);
            woresponse._appendTagAttributeAndValue("value", s2, false);
        }
        woresponse.appendContentCharacter('>');
        if (flag1) {
            woresponse.appendContentHTMLString(s1);
        } else {
            woresponse.appendContentString(s1);
        }
        woresponse._appendContentAsciiString("</option>");
    }
}
Also used : NSArray(com.webobjects.foundation.NSArray) WOComponent(com.webobjects.appserver.WOComponent) NSMutableArray(com.webobjects.foundation.NSMutableArray) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

NSArray (com.webobjects.foundation.NSArray)53 Enumeration (java.util.Enumeration)17 NSMutableArray (com.webobjects.foundation.NSMutableArray)13 NSBundle (com.webobjects.foundation.NSBundle)5 NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)5 File (java.io.File)4 List (java.util.List)4 WOAssociation (com.webobjects.appserver.WOAssociation)3 WOComponent (com.webobjects.appserver.WOComponent)3 NSDictionary (com.webobjects.foundation.NSDictionary)3 IOException (java.io.IOException)3 URL (java.net.URL)3 ArrayList (java.util.ArrayList)3 WOElement (com.webobjects.appserver.WOElement)2 WOResponse (com.webobjects.appserver.WOResponse)2 WOConstantValueAssociation (com.webobjects.appserver._private.WOConstantValueAssociation)2 EOEvent (com.webobjects.eocontrol.EOEvent)2 EOSortOrdering (com.webobjects.eocontrol.EOSortOrdering)2 NSForwardException (com.webobjects.foundation.NSForwardException)2 NSKeyValueCoding (com.webobjects.foundation.NSKeyValueCoding)2