Package java.util

Examples of java.util.HashSet


   * of a task will need less memory. This can be interesting if you
   * have to store lots of objects in this list.
   */
  public HashedMemoryTaskList(boolean sequentialAccess, int initialCapacity) {
    this.sequentialAccess = sequentialAccess;
    this.hashset = new HashSet(initialCapacity);
  }
View Full Code Here


    m_CurrentCol         = -1;
    m_LastSearch         = "";
    m_LastReplace        = "";
    m_ShowAttributeIndex = true;
    m_Changed            = false;
    m_ChangeListeners    = new HashSet();
  }
View Full Code Here

            if (links == null) {
              links = htmlDoc.getLinks();
              doc.setLinks(links);
            }
            if (duplicate == null) {
              HashSet checkedLinks = new HashSet();
              for (int i = 0; i < links.size(); i++) {
                URL link = (URL) links.elementAt(i);
                log.info("Link: "+link);
                // check already here for duplicate links to avoid expensive
                // creation of RobotTasks
                if (!checkedLinks.contains(link)) {
                  checkedLinks.add(link);
                  String myReferer = u.toString();
                  if (u.getUserInfo() != null) {
                    // remove userinfo from referer
                    int endindex = myReferer.indexOf("@")+1;
                    myReferer = "http://"+ myReferer.substring(endindex);
View Full Code Here

   * performs some initialization
   */
  private ArffTableModel() {
    super();
   
    m_Listeners           = new HashSet();
    m_Data                = null;
    m_NotificationEnabled = true;
    m_UndoList            = new Vector();
    m_IgnoreChanges       = false;
    m_UndoEnabled         = true;
View Full Code Here

    protected void shutdown() {}

    public void run() {
      Message msg = null;
      Set servers = new HashSet();
      try {
        try {
          nos = new NetworkOutputStream();
        } catch (IOException exc) {
          logmon.log(BasicLevel.FATAL, getName() + ", cannot start.");
          return;
        }

        while (running) {
          canStop = true;
          try {
            if (this.logmon.isLoggable(BasicLevel.DEBUG))
              this.logmon.log(BasicLevel.DEBUG, this.getName() + ", waiting message");
            msg = qout.get(WDActivationPeriod);
          } catch (InterruptedException exc) {
            if (this.logmon.isLoggable(BasicLevel.DEBUG))
              this.logmon.log(BasicLevel.DEBUG, this.getName() + ", interrupted");
            continue;
          }
          canStop = false;
          if (! running) break;

          if (msg != null) {
            sendList.addMessage(msg);
            qout.pop();
          }
          long currentTimeMillis = System.currentTimeMillis();
          ServerDesc server = null;

          Iterator iterator = sendList.toSendIterator();

          while (iterator.hasNext()) {
            msg = (Message) iterator.next();
            short msgto = msg.getDest();

            if (this.logmon.isLoggable(BasicLevel.DEBUG))
              this.logmon.log(BasicLevel.DEBUG,
                              this.getName() +
                              ", check msg#" + msg.getStamp() +
                              " from " + msg.from +
                              " to " + msg.to);

            if (msg.not.expiration > 0L && msg.not.expiration < currentTimeMillis) {
             
              // Remove the message.
              AgentServer.getTransaction().begin();

              if (msg.not.deadNotificationAgentId != null) {
                if (logmon.isLoggable(BasicLevel.DEBUG)) {
                  logmon.log(BasicLevel.DEBUG, getName() + ": forward expired notification " + msg.from
                      + ", " + msg.not + " to " + msg.not.deadNotificationAgentId);
                }
                ExpiredNot expiredNot = new ExpiredNot(msg.not, msg.from, msg.to);
                Channel.post(Message.alloc(AgentId.localId, msg.not.deadNotificationAgentId, expiredNot));
                Channel.validate();
              } else {
                if (logmon.isLoggable(BasicLevel.DEBUG)) {
                  logmon.log(BasicLevel.DEBUG, getName() + ": removes expired notification " + msg.from + ", "
                      + msg.not);
                }
              }

              // Deletes the processed notification
              iterator.remove();
    // AF: A reprendre.
//               // send ack in JGroups to delete msg
//               if (jgroups != null)
//                 jgroups.send(new JGroupsAckMsg(msg));
              msg.delete();
              msg.free();
              AgentServer.getTransaction().commit(true);
              continue;
            }

            try {
              server = AgentServer.getServerDesc(msgto);
            } catch (UnknownServerException exc) {
              this.logmon.log(BasicLevel.ERROR,
                              this.getName() + ", can't send message: " + msg,
                              exc);
              // Remove the message, may be we have to post an error
              // notification to sender.
              AgentServer.getTransaction().begin();
              // Deletes the processed notification
              iterator.remove();
    // AF: A reprendre.
//              // send ack in JGroups to delete msg
//               if (jgroups != null)
//                 jgroups.send(new JGroupsAckMsg(msg));
              msg.delete();
              msg.free();
              AgentServer.getTransaction().commit(true);
              continue;
            }

            if (servers.contains(server)) {
              // The server has already been tested during this round
              continue;
            }

            this.logmon.log(BasicLevel.DEBUG,
                            this.getName() + server.active + ',' +
                            server.retry + ',' +
                            server.last + ',' +
                            currentTimeMillis);

            if ((server.active) ||
                ((server.retry < WDNbRetryLevel1) &&
                 ((server.last + WDRetryPeriod1) < currentTimeMillis)) ||
                ((server.retry < WDNbRetryLevel2) &&
                 ((server.last + WDRetryPeriod2) < currentTimeMillis)) ||
                ((server.last + WDRetryPeriod3) < currentTimeMillis)) {
              try {
                if (this.logmon.isLoggable(BasicLevel.DEBUG))
                  this.logmon.log(BasicLevel.DEBUG,
                                  this.getName() +
                                  ", send msg#" + msg.getStamp());

                // Open the connection.
                Socket socket = createSocket(server);
                // The connection is ok, reset active and retry flags.
                server.active = true;
                server.retry = 0;
                server.last = currentTimeMillis;

                setSocketOption(socket);

                send(socket, msg, currentTimeMillis);
              } catch (SocketException exc) {
                if (this.logmon.isLoggable(BasicLevel.WARN))
                  this.logmon.log(BasicLevel.WARN,
                                  this.getName() + ", let msg in watchdog list",
                                  exc);
                server.active = false;
                server.retry++;
                server.last = currentTimeMillis;
               
                // Do not send following messages to this server
                servers.add(server);
                //  There is a connection problem, let the message in the
                // waiting list.
                continue;
              } catch (Exception exc) {
                this.logmon.log(BasicLevel.ERROR,
                                this.getName() + ", error", exc);
              }

              AgentServer.getTransaction().begin();
              //  Deletes the processed notification
              iterator.remove();
// AF (TODO): To remove ?
//               // send ack in JGroups to delete msg
//               if (jgroups != null)
//                 jgroups.send(new JGroupsAckMsg(msg));
              msg.delete();
              msg.free();
              AgentServer.getTransaction().commit(true);
            } else {
              // Do not send following messages to this server
              servers.add(server);
            }
          }
          servers.clear();
        }
      } catch (Exception exc) {
        this.logmon.log(BasicLevel.FATAL,
                        this.getName() + ", unrecoverable exception", exc);
        //  There is an unrecoverable exception during the transaction
View Full Code Here

     * Checks that only one {@link TransportOptionsDefinition} instance exists for each
     * {@link TransportOptionsDefinition} class.
     */
    private void checkForDuplicateTransportOptionDefinitions() {
        if (m_transportOptDefs != null) {
            Set definedOptions = new HashSet();
            for (Iterator iterator = m_transportOptDefs.iterator(); iterator.hasNext();) {
                TransportOptionsDefinition def = (TransportOptionsDefinition) iterator.next();
                String type = def.getClass().getName();
                if (definedOptions.contains(type)) {
                    throw new IllegalArgumentException("Duplicate transport options definition of type " + type);
                }
                definedOptions.add(type);
            }
        }
    }
View Full Code Here

      }

      //===== SPEW in the dates that are added by using a BYxyz of lower
      //===== magnitude than the frequency

      HashSet resultSet = new HashSet();

      for ( int pdCtr = protoDateList.size()-1 ; pdCtr>=0 ; pdCtr-- ){
        Calendar curProtoDate = (Calendar)protoDateList.get(pdCtr);

        HashSet resultPile = new HashSet();
        resultPile.add(curProtoDate);

        // BYMONTH
        if ( freqNumber > Constants.FREQ_MONTHLY ){
          resultPile = breedMetaSet(resultPile,Calendar.MONTH,monthSet);
        }
View Full Code Here

  /***
  split a list into validated numbers
  ***/
  private HashSet getNumberSet(String list, int low, int high, String key)
  {
    HashSet result = new HashSet();
    StringTokenizer stk = new StringTokenizer(list,",");
    while ( stk.hasMoreTokens() ){
      int cur = Integer.parseInt(stk.nextToken());
      //--- be in range
      if ( cur<low || cur>high ){
        throw new IllegalArgumentException("ERROR: invalid integer list: "+key);
      }
      //--- if low != 0 then 0 is disallowed
      if ( low!=0 && cur==0 ){
        throw new IllegalArgumentException("ERROR: zero is not allowed in "+key);
      }
      result.add( new Integer(cur) );
    }
    return result;
  }
View Full Code Here

  /***
  Use this for getting months, when the user gives it to you 1 based, but java wants it 0 based.
  ***/
  private HashSet getNumberSetHoldTheEvil(String list, int low, int high, String key)
  {
    HashSet old = getNumberSet(list, low, high, key);
    HashSet result = new HashSet();

    for ( Iterator it = old.iterator();it.hasNext(); ){
      result.add( new Integer( ((Integer)it.next()).intValue()-1 ) );
    }

    return result;

  }
View Full Code Here

  /***
  split a list into validated ByDay objects
  ***/
  private HashSet getWeekDaySet(String list)
  {
    HashSet result = new HashSet();
    StringTokenizer stk = new StringTokenizer(list,",");
    while ( stk.hasMoreTokens() ){
      ByDay bd = new ByDay(stk.nextToken());
      if ( bd.count != 0 &&
           !( "MONTHLY".equals(freq) || "YEARLY".equals(freq) ) ) {
        throw new IllegalArgumentException("  ERROR: You can only specify a number with a week day in the YEARLY or MONTHLY frequencies.");
      }
      result.add( bd );
    }
    return result;
  }
View Full Code Here

TOP

Related Classes of java.util.HashSet

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.