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

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

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

Stack.clone介绍

暂无

代码示例

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

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

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

  1. /**
  2. Clone the diagnostic context for the current thread.
  3. <p>Internally a diagnostic context is represented as a stack. A
  4. given thread can supply the stack (i.e. diagnostic context) to a
  5. child thread so that the child can inherit the parent thread's
  6. diagnostic context.
  7. <p>The child thread uses the {@link #inherit inherit} method to
  8. inherit the parent's diagnostic context.
  9. @return Stack A clone of the current thread's diagnostic context.
  10. */
  11. public
  12. static
  13. Stack cloneStack() {
  14. Stack stack = getCurrentStack();
  15. if(stack == null)
  16. return null;
  17. else {
  18. return (Stack) stack.clone();
  19. }
  20. }

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

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

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

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

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

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

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

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

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

  1. m_currentNodes = (IntStack) xpc.getCurrentNodeStack().clone();
  2. m_currentExpressionNodes =
  3. (IntStack) xpc.getCurrentExpressionNodeStack().clone();
  4. m_contextNodeLists = (Stack) xpc.getContextNodeListsStack().clone();
  5. (DTMIterator) xpc.getContextNodeList().clone();
  6. m_axesIteratorStack = (Stack) xpc.getAxesIteratorStackStacks().clone();
  7. m_currentTemplateRuleIsNull =
  8. (BoolStack) transformer.m_currentTemplateRuleIsNull.clone();
  9. m_currentTemplateElements =
  10. (ObjectStack) transformer.m_currentTemplateElements.clone();
  11. m_currentMatchTemplates =
  12. (Stack) transformer.m_currentMatchTemplates.clone();
  13. m_attrSetStack = (Stack) transformer.m_attrSetStack.clone();

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

  1. xpc.setCurrentNodeStack((IntStack) m_currentNodes.clone());
  2. xpc.setCurrentExpressionNodeStack(
  3. (IntStack) m_currentExpressionNodes.clone());
  4. xpc.setContextNodeListsStack((Stack) m_contextNodeLists.clone());
  5. xpc.setAxesIteratorStackStacks((Stack) m_axesIteratorStack.clone());
  6. (ObjectStack) m_currentTemplateElements.clone();
  7. transformer.m_currentMatchTemplates =
  8. (Stack) m_currentMatchTemplates.clone();
  9. transformer.m_attrSetStack = (Stack) m_attrSetStack.clone();

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

  1. /**
  2. * Create a new <code>ParseState</code> whose {@link Stack} is a {@link Object#clone clone}
  3. * of that of the passed in <code>ParseState</code>.
  4. */
  5. private ParseState(ParseState other) {
  6. this.state = (Stack) other.state.clone();
  7. }

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

  1. private Stack<String> truncatePathStack(int pLevel) {
  2. if (pathStack.size() < pLevel) {
  3. return new Stack<String>();
  4. } else {
  5. // Trim of domain and MBean properties
  6. // pathStack gets cloned here since the processing will eat it up
  7. Stack<String> ret = (Stack<String>) pathStack.clone();
  8. for (int i = 0;i < pLevel;i++) {
  9. ret.pop();
  10. }
  11. return ret;
  12. }
  13. }

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

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

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

  1. /**
  2. * Constructor taking a max depth. The <em>max depth</em> specifies how deep the info tree should be build
  3. * up. The tree will be truncated if it gets larger than this value. A <em>path</em> (in form of a stack)
  4. * can be given, in which only a sub information is (sub-tree or leaf value) is stored
  5. *
  6. * @param pMaxDepth max depth
  7. * @param pPathStack the stack for restricting the information to add. The given stack will be cloned
  8. * and is left untouched.
  9. * @param pUseCanonicalName whether to use canonical name in listings
  10. */
  11. public MBeanInfoData(int pMaxDepth, Stack<String> pPathStack, boolean pUseCanonicalName) {
  12. maxDepth = pMaxDepth;
  13. useCanonicalName = pUseCanonicalName;
  14. pathStack = pPathStack != null ? (Stack<String>) pPathStack.clone() : new Stack<String>();
  15. infoMap = new JSONObject();
  16. }

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

  1. private Object extractListAsJson(ObjectToJsonConverter pConverter, Collection pCollection, Stack<String> pPathParts, int pLength) throws AttributeNotFoundException {
  2. List ret = new JSONArray();
  3. Iterator it = pCollection.iterator();
  4. for (int i = 0;i < pLength; i++) {
  5. Object val = it.next();
  6. Stack<String> path = (Stack<String>) pPathParts.clone();
  7. ret.add(pConverter.extractObject(val, path, true));
  8. }
  9. return ret;
  10. }

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

  1. /**
  2. Clone the diagnostic context for the current thread.
  3. <p>Internally a diagnostic context is represented as a stack. A
  4. given thread can supply the stack (i.e. diagnostic context) to a
  5. child thread so that the child can inherit the parent thread's
  6. diagnostic context.
  7. <p>The child thread uses the {@link #inherit inherit} method to
  8. inherit the parent's diagnostic context.
  9. @return Stack A clone of the current thread's diagnostic context.
  10. */
  11. public
  12. static
  13. Stack cloneStack() {
  14. Stack stack = getCurrentStack();
  15. if(stack == null) {
  16. return null;
  17. } else {
  18. return (Stack) stack.clone();
  19. }
  20. }

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

  1. private Object extractBeanValues(ObjectToJsonConverter pConverter, Object pValue, Stack<String> pPathParts, List<String> pAttributes) throws AttributeNotFoundException {
  2. Map ret = new JSONObject();
  3. for (String attribute : pAttributes) {
  4. Stack path = (Stack) pPathParts.clone();
  5. try {
  6. ret.put(attribute, extractJsonifiedPropertyValue(pConverter, pValue, attribute, path));
  7. } catch (ValueFaultHandler.AttributeFilteredException exp) {
  8. // Skip it since we are doing a path with wildcards, filtering out non-matchin attrs.
  9. }
  10. }
  11. if (ret.isEmpty() && pAttributes.size() > 0) {
  12. // Ok, everything was filtered. Bubbling upwards ...
  13. throw new ValueFaultHandler.AttributeFilteredException();
  14. }
  15. return ret;
  16. }

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

  1. private Object extractListAsJson(ObjectToJsonConverter pConverter, List pList, Stack<String> pPath, int pLength) throws AttributeNotFoundException {
  2. List ret = new JSONArray();
  3. for (int i = 0;i < pLength; i++) {
  4. Stack<String> path = (Stack<String>) pPath.clone();
  5. try {
  6. ret.add(pConverter.extractObject(pList.get(i), path, true));
  7. } catch (ValueFaultHandler.AttributeFilteredException exp) {
  8. // This element is filtered out, next one ...
  9. }
  10. }
  11. if (ret.isEmpty() && pLength > 0) {
  12. throw new ValueFaultHandler.AttributeFilteredException();
  13. }
  14. return ret;
  15. }

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

  1. private JSONObject extractMapValues(ObjectToJsonConverter pConverter, Stack<String> pPathParts, boolean jsonify, Map<Object, Object> pMap, int pLength) throws AttributeNotFoundException {
  2. JSONObject ret = new JSONObject();
  3. int i = 0;
  4. for(Map.Entry entry : pMap.entrySet()) {
  5. Stack<String> paths = (Stack<String>) pPathParts.clone();
  6. try {
  7. ret.put(entry.getKey(),
  8. pConverter.extractObject(entry.getValue(), paths, jsonify));
  9. if (++i > pLength) {
  10. break;
  11. }
  12. } catch (ValueFaultHandler.AttributeFilteredException exp) {
  13. // Filtered out ...
  14. }
  15. }
  16. if (ret.isEmpty() && pLength > 0) {
  17. // Not a single value passed the filter
  18. throw new ValueFaultHandler.AttributeFilteredException();
  19. }
  20. return ret;
  21. }

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

  1. private List<Object> extractArray(ObjectToJsonConverter pConverter, Object pValue, Stack<String> pPath, boolean jsonify, int pLength) throws AttributeNotFoundException {
  2. List<Object> ret = new JSONArray();
  3. for (int i = 0; i < pLength; i++) {
  4. Stack<String> path = (Stack<String>) pPath.clone();
  5. try {
  6. Object obj = Array.get(pValue, i);
  7. ret.add(pConverter.extractObject(obj, path, jsonify));
  8. } catch (ValueFaultHandler.AttributeFilteredException exp) {
  9. // Filtered ...
  10. }
  11. }
  12. if (ret.isEmpty() && pLength > 0) {
  13. throw new ValueFaultHandler.AttributeFilteredException();
  14. }
  15. return ret;
  16. }

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

  1. private Object convertMxBeanMapToJson(TabularData pTd, Stack<String> pExtraArgs, ObjectToJsonConverter pConverter)
  2. throws AttributeNotFoundException {
  3. JSONObject ret = new JSONObject();
  4. for (Object rowObject : pTd.values()) {
  5. CompositeData row = (CompositeData) rowObject;
  6. Stack<String> path = (Stack<String>) pExtraArgs.clone();
  7. Object keyObject = row.get("key");
  8. if (keyObject != null) {
  9. try {
  10. Object value = pConverter.extractObject(row.get("value"), path, true);
  11. ret.put(keyObject.toString(), value);
  12. } catch (ValueFaultHandler.AttributeFilteredException exp) {
  13. // Skip to next object since attribute was filtered
  14. }
  15. }
  16. }
  17. if (!pTd.isEmpty() && ret.isEmpty()) {
  18. // Bubble up if not a single thingy has been found
  19. throw new ValueFaultHandler.AttributeFilteredException();
  20. }
  21. return ret;
  22. }

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

  1. private Object extractCompleteCdAsJson(ObjectToJsonConverter pConverter, CompositeData pData, Stack<String> pPath) throws AttributeNotFoundException {
  2. JSONObject ret = new JSONObject();
  3. for (String key : (Set<String>) pData.getCompositeType().keySet()) {
  4. Stack<String> path = (Stack<String>) pPath.clone();
  5. try {
  6. ret.put(key, pConverter.extractObject(pData.get(key), path, true));
  7. } catch (ValueFaultHandler.AttributeFilteredException exp) {
  8. // Ignore this key;
  9. }
  10. }
  11. if (ret.isEmpty()) {
  12. // If every key was filtered, this composite data should be skipped completely
  13. throw new ValueFaultHandler.AttributeFilteredException();
  14. }
  15. return ret;
  16. }

相关文章