Search in sources :

Example 11 with NSMutableArray

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

the class WOHostUtilities method initLocalHosts.

@SuppressWarnings("unchecked")
static NSArray initLocalHosts() {
    NSMutableArray localNSMutableArray = new NSMutableArray();
    try {
        InetAddress localInetAddress1 = InetAddress.getLocalHost();
        _addInetAddress(localInetAddress1, localNSMutableArray);
    } catch (Exception localException1) {
        NSLog.err.appendln("<WOHostUtilities>: Couldn't invoke getLocalHost(): " + localException1);
    }
    try {
        InetAddress[] arrayOfInetAddress1 = InetAddress.getAllByName("localhost");
        _addInetAddressArray(arrayOfInetAddress1, localNSMutableArray);
    } catch (Exception localException2) {
        NSLog.err.appendln("<WOHostUtilities>: Couldn't get InetAddress for 'localhost': " + localException2);
    }
    try {
        InetAddress[] arrayOfInetAddress2 = InetAddress.getAllByName("127.0.0.1");
        _addInetAddressArray(arrayOfInetAddress2, localNSMutableArray);
    } catch (Exception localException3) {
        NSLog.err.appendln("<WOHostUtilities>: Couldn't get InetAddress for '127.0.0.1': " + localException3);
    }
    NSArray<String> ips = ERXProperties.arrayForKey(LOCALHOST_IPS_PROPERTY_KEY);
    if (ips != null) {
        for (String ip : ips) {
            try {
                InetAddress address = InetAddress.getByName(ip);
                _addInetAddress(address, localNSMutableArray);
                log.debug("Added the address {} as a local host.", address);
            } catch (Exception e) {
                log.error("Could not add localhost IP {}", ip);
            }
        }
    }
    int i = localNSMutableArray.count();
    for (int j = 0; j < i; ++j) {
        InetAddress localInetAddress2 = (InetAddress) localNSMutableArray.objectAtIndex(j);
        try {
            InetAddress[] arrayOfInetAddress3 = InetAddress.getAllByName(localInetAddress2.getHostName());
            _addInetAddressArray(arrayOfInetAddress3, localNSMutableArray);
        } catch (Exception localException4) {
            NSLog.err.appendln("<WOHostUtilities>: Couldn't get InetAddresses for '" + localInetAddress2.getHostName() + "': " + localException4);
        }
    }
    if (NSLog.debugLoggingAllowedForLevelAndGroups(3, 4L))
        NSLog.out.appendln("<WOHostUtilities>: Initialized Local Host List: " + localNSMutableArray);
    return localNSMutableArray;
}
Also used : NSMutableArray(com.webobjects.foundation.NSMutableArray) InetAddress(java.net.InetAddress)

Example 12 with NSMutableArray

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

the class WOHTMLWebObjectTag method template.

public WOElement template() {
    NSMutableArray nsmutablearray = null;
    if (_children == null) {
        return null;
    }
    Enumeration enumeration = _children.objectEnumerator();
    if (enumeration != null) {
        nsmutablearray = new NSMutableArray(_children.count());
        StringBuilder stringbuffer = new StringBuilder(128);
        while (enumeration.hasMoreElements()) {
            Object obj1 = enumeration.nextElement();
            if (obj1 instanceof String) {
                stringbuffer.append((String) obj1);
            } else {
                if (stringbuffer.length() > 0) {
                    WOHTMLBareString wohtmlbarestring1 = new WOHTMLBareString(stringbuffer.toString());
                    nsmutablearray.addObject(wohtmlbarestring1);
                    stringbuffer.setLength(0);
                }
                nsmutablearray.addObject(obj1);
            }
        }
        if (stringbuffer.length() > 0) {
            WOHTMLBareString wohtmlbarestring = new WOHTMLBareString(stringbuffer.toString());
            stringbuffer.setLength(0);
            nsmutablearray.addObject(wohtmlbarestring);
        }
    }
    WOElement obj = null;
    if (nsmutablearray != null && nsmutablearray.count() == 1) {
        Object obj2 = nsmutablearray.objectAtIndex(0);
        if (obj2 instanceof WOComponentReference) {
            obj = new WODynamicGroup(_name, null, (WOElement) obj2);
        } else {
            obj = (WOElement) obj2;
        }
    } else {
        obj = new WODynamicGroup(_name, null, nsmutablearray);
    }
    return obj;
}
Also used : Enumeration(java.util.Enumeration) NSMutableArray(com.webobjects.foundation.NSMutableArray) WODynamicGroup(com.webobjects.appserver._private.WODynamicGroup) WOHTMLBareString(com.webobjects.appserver._private.WOHTMLBareString) WOHTMLBareString(com.webobjects.appserver._private.WOHTMLBareString) WOComponentReference(com.webobjects.appserver._private.WOComponentReference) WOElement(com.webobjects.appserver.WOElement)

Example 13 with NSMutableArray

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

the class ERXWOComponentContent method template.

private WOElement template(WOComponent component) {
    WOElement content = component._childTemplate();
    WOElement result = null;
    String templateName = (_templateName == null) ? null : (String) _templateName.valueInComponent(component);
    if (content != null && content.getClass() == WODynamicGroup.class) {
        WODynamicGroup group = (WODynamicGroup) content;
        if (templateName == null) {
            // MS: If you don't set a template name, then let's construct all the children of
            // this element that are NOT ERXWOTemplate's, so we don't double-display.  This lets
            // you use an ERXWOComponentContent and have it just act like a "default" template
            // that skips all the children that are explicitly wrapped in an ERXWOTemplate.
            NSMutableArray<WOElement> originalChildrenElements = group.childrenElements();
            if (originalChildrenElements != null && originalChildrenElements.count() > 0) {
                NSMutableArray<WOElement> nonTemplateChildrenElements = new NSMutableArray<>();
                for (WOElement originalChild : originalChildrenElements) {
                    if (!(originalChild instanceof ERXWOTemplate)) {
                        nonTemplateChildrenElements.addObject(originalChild);
                    }
                }
                result = new WODynamicGroup(null, null, nonTemplateChildrenElements);
            }
        } else {
            for (Enumeration e = group.childrenElements().objectEnumerator(); e.hasMoreElements() && result == null; ) {
                WOElement current = (WOElement) e.nextElement();
                if (current instanceof ERXWOTemplate) {
                    ERXWOTemplate template = (ERXWOTemplate) current;
                    String name = template.templateName(component);
                    if (name.equals(templateName)) {
                        result = template;
                    }
                }
            }
        }
    } else if (content instanceof ERXWOTemplate) {
        ERXWOTemplate template = (ERXWOTemplate) content;
        String name = template.templateName(component);
        if (name.equals(templateName)) {
            result = template;
        }
    } else if (templateName == null) {
        result = content;
    }
    return result;
}
Also used : ERXWOTemplate(er.extensions.components.conditionals.ERXWOTemplate) Enumeration(java.util.Enumeration) WODynamicGroup(com.webobjects.appserver._private.WODynamicGroup) NSMutableArray(com.webobjects.foundation.NSMutableArray) WOHTMLBareString(com.webobjects.appserver._private.WOHTMLBareString) WOElement(com.webobjects.appserver.WOElement)

Example 14 with NSMutableArray

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

the class WOEventSetupPage method registeredEventClasses.

public NSArray registeredEventClasses() {
    NSMutableArray classes;
    classes = new NSMutableArray();
    classes.setArray(EOEventCenter.registeredEventClasses());
    try {
        classes.sortUsingComparator(_classNameAscendingComparator);
    } catch (NSComparator.ComparisonException e) {
        throw NSForwardException._runtimeExceptionForThrowable(e);
    }
    return classes;
}
Also used : NSComparator(com.webobjects.foundation.NSComparator) NSMutableArray(com.webobjects.foundation.NSMutableArray)

Example 15 with NSMutableArray

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

NSMutableArray (com.webobjects.foundation.NSMutableArray)35 NSArray (com.webobjects.foundation.NSArray)13 Enumeration (java.util.Enumeration)8 NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)6 WOComponent (com.webobjects.appserver.WOComponent)4 WOElement (com.webobjects.appserver.WOElement)3 WODynamicGroup (com.webobjects.appserver._private.WODynamicGroup)3 WOHTMLBareString (com.webobjects.appserver._private.WOHTMLBareString)3 NSBundle (com.webobjects.foundation.NSBundle)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 WOComponentReference (com.webobjects.appserver._private.WOComponentReference)2 NSComparator (com.webobjects.foundation.NSComparator)2 ERXLocalizer (er.extensions.localization.ERXLocalizer)2 File (java.io.File)2 Level (org.apache.log4j.Level)2 Logger (org.apache.log4j.Logger)2 WOActionResults (com.webobjects.appserver.WOActionResults)1 WOContext (com.webobjects.appserver.WOContext)1 WOEvent (com.webobjects.appserver.WOEvent)1