Package jade.util.leap

Examples of jade.util.leap.ArrayList


   * For each object specifier, a new java object <code>Specifier</code>
   * is added to the passed <code>out</code> List parameter.
   */
  public List parseSpecifiers(String str) throws PropertiesException {

    List result = new ArrayList();

    // Cursor on the given string: marks the parser position
    int cursor = 0;

    while (cursor < str.length()) {
      int commaPos = str.indexOf(ARGUMENT_SEPARATOR, cursor);

      if (commaPos == -1) {
        commaPos = str.length();
      }

      String arg = str.substring(cursor, commaPos);
      int openBracketPos = arg.indexOf('(');
      int closedBracketPos = arg.indexOf(')');
      Specifier s = new Specifier();

      if ((openBracketPos == -1) && (closedBracketPos == -1)) {

        // No brackets: no argument
        s.setClassName(arg);
      } else {

        // An open bracket, then something, then a closed bracket:
        // the class name is before the open bracket, and the
        // argument is between brackets.
        if ((openBracketPos != -1) && (closedBracketPos != -1)
            && (openBracketPos < closedBracketPos)) {
          s.setClassName(arg.substring(0, openBracketPos));

          Object a[] = new Object[1];

          a[0] = arg.substring(openBracketPos + 1,
              closedBracketPos);

          s.setArgs(a);
        } else {
          throw new PropertiesException(
              "Ill-formed specifier: mismatched parentheses.");
        }
      }

      cursor = commaPos + 1;

      result.add(s);
    }    // while (cursor)
    return result;
  }
View Full Code Here


                    as.setClassName(cur.substring(index1 + 1, index2));

                    // having removed agentName,':',agentClass, and '(',
                    // what remains is the firstArgument of the Agent
                    // search for all the arguments up to the closed parenthesis
                    List asArgs = new ArrayList();
                    String nextArg =
                        cur.substring(index2 + 1);    //from the '(' to the end

                    while (!getAgentArgument(nextArg, asArgs)) {    //4
                        i++;

                        if (i >= args.size()) {    //5
                            System.err.println(
                                "Missing closed bracket to delimit agent arguments. The system cannot be launched");

                            //FIXME printUsageInfo = true;
                        }    //5

                        nextArg = (String) args.elementAt(i);
                    }    // 4

                    Object agentArgs[] = new Object[asArgs.size()];

                    for (int i3 = 0; i3 < asArgs.size(); i3++) {
                        agentArgs[i3] = (String) asArgs.get(i3);
                    }

                    as.setArgs(agentArgs);
                }    // 3
View Full Code Here

  // Utility methods dealing with pending events
  private void addPendingEvent(JADEEvent ev, AID id) {
    synchronized (pendingEvents) {
      List l = (List) pendingEvents.get(id);
      if (l == null) {
        l = new ArrayList();
        pendingEvents.put(id, l);
      }
      l.add(ev);
    }
  }
View Full Code Here

    // given, activate the default HTTP MTP (unless some MTPs have
    // been directly provided).
    if(isMain() && (!getBooleanProperty("nomtp", false)) && (props.getProperty(MTPS) == null)) {
      Specifier s = new Specifier();
      s.setClassName("jade.mtp.http.MessageTransportProtocol");
      List l = new ArrayList(1);
      l.add(s);
      props.put(MTPS, l);
    }
    //#J2ME_EXCLUDE_END
   
  }
View Full Code Here

    // The list should be present as a string --> parse it
    String    specsLine = getParameter(key, null);
    try {
      Vector v = Specifier.parseSpecifierList(specsLine);
      // convert the vector into an arraylist (notice that using the vector allows to avoid class loading of ArrayList)
      List l1 = new ArrayList(v.size());
      for (int i=0; i<v.size(); i++)
        l1.add(v.elementAt(i));
      return l1;
    }
    catch (Exception e) {
      throw new ProfileException("Error parsing specifier list "+specsLine+".", e);
    }
View Full Code Here

     //FIXME for applet I have not the agent c = sender.lookupLanguage(SL0Codec.NAME);
     //if (c == null)
       c = new SLCodec();

     // Write the action in the :content slot of the request
     List content = new ArrayList();
     content.add(act);

     try {
      String s = ((SLCodec)c).encode(o, (AbsContentElement)o.fromObject(act));
      this.reqMsg.setContent(s);
    } catch(OntologyException oe) {
View Full Code Here

     
      // Put the peer in the table of local ICPs.
      String proto = tp.getName().toLowerCase();
      List                  list = (List) icps.get(proto);
      if (list == null) {
        icps.put(proto, (list = new ArrayList()));
      }
     
      list.add(peer);
    }
    catch (ICPException icpe) {
View Full Code Here

   @param dest The value to add to the slot value set.
   */
  public void addReplyTo(AID dest) {
    if (dest != null) {
      //#MIDP_EXCLUDE_BEGIN
      reply_to = (reply_to == null ? new ArrayList(REPLYTO_EXPECTED_SIZE) : reply_to);
      reply_to.add(dest);
      //#MIDP_EXCLUDE_END
      /*#MIDP_INCLUDE_BEGIN
       reply_to = (reply_to == null ? new Vector(REPLYTO_EXPECTED_SIZE) : reply_to);
       reply_to.addElement(dest);
View Full Code Here

    executeRemotely(c, 0);
  }
   
  public List removePendingMessages(MessageTemplate template) {
    synchronized (pendingCommands) {
      List messages = new ArrayList();
      List commands = new ArrayList();
      Enumeration e = pendingCommands.elements();
      while (e.hasMoreElements()) {
        Command c = (Command) e.nextElement();
        if (c.getCode() == FrontEndSkel.MESSAGE_IN) {
          ACLMessage msg = (ACLMessage) c.getParamAt(0);
          if (template.match(msg)) {
            Object[] oo = new Object[]{msg, c.getParamAt(1)};
            messages.add(oo);
            commands.add(c);
          }
        }
      }
      // Remove all the commands carrying matching messages
      Iterator it = commands.iterator();
      while (it.hasNext()) {
        pendingCommands.remove(it.next());
     
     
      // Return the list of matching messages
View Full Code Here

        result.source = (AID)source.clone();
      }
     
      // Deep clone receivers
      if(dests != null) {
        result.dests = new ArrayList(dests.size());
        Iterator it = dests.iterator();
        while(it.hasNext()) {
          AID id = (AID)it.next();
          result.dests.add(id.clone());
        }
      }
     
      // Deep clone reply_to
      if(reply_to != null) {
        result.reply_to = new ArrayList(reply_to.size());
        Iterator it = reply_to.iterator();
        while(it.hasNext()) {
          AID id = (AID)it.next();
          result.reply_to.add(id.clone());
        }
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.