Package jade.util.leap

Examples of jade.util.leap.ArrayList


    }
    else {
      tmp = myLogManager.getAllLogInfo();
    }
    // Now sort log info in alphabetical order
    List infos = new ArrayList(tmp.size());
    Iterator it = tmp.iterator();
    while (it.hasNext()) {
      LoggerInfo li = (LoggerInfo) it.next();
      String name = li.toString();
      int i = 0;
      while (i < infos.size() && name.compareTo(infos.get(i).toString()) >= 0) {
        ++i;
      }
      infos.add(i, li);
    }
    return infos;
  }
View Full Code Here


  }

  private List getAllNodesInfo() {
    // Get all node descriptors and build the list of NodeInfo
    Object[] allNodes = nodes.values().toArray();
    List infos = new ArrayList(allNodes.length);
    for (int i = 0; i < allNodes.length; ++i) {
      NodeDescriptor nodeDsc = (NodeDescriptor) allNodes[i];
      infos.add(new NodeInfo(nodeDsc));
    }

    // Build the map of services for each node
    Map nodeServices = new HashMap();
    // Avoid concurrent modification exception
    Object[] allServices = services.values().toArray();
    for (int j = 0; j < allServices.length; ++j) {
      ServiceEntry e = (ServiceEntry) allServices[j];
      Node[] serviceNodes = e.getNodes();

      for (int i = 0; i < serviceNodes.length; i++) {
        String nodeName = serviceNodes[i].getName();

        Vector v = (Vector) nodeServices.get(nodeName);
        if (v == null) {
          v = new Vector();
          nodeServices.put(nodeName, v);
        }
        Service svc = e.getService();
        v.addElement(new ServiceDescriptor(svc.getName(), svc));
      }
    }

    // Now fill the services in the list of NodeInfo
    Iterator it = infos.iterator();
    while (it.hasNext()) {
      NodeInfo ni = (NodeInfo) it.next();
      Vector v = (Vector) nodeServices.get(ni.getNodeDescriptor().getName());
      ni.setServices(v);
    }
View Full Code Here

    }
    return infos;
  }

  private Node[] getChildren(String name) {
    List children = new ArrayList();
    Object[] allNodes = nodes.values().toArray();
    for (int i = 0; i < allNodes.length; i++) {
      NodeDescriptor dsc = (NodeDescriptor) allNodes[i];
      Node parent = dsc.getParentNode();
      if (parent != null && name.equals(parent.getName())) {
        children.add(dsc.getNode());
      }
    }
    Node[] childrenArray = new Node[children.size()];
    for (int i = 0; i < childrenArray.length; ++i) {
      childrenArray[i] = (Node) children.get(i);
    }
    return childrenArray;
  }
View Full Code Here

  /**
   Searches the White Pages for agents whose description matches a given
   template.
   */
  public List amsSearch(AMSAgentDescription template, long maxResults) {
    List results = new ArrayList();
    AID[] ids = platformAgents.keys();
    for (int i = 0; i < ids.length; ++i) {
      try {
        AMSAgentDescription amsd = getAMSDescription(ids[i]);
        if (match(template, amsd)) {
          results.add(amsd);
          if (results.size() >= maxResults) {
            break;
          }
        }
      }
      catch (NotFoundException nfe) {
View Full Code Here

 
  /**
   Return all agents living on a container
   */
  public List containerAgents(ContainerID cid) throws NotFoundException {
    List agents = new ArrayList();
    AID[] allIds = platformAgents.keys();
   
    for (int i = 0; i < allIds.length; ++i) {
      AID    id = allIds[i];
      AgentDescriptor ad = platformAgents.acquire(id);
      if (ad != null) {
        ContainerID cid1 = ad.getContainerID();
       
        if (cid.equals(cid1)) {
          agents.add(id);
        }
        platformAgents.release(id);
      }
    }
    return agents;
View Full Code Here

      resultItems = theAMS.searchAction((Search) action, request.getSender());
    }
    // GET_DESCRIPTION
    else if (action instanceof GetDescription) {
      APDescription dsc = theAMS.getDescriptionAction(request.getSender());
      resultItems = new ArrayList();
      resultItems.add(dsc);
    }
    else {
      throw new UnsupportedFunction();
    }
View Full Code Here

    for (int i = 0; i < subscriptions.length; ++i) {
      SubscriptionInfo info = subscriptions[i];
      DFAgentDescription template = info.getTemplate();
      if ( DFMemKB.compare(template, dfd) || ((oldDfd!=null) && DFMemKB.compare(template, oldDfd))) {
        // This subscriber must be notified
        List results = new ArrayList();
        results.add(dfd);
        if (myLogger.isLoggable(Logger.FINE)) {
          ACLMessage subMessage = info.getSubscription().getMessage();
          myLogger.log(Logger.FINE, "Notifying subscribed agent "+subMessage.getSender().getName()+" ["+subMessage.getConversationId()+"] ");
        }
        notify(info.getSubscription(), results, info.getAbsIota());
View Full Code Here

        myLogger.log(Logger.SEVERE,"Internal error: handleMove() called with a wrong name (" + agentID.getName() + ") !!!");
        return;
      }
     
      int transferState = 0;
      List messages = new ArrayList();
      AgentMobilitySlice dest = null;
      try {
        // If the destination container is the same as this one, there is nothing to do
        if (CaseInsensitiveString.equalsIgnoreCase(where.getName(), myContainer.here().getName())) {
          return;
View Full Code Here

        queue.setMaxSize(msgQueueMaxSize);
        // Copy messages (if any) from the old message queue to the new one
        synchronized (msgQueue) {
          int size = msgQueue.size();
          if (size > 0) {
            List l = new ArrayList(size);
            msgQueue.copyTo(l);
            Iterator it = l.iterator();
            while (it.hasNext()) {
              queue.addLast((ACLMessage) it.next());
            }
          }
          msgQueue = queue;
View Full Code Here

   */
  public void setEnabledO2ACommunication(boolean enabled, int queueSize) {
    if(enabled) {
      if(o2aQueue == null)
        o2aQueue = new ArrayList(queueSize);

      // Ignore a negative value
      if(queueSize >= 0)
        o2aQueueSize = queueSize;
    }
View Full Code Here

TOP

Related Classes of jade.util.leap.ArrayList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.