当前位置: 首页>>代码示例>>Java>>正文


Java Stack.elementAt方法代码示例

本文整理汇总了Java中java.util.Stack.elementAt方法的典型用法代码示例。如果您正苦于以下问题:Java Stack.elementAt方法的具体用法?Java Stack.elementAt怎么用?Java Stack.elementAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Stack的用法示例。


在下文中一共展示了Stack.elementAt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addStackToCycle

import java.util.Stack; //导入方法依赖的package包/类
/**
 * 
 * @param stack
 * @param sm
 */
public void addStackToCycle(Stack<SootMethod> stack, SootMethod sm) {
  Set<SootMethod> methods = new HashSet<SootMethod>();
  int startIndex = stack.indexOf(sm);
  for (int i=startIndex+1; i<stack.size(); i++)
    methods.add(stack.elementAt(i));
  
  CycleKey ck = new CycleKey(sm, stack.size()+1); // +1 since sm is not in the stack
  if (!cycle2Methods.keySet().contains(ck)) {
    String s = "\n";
    for (int i=0; i<stack.size(); i++)
      s += i +"> "+ stack.elementAt(i) +"\n";
    throw new RuntimeException("error: cyclekey not in stack! "+ ck + s);
  }
  cycle2Methods.get(ck).addAll(methods);
  cache.addAll(methods);
  System.out.println("[cycle] add at depth '"+ stack.size() +"' for method '"+ sm +"'");
}
 
开发者ID:Alexandre-Bartel,项目名称:permission-map,代码行数:23,代码来源:Cycles.java

示例2: deleteChildNodes

import java.util.Stack; //导入方法依赖的package包/类
/**
 * When replacing the bookmark's text, it is necessary to delete any nodes
 * that are found between matching start and end tags. Complications occur
 * here because it is possible to have bookmarks nested within bookmarks to
 * almost any level and it is important to not remove any inner or nested
 * bookmarks when replacing the contents of an outer or containing
 * bookmark. This code successfully handles the simplest occurrence - where
 * one bookmark completely contains another - but not more complex cases
 * where one bookmark overlaps another in the markup. That is still to do.
 *
 * @param nodeStack An instance of the Stack class that encapsulates
 * references to any and all nodes found between the opening and closing
 * tags of a bookmark.
 */
private void deleteChildNodes(Stack<Node> nodeStack) {
    Node toDelete = null;
    int bookmarkStartID = 0;
    int bookmarkEndID = 0;
    boolean inNestedBookmark = false;

    // The first element in the list will be a bookmarkStart tag and that
    // must not be deleted.
    for(int i = 1; i < nodeStack.size(); i++) {

        // Get an element. If it is another bookmarkStart tag then
        // again, we do not want to delete it, it's matching end tag
        // or any nodes that fall inbetween.
        toDelete = nodeStack.elementAt(i);
        if(toDelete.getNodeName().contains(BookMark.BOOKMARK_START_TAG)) {
            bookmarkStartID = Integer.parseInt(
                    toDelete.getAttributes().getNamedItem(BookMark.BOOKMARK_ID_ATTR_NAME).getNodeValue());
            inNestedBookmark = true;
        }
        else if(toDelete.getNodeName().contains(BookMark.BOOKMARK_END_TAG)) {
            bookmarkEndID = Integer.parseInt(
                    toDelete.getAttributes().getNamedItem(BookMark.BOOKMARK_ID_ATTR_NAME).getNodeValue());
            if(bookmarkEndID == bookmarkStartID) {
                inNestedBookmark = false;
            }
        }
        else {
            if(!inNestedBookmark) {
                this._para.getCTP().getDomNode().removeChild(toDelete);
            }
        }
    }
}
 
开发者ID:dragon-yuan,项目名称:Ins_fb_pictureSpider_WEB,代码行数:48,代码来源:BookMark.java

示例3: addPermissionsToStack

import java.util.Stack; //导入方法依赖的package包/类
private static void addPermissionsToStack(Stack<SootMethod> stack, SootMethod outMethod) {
  if (!methodToPermissionSet.containsKey(outMethod))
    return;
  Set<String> permissions = methodToPermissionSet.get(outMethod);
  if (permissions.size() == 0)
    return;
  for (int i = 0; i < stack.size(); i++) {
    SootMethod sm = stack.elementAt(i);
    if (methodToPermissionSet.containsKey(sm)) {
      methodToPermissionSet.get(sm).addAll(permissions);
    } else {
      methodToPermissionSet.put(sm, new HashSet<String>(permissions));
    }     
  }
}
 
开发者ID:Alexandre-Bartel,项目名称:permission-map,代码行数:16,代码来源:ForwardSearch.java

示例4: QName

import java.util.Stack; //导入方法依赖的package包/类
/**
 * Construct a QName from a string, resolving the prefix
 * using the given namespace stack. The default namespace is
 * not resolved.
 *
 * @param qname Qualified name to resolve
 * @param namespaces Namespace stack to use to resolve namespace
 * @param validate If true the new QName will be validated and an IllegalArgumentException will
 *                 be thrown if it is invalid.
 */
public QName(String qname, Stack namespaces, boolean validate)
{

  String namespace = null;
  String prefix = null;
  int indexOfNSSep = qname.indexOf(':');

  if (indexOfNSSep > 0)
  {
    prefix = qname.substring(0, indexOfNSSep);

    if (prefix.equals("xml"))
    {
      namespace = S_XMLNAMESPACEURI;
    }
    // Do we want this?
    else if (prefix.equals("xmlns"))
    {
      return;
    }
    else
    {
      int depth = namespaces.size();

      for (int i = depth - 1; i >= 0; i--)
      {
        NameSpace ns = (NameSpace) namespaces.elementAt(i);

        while (null != ns)
        {
          if ((null != ns.m_prefix) && prefix.equals(ns.m_prefix))
          {
            namespace = ns.m_uri;
            i = -1;

            break;
          }

          ns = ns.m_next;
        }
      }
    }

    if (null == namespace)
    {
      throw new RuntimeException(
        XMLMessages.createXMLMessage(
          XMLErrorResources.ER_PREFIX_MUST_RESOLVE,
          new Object[]{ prefix }));  //"Prefix must resolve to a namespace: "+prefix);
    }
  }

  _localName = (indexOfNSSep < 0)
               ? qname : qname.substring(indexOfNSSep + 1);

  if (validate)
  {
      if ((_localName == null) || (!XML11Char.isXML11ValidNCName(_localName)))
      {
         throw new IllegalArgumentException(XMLMessages.createXMLMessage(
          XMLErrorResources.ER_ARG_LOCALNAME_INVALID,null )); //"Argument 'localName' not a valid NCName");
      }
  }
  _namespaceURI = namespace;
  _prefix = prefix;
  m_hashCode = toString().hashCode();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:78,代码来源:QName.java

示例5: getArrayFromMethod

import java.util.Stack; //导入方法依赖的package包/类
/**
   * Get the definition of the Array starting from an ArrayRef.
   * Two possibilities:
   * 1) array = IdentityStmt in which case the previous method in the stack is analyzed
   * 2) array = newarray in which case all statements array[i] = r are analyzed
   * @param stack
   * @param curDepth
   * @param ar
   * @param mpSet
   */
  private static void getArrayFromMethod (Stack<SootMethod> stack, int curDepth, ArrayRef ar, Set<String> mpSet) {
    
    SootMethod targetM = stack.elementAt(curDepth);
    logger.info("getArrayFromMethod target: "+ targetM);
    
    Body b = targetM.getActiveBody();
    System.out.println("body: "+ b); // TODO: change to logger.debug
    UnitGraph eug = new ExceptionalUnitGraph( b ); 

    LocalDefinition ld = new LocalDefinition(b);
    Local l = (Local)ar.getBase();
  
    List<Unit> arrayDefs = ld.collectDefinitionsWithAliases(l);
    for (Unit arrayDef: arrayDefs) {
      if (arrayDef instanceof IdentityStmt) {
        logger.info("array: right is IdentityStmt");
        IdentityStmt ids = (IdentityStmt)arrayDef;
        ParameterRef pref = (ParameterRef)ids.getRightOp();
        int paramPos = pref.getIndex();
        logger.info("index of array parameter: "+ paramPos); // TODO: should be debug
//        List<MethodCall> methodCallsList = getStringParameterInCall(stack.elementAt(curDepth - 1), targetM, paramPos, mpSet);
//        getArrayFromMethod (stack, stack.size()-1, ar, mpSet);
        getStringFromMethod (stack, curDepth-1, targetM, paramPos, mpSet);
      } else if (arrayDef instanceof AssignStmt) {
        AssignStmt ass = (AssignStmt) arrayDef;
        Value right = ass.getRightOp();
        if (right instanceof NewArrayExpr) {
          logger.info("array: right is NewArray");
          // get the unit array[i] = str
          // TODO: Limitation: we suppose the array is initialized in the body where it is created
          // and that it is not aliased
          Local arrayLocal = (Local)ass.getLeftOp();
          List<Value> arrayInitValues = retrieveArrayInitStmts (b, arrayLocal);
          for (Value v: arrayInitValues) {
            if (v instanceof StringConstant) {
              StringConstant sc = (StringConstant)v;
              String p = sc.value;
              mpSet.add(p);
              logger.info("add perm from array inif: "+ p);
            } else {
              logger.warn("not handling this value for array init: "+ v);
            }
          }
        } else if (right instanceof Local){
          logger.info("alias "+ ass); // definitions *and* aliases are collected, so no need to handle them separately
        } else {
          throw new RuntimeException("error: right not instance of NewArrayExpr nor Local! "+ ass);
        }
      }
    }

  }
 
开发者ID:Alexandre-Bartel,项目名称:permission-map,代码行数:63,代码来源:CheckForPermission.java


注:本文中的java.util.Stack.elementAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。