@SuppressWarnings("unchecked") private static Stack<String> copy(Stack<String> stack) { return (Stack<String>) stack.clone(); } private static <T> Stack<T> reverse(Stack<T> stack) {
/** Clone the diagnostic context for the current thread. <p>Internally a diagnostic context is represented as a stack. A given thread can supply the stack (i.e. diagnostic context) to a child thread so that the child can inherit the parent thread's diagnostic context. <p>The child thread uses the {@link #inherit inherit} method to inherit the parent's diagnostic context. @return Stack A clone of the current thread's diagnostic context. */ public static Stack cloneStack() { Stack stack = getCurrentStack(); if(stack == null) return null; else { return (Stack) stack.clone(); } }
Stack ndcStack = (Stack) field.get(callableWithNdc); final Stack clonedStack = (Stack) ndcStack.clone(); final String fragmentId = (String) clonedStack.pop(); final String queryId = (String) clonedStack.pop();
@Override final public Stack<String> getFragmentStack() { if (mStackManager == null || mStackManager.getFragmentStack() == null) return new Stack<>(); return (Stack<String>) mStackManager.getFragmentStack().clone(); }
Stack<Object> enclosing = (Stack<Object>) surrounding.clone(); Queue<String> indents = new LinkedList<String>(); for (int i = 0; i < enclosing.size(); i++) {
public static Stack<Type> updateStack(StackEffectSwitch sw, Stack<Type> st) { @SuppressWarnings("unchecked") Stack<Type> clone = (Stack<Type>) st.clone();
m_currentNodes = (IntStack) xpc.getCurrentNodeStack().clone(); m_currentExpressionNodes = (IntStack) xpc.getCurrentExpressionNodeStack().clone(); m_contextNodeLists = (Stack) xpc.getContextNodeListsStack().clone(); (DTMIterator) xpc.getContextNodeList().clone(); m_axesIteratorStack = (Stack) xpc.getAxesIteratorStackStacks().clone(); m_currentTemplateRuleIsNull = (BoolStack) transformer.m_currentTemplateRuleIsNull.clone(); m_currentTemplateElements = (ObjectStack) transformer.m_currentTemplateElements.clone(); m_currentMatchTemplates = (Stack) transformer.m_currentMatchTemplates.clone(); m_attrSetStack = (Stack) transformer.m_attrSetStack.clone();
xpc.setCurrentNodeStack((IntStack) m_currentNodes.clone()); xpc.setCurrentExpressionNodeStack( (IntStack) m_currentExpressionNodes.clone()); xpc.setContextNodeListsStack((Stack) m_contextNodeLists.clone()); xpc.setAxesIteratorStackStacks((Stack) m_axesIteratorStack.clone()); (ObjectStack) m_currentTemplateElements.clone(); transformer.m_currentMatchTemplates = (Stack) m_currentMatchTemplates.clone(); transformer.m_attrSetStack = (Stack) m_attrSetStack.clone();
/** * Create a new <code>ParseState</code> whose {@link Stack} is a {@link Object#clone clone} * of that of the passed in <code>ParseState</code>. */ private ParseState(ParseState other) { this.state = (Stack) other.state.clone(); }
private Stack<String> truncatePathStack(int pLevel) { if (pathStack.size() < pLevel) { return new Stack<String>(); } else { // Trim of domain and MBean properties // pathStack gets cloned here since the processing will eat it up Stack<String> ret = (Stack<String>) pathStack.clone(); for (int i = 0;i < pLevel;i++) { ret.pop(); } return ret; } }
Stack<Type> s = (Stack<Type>) stackHeightsBefore.get(begUnit).clone();
/** * Constructor taking a max depth. The <em>max depth</em> specifies how deep the info tree should be build * up. The tree will be truncated if it gets larger than this value. A <em>path</em> (in form of a stack) * can be given, in which only a sub information is (sub-tree or leaf value) is stored * * @param pMaxDepth max depth * @param pPathStack the stack for restricting the information to add. The given stack will be cloned * and is left untouched. * @param pUseCanonicalName whether to use canonical name in listings */ public MBeanInfoData(int pMaxDepth, Stack<String> pPathStack, boolean pUseCanonicalName) { maxDepth = pMaxDepth; useCanonicalName = pUseCanonicalName; pathStack = pPathStack != null ? (Stack<String>) pPathStack.clone() : new Stack<String>(); infoMap = new JSONObject(); }
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)); } return ret; }
/** Clone the diagnostic context for the current thread. <p>Internally a diagnostic context is represented as a stack. A given thread can supply the stack (i.e. diagnostic context) to a child thread so that the child can inherit the parent thread's diagnostic context. <p>The child thread uses the {@link #inherit inherit} method to inherit the parent's diagnostic context. @return Stack A clone of the current thread's diagnostic context. */ public static Stack cloneStack() { Stack stack = getCurrentStack(); if(stack == null) { return null; } else { return (Stack) stack.clone(); } }
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 { 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; }
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 { 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; }
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; 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; }
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 { 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; }
private Object convertMxBeanMapToJson(TabularData pTd, Stack<String> pExtraArgs, ObjectToJsonConverter pConverter) throws AttributeNotFoundException { JSONObject ret = new JSONObject(); for (Object rowObject : pTd.values()) { CompositeData row = (CompositeData) rowObject; Stack<String> path = (Stack<String>) pExtraArgs.clone(); Object keyObject = row.get("key"); if (keyObject != null) { try { Object value = pConverter.extractObject(row.get("value"), path, true); ret.put(keyObject.toString(), value); } catch (ValueFaultHandler.AttributeFilteredException exp) { // Skip to next object since attribute was filtered } } } if (!pTd.isEmpty() && ret.isEmpty()) { // Bubble up if not a single thingy has been found throw new ValueFaultHandler.AttributeFilteredException(); } return ret; }
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 { 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; }