Package com.knowgate.debug

Examples of com.knowgate.debug.Chronometer


   */

  public String[] listFolderMessages(String sFolderName)
    throws AuthenticationFailedException,NoSuchProviderException,MessagingException {

  Chronometer oChMeter = null;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin SessionHandler.listFolderMessages("+sFolderName+")");
      DebugFile.incIdent();
      oChMeter = new Chronometer();
    }

    HeadersHelper oHlpr = new HeadersHelper();
    String [] aMsgsXml = null;

    Folder oFldr = getFolder(sFolderName);

  oFldr.open (Folder.READ_ONLY);

  int iDeleted = 0;
  int iTotalCount = oFldr.getMessageCount();

  if (iTotalCount>0) {

      if (DebugFile.trace) DebugFile.writeln("Folder.getMessages("+String.valueOf(iTotalCount)+")");

      Message[] aMsgsObj = oFldr.getMessages();

      FetchProfile oFtchPrfl = new FetchProfile();
      oFtchPrfl.add(FetchProfile.Item.ENVELOPE);
      oFtchPrfl.add(FetchProfile.Item.CONTENT_INFO);
      oFtchPrfl.add(FetchProfile.Item.FLAGS);
      oFtchPrfl.add("X-Priority");
      oFtchPrfl.add("X-Spam-Flag");

      if (DebugFile.trace) {
        DebugFile.writeln("Folder.fetch(Message[], ENVELOPE & CONTENT_INFO & FLAGS)");
        oChMeter.start();
      }

      oFldr.fetch(aMsgsObj, oFtchPrfl);
     
      if (DebugFile.trace) {
        DebugFile.writeln(String.valueOf(iTotalCount)+" headers fetched in "+String.valueOf(oChMeter.stop()/1000l)+" seconds");
        oChMeter.start();
      }
       
      aMsgsXml = new String[iTotalCount];
      for (int m=0; m<iTotalCount; m++) {
        if (aMsgsObj[m].isSet(Flags.Flag.DELETED)) {
          iDeleted++;
        } else {
          oHlpr.setMessage((MimeMessage) aMsgsObj[m]);
          aMsgsXml[m-iDeleted] = oHlpr.toXML();
        } // fi
      } // next (m)
     
      aMsgsObj = null;

    if (iDeleted>0) aMsgsXml = Arrays.copyOfRange(aMsgsXml, 0, iTotalCount-iDeleted);

      if (DebugFile.trace) {
        DebugFile.writeln(String.valueOf(iTotalCount-iDeleted)+" messages to XML in "+String.valueOf(oChMeter.stop())+" ms");
      }

  } // fi (iTotalCount>0)
  oFldr.close(false);

View Full Code Here

TOP

Related Classes of com.knowgate.debug.Chronometer

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.