Example usage for java.util Stack clone

List of usage examples for java.util Stack clone

Introduction

In this page you can find the example usage for java.util Stack clone.

Prototype

@HotSpotIntrinsicCandidate
protected native Object clone() throws CloneNotSupportedException;

Source Link

Document

Creates and returns a copy of this object.

Usage

From source file:org.openremote.server.route.SubflowRoute.java

public static Map<String, Object> copyCorrelationStack(Map<String, Object> headers, boolean popStack) {
    Map<String, Object> headersCopy = new HashMap<>(headers);
    if (hasCorrelationStack(headers)) {

        @SuppressWarnings("unchecked")
        Stack<String> correlationStack = (Stack<String>) headers.get(SUBFLOW_CORRELATION_STACK);

        @SuppressWarnings("unchecked")
        Stack<String> correlationStackCopy = (Stack<String>) correlationStack.clone();

        if (correlationStackCopy.size() > 0 && popStack) {
            correlationStackCopy.pop();/*from   w w w  .j a va2  s  .c  o  m*/
        }
        headersCopy.put(SUBFLOW_CORRELATION_STACK, correlationStackCopy);
    }
    return headersCopy;
}

From source file:org.plasma.sdo.core.CorePathAssembler.java

@SuppressWarnings("unchecked")
public String getMinimumPathString() {
    Stack<PathNode> path = getMinimumPath();
    Stack<PathNode> clone = (Stack<PathNode>) path.clone();

    String result = getPathString(clone);
    return result;
}

From source file:org.jolokia.converter.json.CompositeDataExtractor.java

private Object extractCompleteCdAsJson(ObjectToJsonConverter pConverter, CompositeData pData,
        Stack<String> pPath) throws AttributeNotFoundException {
    JSONObject ret = new JSONObject();
    for (String key : (Set<String>) pData.getCompositeType().keySet()) {
        Stack<String> path = (Stack<String>) pPath.clone();
        try {//from   w w w. j  a v  a  2  s. co  m
            ret.put(key, pConverter.extractObject(pData.get(key), path, true));
        } catch (ValueFaultHandler.AttributeFilteredException exp) {
            // Ignore this key;
        }
    }
    if (ret.isEmpty()) {
        // If every key was filtered, this composite data should be skipped completely
        throw new ValueFaultHandler.AttributeFilteredException();
    }
    return ret;
}

From source file:org.apache.fop.render.rtf.rtflib.tools.BuilderContext.java

/** find first object of given class from top of stack s
 *  @return null if not found//from w w w  .j av  a 2  s.c  o m
 */
private Object getObjectFromStack(Stack s, Class desiredClass) {
    Object result = null;
    final Stack copy = (Stack) s.clone();
    while (!copy.isEmpty()) {
        final Object o = copy.pop();
        if (desiredClass.isAssignableFrom(o.getClass())) {
            result = o;
            break;
        }
    }
    return result;
}

From source file:org.jolokia.converter.json.ListExtractor.java

private Object extractListAsJson(ObjectToJsonConverter pConverter, List pList, Stack<String> pPath, int pLength)
        throws AttributeNotFoundException {
    List ret = new JSONArray();
    for (int i = 0; i < pLength; i++) {
        Stack<String> path = (Stack<String>) pPath.clone();
        try {/*from   ww  w  .ja  v a2  s  . c  om*/
            ret.add(pConverter.extractObject(pList.get(i), path, true));
        } catch (ValueFaultHandler.AttributeFilteredException exp) {
            // This element is filtered out, next one ...
        }
    }
    if (ret.isEmpty() && pLength > 0) {
        throw new ValueFaultHandler.AttributeFilteredException();
    }
    return ret;
}

From source file:org.jolokia.converter.json.ArrayExtractor.java

private List<Object> extractArray(ObjectToJsonConverter pConverter, Object pValue, Stack<String> pPath,
        boolean jsonify, int pLength) throws AttributeNotFoundException {
    List<Object> ret = new JSONArray();
    for (int i = 0; i < pLength; i++) {
        Stack<String> path = (Stack<String>) pPath.clone();
        try {//  w  w  w .  j  av a  2s  .co  m
            Object obj = Array.get(pValue, i);
            ret.add(pConverter.extractObject(obj, path, jsonify));
        } catch (ValueFaultHandler.AttributeFilteredException exp) {
            // Filtered ...
        }
    }
    if (ret.isEmpty() && pLength > 0) {
        throw new ValueFaultHandler.AttributeFilteredException();
    }
    return ret;
}

From source file:org.jolokia.converter.json.CollectionExtractor.java

private Object extractListAsJson(ObjectToJsonConverter pConverter, Collection pCollection,
        Stack<String> pPathParts, int pLength) throws AttributeNotFoundException {
    List ret = new JSONArray();
    Iterator it = pCollection.iterator();
    for (int i = 0; i < pLength; i++) {
        Object val = it.next();
        Stack<String> path = (Stack<String>) pPathParts.clone();
        ret.add(pConverter.extractObject(val, path, true));
    }//from w  w w . j  a v  a  2 s.  co m
    return ret;
}

From source file:org.jolokia.converter.json.MapExtractor.java

private JSONObject extractMapValues(ObjectToJsonConverter pConverter, Stack<String> pPathParts, boolean jsonify,
        Map<Object, Object> pMap, int pLength) throws AttributeNotFoundException {
    JSONObject ret = new JSONObject();
    int i = 0;/*from w w  w . java  2  s .  co m*/
    for (Map.Entry entry : pMap.entrySet()) {
        Stack<String> paths = (Stack<String>) pPathParts.clone();
        try {
            ret.put(entry.getKey(), pConverter.extractObject(entry.getValue(), paths, jsonify));
            if (++i > pLength) {
                break;
            }
        } catch (ValueFaultHandler.AttributeFilteredException exp) {
            // Filtered out ...
        }
    }
    if (ret.isEmpty() && pLength > 0) {
        // Not a single value passed the filter
        throw new ValueFaultHandler.AttributeFilteredException();
    }
    return ret;
}

From source file:org.jolokia.converter.json.simplifier.SimplifierExtractor.java

private Object extractAll(ObjectToJsonConverter pConverter, T pValue, Stack<String> pPathParts, boolean jsonify)
        throws AttributeNotFoundException {
    JSONObject ret = new JSONObject();
    for (Map.Entry<String, AttributeExtractor<T>> entry : extractorMap.entrySet()) {
        Stack<String> paths = (Stack<String>) pPathParts.clone();
        try {/*w  w w  .j a va  2  s  .c  o  m*/
            Object value = entry.getValue().extract(pValue);
            ret.put(entry.getKey(), pConverter.extractObject(value, paths, jsonify));
        } catch (AttributeExtractor.SkipAttributeException e) {
            // Skip this one ...
            continue;
        } catch (ValueFaultHandler.AttributeFilteredException e) {
            // ... and this, too
            continue;
        }
    }
    if (ret.isEmpty()) {
        // Everything filtered, bubble up ...
        throw new ValueFaultHandler.AttributeFilteredException();
    }
    return ret;
}

From source file:org.jolokia.converter.json.BeanExtractor.java

private Object extractBeanValues(ObjectToJsonConverter pConverter, Object pValue, Stack<String> pPathParts,
        List<String> pAttributes) throws AttributeNotFoundException {
    Map ret = new JSONObject();
    for (String attribute : pAttributes) {
        Stack path = (Stack) pPathParts.clone();
        try {//from   w ww.j  a  va 2 s.c  o  m
            ret.put(attribute, extractJsonifiedPropertyValue(pConverter, pValue, attribute, path));
        } catch (ValueFaultHandler.AttributeFilteredException exp) {
            // Skip it since we are doing a path with wildcards, filtering out non-matchin attrs.
        }
    }
    if (ret.isEmpty() && pAttributes.size() > 0) {
        // Ok, everything was filtered. Bubbling upwards ...
        throw new ValueFaultHandler.AttributeFilteredException();
    }
    return ret;
}