Package java.util

Examples of java.util.Enumeration


   */
  protected void denyRequest(AgentId from, DenyRequest not) {
    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG, "Queue.DenyRequest(" + from + ',' + not + ')');

    Enumeration ids = not.getIds();

    String msgId;
    Message message;
    AgentId consId;
    int consCtx;
    DMQManager dmqManager = null;

    if (! ids.hasMoreElements()) {
      // If the deny request is empty, the denying is a contextual one: it
      // requests the denying of all the messages consumed by the denier in
      // the denying context:
      for (Iterator entries = deliveredMsgs.entrySet().iterator(); entries.hasNext();) {
        // Browsing the delivered messages:
        Map.Entry entry = (Map.Entry) entries.next();

        msgId = (String) entry.getKey();
        message = (Message) entry.getValue();

        consId = (AgentId) consumers.get(msgId);
        consCtx = ((Integer) contexts.get(msgId)).intValue();

        if (logger.isLoggable(BasicLevel.DEBUG))
          logger.log(BasicLevel.DEBUG, " -> deny msg " + msgId + "(consId = " + consId + ')');

        // If the current message has been consumed by the denier in the same
        // context: denying it.
        if (consId.equals(from) && consCtx == not.getClientContext()) {
          // state change, so save.
          setSave();
          consumers.remove(msgId);
          contexts.remove(msgId);
          entries.remove();
          message.setRedelivered();

          // If message considered as undeliverable, adding
          // it to the list of dead messages:
          if (isUndeliverable(message)) {
            message.delete();
            if (dmqManager == null)
              dmqManager = new DMQManager(dmqId, getId());
            nbMsgsSentToDMQSinceCreation++;
            dmqManager.addDeadMessage(message.getFullMessage(), MessageErrorConstants.UNDELIVERABLE);
          } else {
            // Else, putting the message back into the deliverables list:
            storeMessageHeader(message);
          }

          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG, "Message " + msgId + " denied.");
        }
      }
    }

    // For a non empty request, browsing the denied messages:
    for (ids = not.getIds(); ids.hasMoreElements();) {
      msgId = (String) ids.nextElement();
      message = (Message) deliveredMsgs.remove(msgId);

      // Message may have already been denied. For example, a proxy may deny
      // a message twice, first when detecting a connection failure - and
      // in that case it sends a contextual denying -, then when receiving
View Full Code Here


        }
        writer.writeEndElement();
    }

    private void addNamespaceDeclarations(Properties namespaces) throws XMLStreamException{
        Enumeration e = namespaces.propertyNames();
        while (e.hasMoreElements()){
            String prefix = (String)e.nextElement();
            String uri = namespaces.getProperty(prefix);
            writer.writeStartElement(MappingNodeConstants.Tags.NAMESPACE_DECLARATION);
            if (!prefix.equals(MappingNodeConstants.DEFAULT_NAMESPACE_PREFIX)){
              writeElement(MappingNodeConstants.Tags.NAMESPACE_DECLARATION_PREFIX, prefix);
            }
View Full Code Here

  protected static ResourceXmlBean getResource(String id) {
    return (ResourceXmlBean) roots.get(id);
  }

  protected static Vector getItems() {
    Enumeration elts = roots.elements();
    Vector retour = new Vector();
    while (elts.hasMoreElements()) {
      retour.add(elts.nextElement());
    }
    return retour;
  }
View Full Code Here

    }
   
    public int hashCode() {
        int code = Integer.MAX_VALUE/45; // "random" value for empty lists
        String paramName = null;
        Enumeration enm = this.getNames();

        while (enm.hasMoreElements()) {
            paramName = (String)enm.nextElement();
            code += paramName.hashCode();
            code += this.get(paramName).hashCode();
        }

        return code;
View Full Code Here

    public String toString() {
        StringBuffer buffer = new StringBuffer();
        buffer.ensureCapacity(parameters.size() * 16);    //    heuristic: 8 characters per field
       
        Enumeration keys = parameters.keys();
        while(keys.hasMoreElements())
        {
            buffer.append("; ");
           
            String key = (String)keys.nextElement();
            buffer.append(key);
            buffer.append('=');
               buffer.append(quote((String)parameters.get(key)));
        }
       
View Full Code Here

  protected static ResourceXmlBean getResource(String id) {
    return (ResourceXmlBean) roots.get(id);
  }

  protected static Vector getItems() {
    Enumeration elts = roots.elements();
    Vector retour = new Vector();
    while (elts.hasMoreElements()) {
      retour.add(elts.nextElement());
    }
    return retour;
  }
View Full Code Here

  static void extract(final File sourceZipFile, File unzipDestinationDirectory) throws IOException {
    // Open Zip file for reading
    ZipFile zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);

    // Create an enumeration of the entries in the zip file
    Enumeration zipFileEntries = zipFile.entries();

    // Process each entry
    while (zipFileEntries.hasMoreElements()) {
      // grab a zip file entry
      ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();

      String currentEntry = entry.getName();

      File destFile = new File(unzipDestinationDirectory, currentEntry);
View Full Code Here

    if ((m_BaseClassifier != null) &&
  (m_BaseClassifier instanceof OptionHandler)) {
      newVector.addElement(new Option("", "", 0, "\nOptions specific to scheme "
              + m_BaseClassifier.getClass().getName()
              + ":"));
      Enumeration enu = ((OptionHandler)m_BaseClassifier).listOptions();

      while (enu.hasMoreElements()) {
        newVector.addElement(enu.nextElement());
      }
    }

    return  newVector.elements();
  }
View Full Code Here

  /**
   * registers all the editors in Weka.
   */
  public static void registerEditors() {
    Properties     props;
    Enumeration   enm;
    String     name;
    String     value;
    Class     baseCls;
    Class    cls;

    if (m_EditorsRegistered)
      return;
   
    System.err.println("---Registering Weka Editors---");
    m_EditorsRegistered = true;

    // load properties
    try {
      props = Utils.readProperties(GUIEDITORS_PROPERTY_FILE);
    }
    catch (Exception e) {
      props = new Properties();
      e.printStackTrace();
    }
   
    enm = props.propertyNames();
    while (enm.hasMoreElements()) {
      name  = enm.nextElement().toString();
      value = props.getProperty(name, "");
     
      registerEditor(name, value);
    }
  }
View Full Code Here

   * the hashtable (with the root element as key)
   */
  public static Hashtable sortClassesByRoot(String classes) {
    Hashtable                 roots;
    Hashtable                 result;
    Enumeration               enm;
    int                       i;
    StringTokenizer           tok;
    String                    clsname;
    Vector                    list;
    HierarchyPropertyParser   hpp;
    String                    separator;
    String                    root;
    String                    tmpStr;
   
    if (classes == null)
      return null;
   
    roots     = new Hashtable();
    hpp       = new HierarchyPropertyParser();
    separator = hpp.getSeperator();
   
    // go over all classnames and store them in the hashtable, with the
    // root element as the key
    tok   = new StringTokenizer(classes, ", ");
    while (tok.hasMoreElements()) {
      clsname = tok.nextToken();
      root    = getRootFromClass(clsname, separator);
      if (root == null)
        continue;
     
      // already stored?
      if (!roots.containsKey(root)) {
        list = new Vector();
        roots.put(root, list);
      }
      else {
        list = (Vector) roots.get(root);
      }
     
      list.add(clsname);
    }
   
    // build result
    result = new Hashtable();
    enm    = roots.keys();
    while (enm.hasMoreElements()) {
      root = (String) enm.nextElement();
      list = (Vector) roots.get(root);
      tmpStr = "";
      for (i = 0; i < list.size(); i++) {
        if (i > 0)
          tmpStr += ",";
View Full Code Here

TOP

Related Classes of java.util.Enumeration

Copyright © 2015 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.