Package jade.util.leap

Examples of jade.util.leap.List


   * can be associated to a given type of object.
   * @param type The type of object the registered <code>Loader</code> is associated to
   * @param loader The <code>Loader</code> instance.
   */
  public synchronized static void addLoader(String type, Loader loader) {
    List l = (List) loaders.get(type);
    if (l == null) {
      l = new ArrayList();
      loaders.put(type, l);
    }
    l.add(loader);
  }
View Full Code Here


    }
    l.add(loader);
  }
 
  public synchronized static boolean removeLoader(String type, Loader loader) {
    List l = (List) loaders.get(type);
    if (l != null) {
      return l.remove(loader);
    }
    return false;
  }
View Full Code Here

   */
  public synchronized static Object load(String extendedClassName, String type) throws ClassNotFoundException, IllegalAccessException, InstantiationException{
    if (extendedClassName == null) {
      throw new IllegalArgumentException("Null class name");
    }
    List l = (List) loaders.get(type);
    if (l != null && !l.isEmpty()) {
      // If we have loaders for this type of object, try to use them
      Properties pp = getClassProperties(extendedClassName);
      String className = pp.getProperty(ObjectManager.CLASS_NAME);
      Iterator it = l.iterator();
      while (it.hasNext()) {
        Loader loader = (Loader) it.next();
        Object obj = loader.load(className, pp);
        if (obj != null) {
          return obj;
View Full Code Here

    DFAgentDescription output = null;
    try{
     
      JADEAppletRequestProto rf = new JADEAppletRequestProto(this,getDescriptionOfThisDF().getName(), DFAppletVocabulary.GETDESCRIPTIONUSED,null,df);
      rf.doProto();                                          
      List result = rf.getResult();
     
      output = (DFAgentDescription)result.get(0);
     
    }catch(FIPAException e){
      e.printStackTrace();
    }catch(JADEAppletRequestProto.NotYetReady nyr){
      nyr.printStackTrace();   
View Full Code Here

      throw new NotYetReady();
    if(lastMsg.getPerformative() != ACLMessage.INFORM)
      throw new FIPAException(lastMsg);
    Result r = AppletRequestProto.extractContent(lastMsg.getContent(),(SLCodec)c,o);
        Iterator i = r.getItems().iterator(); //this is the set of DFAgentDescription
        List l = new ArrayList();
        while (i.hasNext())
          l.add(i.next());
        return l;
  }
View Full Code Here

    value = argProp.getProperty(REMOTE_SERVICE_MANAGER_ADDRESSES);
    if (value != null) {
      try {
        Vector v = Specifier.parseSpecifierList(value);
        // Convert the Vector into a List
        List l = new ArrayList(v.size());
        Enumeration e = v.elements();
        while (e.hasMoreElements()) {
          l.add(e.nextElement());
        }
        setSpecifiers(Profile.REMOTE_SERVICE_MANAGER_ADDRESSES, l);
      }
      catch(Exception e) {
        e.printStackTrace();
      }
    }

    value = argProp.getProperty(NAME_KEY);
    if (value != null) {
      profileProp.setProperty(Profile.PLATFORM_ID, value);
   

    value = argProp.getProperty(LOGIN_KEY);
    if (value != null) {
      profileProp.setProperty(Profile.USERAUTH_KEY, value);
   

    value = argProp.getProperty(MTP_KEY);
    if (value != null) {
      setSpecifiers(Profile.MTPS, parseSpecifiers(value));
    }

    //NOMTP
    flag = fetchAndVerifyBoolean(NOMTP_KEY);
    if (flag) {
      // Since the value was set to true, cancel the MTP settings
      setSpecifiers(Profile.MTPS, new ArrayList(0));
    }

    value = argProp.getProperty(ACLCODEC_KEY);
    if (value != null) {
      setSpecifiers(Profile.ACLCODECS, parseSpecifiers(value));
    }

    // Get agent list (if any)
    value = argProp.getProperty(AGENTS);


    flag = fetchAndVerifyBoolean(GUI_KEY);
    if (flag) {
      // need to run RMA agent
      if (value != null) {
        value = "RMA:jade.tools.rma.rma " + value;  // put before other agents
      } else {
        value = "RMA:jade.tools.rma.rma"// only one
      }
    }

    if (value != null) {
      Vector agentVector = helper.T2(value, false);
      List agents = new ArrayList();

      for (Enumeration e = helper.getCommandLineAgentSpecifiers(agentVector);
      e.hasMoreElements(); ) {
        agents.add((Specifier) e.nextElement());
      }

      setSpecifiers(Profile.AGENTS, agents);
    }
View Full Code Here

   * 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

        id = ((AgentEvent) ev).getAgent();
      }
      else if (ev instanceof MessageEvent) {
        id = ((MessageEvent) ev).getAgent();
      }
      List l = (List) pendingEvents.get(id);
      if (l != null) {
        l.remove(ev);
        if (l.isEmpty()) {
          pendingEvents.remove(id);
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of jade.util.leap.List

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.