Package ariba.util.fieldvalue

Examples of ariba.util.fieldvalue.OrderedList


    }

    protected Object getValueBody( ExprContext context, Object source ) throws ExprException
    {
        Object result = null;
        OrderedList listProto = OrderedList.get(source);
        // int indexType = getIndexedPropertyType(context, source);
        Object      index = getProperty(context, source);

        if (index instanceof DynamicSubscript) {
            Object      array = source;
            int         len = listProto.size(array);

            switch (((DynamicSubscript)index).getFlag()) {
                case DynamicSubscript.ALL:
                    return listProto.copy(array);
                case DynamicSubscript.FIRST:
                    index = new Integer((len > 0) ? 0 : -1);
                    break;
                case DynamicSubscript.MID:
                    index = new Integer((len > 0) ? (len / 2) : -1);
                    break;
                case DynamicSubscript.LAST:
                    index = new Integer((len > 0) ? (len - 1) : -1);
                    break;
            }
        } else {
            Assert.that(index instanceof Number, "array subscript must be number");
            // if (indexType == ExprRuntime.INDEXED_PROPERTY_OBJECT) {
            // throw new ExprException("DynamicSubscript '" + this + "' not allowed for object indexed property '" + source + "'");
        }
        try {
            Object value = listProto.elementAt(source, ((Number)index).intValue());
            return ExprRuntime.convert(value);
        }
        catch (IndexOutOfBoundsException e) {
            // If there is no element, return null
            return null;
View Full Code Here


    }

    protected void setValueBody( ExprContext context, Object target, Object value ) throws ExprException
    {
        Object      index = getProperty(context, target);
        OrderedList listProto = OrderedList.get(target);
        if (index instanceof DynamicSubscript) {
            Object      array = target;
            int         len = Array.getLength(array);

            switch (((DynamicSubscript)index).getFlag()) {
                case DynamicSubscript.ALL:
                    Assert.that(false, "Array assignment to subscript All not supported");
                case DynamicSubscript.FIRST:
                    index = new Integer((len > 0) ? 0 : -1);
                    break;
                case DynamicSubscript.MID:
                    index = new Integer((len > 0) ? (len / 2) : -1);
                    break;
                case DynamicSubscript.LAST:
                    index = new Integer((len > 0) ? (len - 1) : -1);
                    break;
            }
        } else {
            Assert.that(index instanceof Number, "array subscript must be number");
/*
            if (indexType == ExprRuntime.INDEXED_PROPERTY_OBJECT) {
                throw new ExprException("DynamicSubscript '" + this + "' not allowed for object indexed property '" + target + "'");
            }
*/
        }
        try {
            listProto.setElementAt(target, value, ((Number)index).intValue());
        }
        catch (IndexOutOfBoundsException e) {
            // If there is no element, no op.
        }
    }
View Full Code Here

        List result = null;
        if (list != null) {
            if (list instanceof List) {
                return (List)list;
            }
            OrderedList orderedList = OrderedList.get(list);
            int count = orderedList.size(list);
            result = ListUtil.list(count);
            for (int i=0; i<count; i++) {
                result.add(orderedList.elementAt(list, i));
            }
        }
        return result;
    }
View Full Code Here

        Object[] result = null;
        if (list != null) {
            if (list instanceof List) {
                return ((List)list).toArray();
            }
            OrderedList orderedList = OrderedList.get(list);
            int count = orderedList.size(list);
            result = new Object[count];
            for (int i=0; i<count; i++) {
                result[i] = orderedList.elementAt(list, i);
            }
        }
        return result;
    }
View Full Code Here

     * @param list
     * @return
     */
    public static boolean orderedListArrayMatch (Object list, Object[] array)
    {
        OrderedList orderedList = (list != null) ? OrderedList.get(list) : null;

        if (list == null && array == null) {
            // if both null, then no change
            return true;
        }

        if ((list == null || array == null) || (orderedList.size(list) != array.length)) {
            // if one null and not the other, then changed
            return false;
        }

        // otherwise, we need to walk cached list and see if we happen
        // to have the same list
        for (int i=0, size=array.length; i < size; i++) {
            if (orderedList.elementAt(list, i) != array[i]) {
                return false;
            }
        }

        return true;
View Full Code Here

    protected Object getValueBody( ExprContext context, Object source ) throws ExprException
    {
        // Eventually we need to generalize to apply via classextension...
        Node                expr = children[0];
        OrderedList listInterface = OrderedList.get(source);
        Iterator e = listInterface.elements(source);

        if (methodName.equals("collect")) return collect(e, expr, context, source);
        else if (methodName.equals("findAll")) return findAll(e, expr, context, source);
        else if (methodName.equals("find")) return find(e, expr, context, source);
        else if (methodName.equals("sum")) return sum(e, expr, context, source);
View Full Code Here

TOP

Related Classes of ariba.util.fieldvalue.OrderedList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.