java.util.Stack.clone()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中java.util.Stack.clone()方法的一些代码示例,展示了Stack.clone()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stack.clone()方法的具体详情如下:
包路径:java.util.Stack
类名称:Stack
方法名:clone

Stack.clone介绍

暂无

代码示例

代码示例来源:origin: remkop/picocli

@SuppressWarnings("unchecked") private static Stack<String> copy(Stack<String> stack) { return (Stack<String>) stack.clone(); }
private static <T> Stack<T> reverse(Stack<T> stack) {

代码示例来源:origin: log4j/log4j

/**
  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();
 }
}

代码示例来源:origin: apache/hive

Stack ndcStack = (Stack) field.get(callableWithNdc);
final Stack clonedStack = (Stack) ndcStack.clone();
final String fragmentId = (String) clonedStack.pop();
final String queryId = (String) clonedStack.pop();

代码示例来源:origin: JingYeoh/FragmentRigger

@Override
final public Stack<String> getFragmentStack() {
  if (mStackManager == null || mStackManager.getFragmentStack() == null) return new Stack<>();
  return (Stack<String>) mStackManager.getFragmentStack().clone();
}

代码示例来源:origin: remkop/picocli

Stack<Object> enclosing = (Stack<Object>) surrounding.clone();
Queue<String> indents = new LinkedList<String>();
for (int i = 0; i < enclosing.size(); i++) {

代码示例来源:origin: Sable/soot

public static Stack<Type> updateStack(StackEffectSwitch sw, Stack<Type> st) {
 @SuppressWarnings("unchecked")
 Stack<Type> clone = (Stack<Type>) st.clone();

代码示例来源:origin: xalan/xalan

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();

代码示例来源:origin: xalan/xalan

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();

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * 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();
}

代码示例来源:origin: rhuss/jolokia

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;
  }
}

代码示例来源:origin: Sable/soot

Stack<Type> s = (Stack<Type>) stackHeightsBefore.get(begUnit).clone();

代码示例来源:origin: rhuss/jolokia

/**
 * 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();
}

代码示例来源:origin: rhuss/jolokia

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;
}

代码示例来源:origin: apache/log4j

/**
  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();
 }
}

代码示例来源:origin: rhuss/jolokia

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;
}

代码示例来源:origin: rhuss/jolokia

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;
}

代码示例来源:origin: rhuss/jolokia

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;
}

代码示例来源:origin: rhuss/jolokia

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;
}

代码示例来源:origin: rhuss/jolokia

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;
}

代码示例来源:origin: rhuss/jolokia

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;
}

相关文章