コード例 #1
0
  public static void main(String[] args) throws MessagingException, IOException {
    IMAPFolder folder = null;
    Store store = null;
    String subject = null;
    Flag flag = null;
    try {
      Properties props = System.getProperties();
      props.setProperty("mail.store.protocol", "imaps");
      props.setProperty("mail.imap.host", "imap.googlemail.com");
      SimpleAuthenticator authenticator =
          new SimpleAuthenticator("*****@*****.**", "hhy8611hhyy");
      Session session = Session.getDefaultInstance(props, null);
      // Session session = Session.getDefaultInstance(props, authenticator);

      store = session.getStore("imaps");
      //          store.connect("imap.googlemail.com","*****@*****.**", "hhy8611hhyy");
      // store.connect("imap.googlemail.com","*****@*****.**", "hhy8611hhyy");

      store.connect("*****@*****.**", "hhy8611hhy");
      // folder = (IMAPFolder) store.getFolder("[Gmail]/Spam"); // This doesn't work for other email
      // account
      folder = (IMAPFolder) store.getFolder("inbox"); // This works for both email account

      if (!folder.isOpen()) folder.open(Folder.READ_WRITE);
      Message[] messages = messages = folder.getMessages(150, 150); // folder.getMessages();
      System.out.println("No of get Messages : " + messages.length);
      System.out.println("No of Messages : " + folder.getMessageCount());
      System.out.println("No of Unread Messages : " + folder.getUnreadMessageCount());
      System.out.println("No of New Messages : " + folder.getNewMessageCount());
      System.out.println(messages.length);
      for (int i = 0; i < messages.length; i++) {

        System.out.println(
            "*****************************************************************************");
        System.out.println("MESSAGE " + (i + 1) + ":");
        Message msg = messages[i];
        // System.out.println(msg.getMessageNumber());
        // Object String;
        // System.out.println(folder.getUID(msg)

        subject = msg.getSubject();

        System.out.println("Subject: " + subject);
        System.out.println("From: " + msg.getFrom()[0]);
        System.out.println("To: " + msg.getAllRecipients()[0]);
        System.out.println("Date: " + msg.getReceivedDate());
        System.out.println("Size: " + msg.getSize());
        System.out.println(msg.getFlags());
        System.out.println("Body: \n" + msg.getContent());
        System.out.println(msg.getContentType());
      }
    } finally {
      if (folder != null && folder.isOpen()) {
        folder.close(true);
      }
      if (store != null) {
        store.close();
      }
    }
  }
コード例 #2
0
 /**
  * expand super types after scanning, for super types that were not scanned. this is helpful in
  * finding the transitive closure without scanning all 3rd party dependencies. it uses {@link
  * ReflectionUtils#getSuperTypes(Class)}.
  *
  * <p>for example, for classes A,B,C where A supertype of B, B supertype of C:
  *
  * <ul>
  *   <li>if scanning C resulted in B (B->C in store), but A was not scanned (although A supertype
  *       of B) - then getSubTypes(A) will not return C
  *   <li>if expanding supertypes, B will be expanded with A (A->B in store) - then getSubTypes(A)
  *       will return C
  * </ul>
  */
 public void expandSuperTypes() {
   if (store.keySet().contains(index(SubTypesScanner.class))) {
     Multimap<String, String> mmap = store.get(index(SubTypesScanner.class));
     Sets.SetView<String> keys = Sets.difference(mmap.keySet(), Sets.newHashSet(mmap.values()));
     Multimap<String, String> expand = HashMultimap.create();
     for (String key : keys) {
       expandSupertypes(expand, key, forName(key));
     }
     mmap.putAll(expand);
   }
 }
コード例 #3
0
 /**
  * get all fields annotated with a given annotation
  *
  * <p>depends on FieldAnnotationsScanner configured
  */
 public Set<Field> getFieldsAnnotatedWith(final Class<? extends Annotation> annotation) {
   final Set<Field> result = Sets.newHashSet();
   for (String annotated : store.get(index(FieldAnnotationsScanner.class), annotation.getName())) {
     result.add(getFieldFromString(annotated, loaders()));
   }
   return result;
 }
コード例 #4
0
 /**
  * get parameter names of given {@code constructor}
  *
  * <p>depends on MethodParameterNamesScanner configured
  */
 public List<String> getConstructorParamNames(Constructor constructor) {
   Iterable<String> names =
       store.get(index(MethodParameterNamesScanner.class), Utils.name(constructor));
   return !Iterables.isEmpty(names)
       ? Arrays.asList(Iterables.getOnlyElement(names).split(", "))
       : Arrays.<String>asList();
 }
コード例 #5
0
 /**
  * Send the user's startup plugin
  *
  * @param source the user
  */
 private void getStartupPlugin(ObjectConnection oc, String source) {
   try {
     UserConcept user = store.getUserStore().getUser(source);
     oc.write(user.getStartupPlugin());
   } catch (Exception e) {
   }
 }
コード例 #6
0
  /**
   * collect saved Reflections resources from all urls that contains the given packagePrefix and
   * matches the given resourceNameFilter and de-serializes them using the default serializer {@link
   * org.reflections.serializers.XmlSerializer} or using the optionally supplied optionalSerializer
   *
   * <p>it is preferred to use a designated resource prefix (for example META-INF/reflections but
   * not just META-INF), so that relevant urls could be found much faster
   *
   * @param optionalSerializer - optionally supply one serializer instance. if not specified or
   *     null, {@link org.reflections.serializers.XmlSerializer} will be used
   */
  public static Reflections collect(
      final String packagePrefix,
      final Predicate<String> resourceNameFilter,
      @Nullable Serializer... optionalSerializer) {
    Serializer serializer =
        optionalSerializer != null && optionalSerializer.length == 1
            ? optionalSerializer[0]
            : new XmlSerializer();

    Collection<URL> urls = ClasspathHelper.forPackage(packagePrefix);
    if (urls.isEmpty()) return null;
    long start = System.currentTimeMillis();
    final Reflections reflections = new Reflections();
    Iterable<Vfs.File> files = Vfs.findFiles(urls, packagePrefix, resourceNameFilter);
    for (final Vfs.File file : files) {
      InputStream inputStream = null;
      try {
        inputStream = file.openInputStream();
        reflections.merge(serializer.read(inputStream));
      } catch (IOException e) {
        throw new ReflectionsException("could not merge " + file, e);
      } finally {
        close(inputStream);
      }
    }

    if (log != null) {
      Store store = reflections.getStore();
      int keys = 0;
      int values = 0;
      for (String index : store.keySet()) {
        keys += store.get(index).keySet().size();
        values += store.get(index).size();
      }

      log.info(
          format(
              "Reflections took %d ms to collect %d url%s, producing %d keys and %d values [%s]",
              System.currentTimeMillis() - start,
              urls.size(),
              urls.size() > 1 ? "s" : "",
              keys,
              values,
              Joiner.on(", ").join(urls)));
    }
    return reflections;
  }
コード例 #7
0
  public List<MailInfo> receive() throws Exception {

    // TODO: externalize ....
    // mail server connection parameters
    // String host = "SSL0.OVH.NET";
    // String user = "******";
    // String password = "******";

    String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
    Properties pop3Props = new Properties();
    pop3Props.setProperty("mail.pop3.socketFactory.class", SSL_FACTORY);
    pop3Props.setProperty("mail.pop3.socketFactory.fallback", "false");
    pop3Props.setProperty("mail.pop3.port", port);
    pop3Props.setProperty("mail.pop3.socketFactory.port", port);

    URLName url = new URLName("pop3", host, Integer.parseInt(port), "", user, password);

    Session session = Session.getInstance(pop3Props, null);
    Store store = new POP3SSLStore(session, url);
    store.connect();

    Folder inbox = store.getFolder("Inbox");
    inbox.open(Folder.READ_WRITE);

    // get the list of inbox messages
    Message[] messages = inbox.getMessages();

    if (messages.length == 0) log.info("No messages found.");

    List<MailInfo> mails = new ArrayList<>();

    for (int i = 0; i < messages.length; i++) {
      MailInfo mail = new MailInfo();
      writePart(messages[i], mail);

      mails.add(mail);

      // TO REACTIVATE ...
      messages[i].setFlag(Flags.Flag.DELETED, true);
    }

    inbox.close(true);
    store.close();

    return mails;
  }
コード例 #8
0
 /**
  * get types annotated with a given annotation, both classes and annotations
  *
  * <p>{@link java.lang.annotation.Inherited} is honored according to given honorInherited.
  *
  * <p>when honoring @Inherited, meta-annotation should only effect annotated super classes and
  * it's sub types
  *
  * <p>when not honoring @Inherited, meta annotation effects all subtypes, including annotations
  * interfaces and classes
  *
  * <p><i>Note that this (@Inherited) meta-annotation type has no effect if the annotated type is
  * used for anything other then a class. Also, this meta-annotation causes annotations to be
  * inherited only from superclasses; annotations on implemented interfaces have no effect.</i>
  *
  * <p>depends on TypeAnnotationsScanner and SubTypesScanner configured
  */
 public Set<Class<?>> getTypesAnnotatedWith(
     final Class<? extends Annotation> annotation, boolean honorInherited) {
   Iterable<String> annotated =
       store.get(index(TypeAnnotationsScanner.class), annotation.getName());
   Iterable<String> classes =
       getAllAnnotated(annotated, annotation.isAnnotationPresent(Inherited.class), honorInherited);
   return Sets.newHashSet(concat(forNames(annotated, loaders()), forNames(classes, loaders())));
 }
コード例 #9
0
  /** Loads internal services */
  private void loadInternalServices() {
    try {
      Iterator services;
      String servicename;
      String baseURL = System.getProperty("user.dir") + "/" + APPLICATIONS_DIRECTORY;

      LucaneClassLoader loader = LucaneClassLoader.getInstance();
      services = store.getServiceStore().getAllServices();

      while (services.hasNext()) {
        ServiceConcept service = (ServiceConcept) services.next();
        servicename = service.getName();
        try {
          loader.addUrl(new URL("jar:file:///" + baseURL + servicename + ".jar!/"));
          String className =
              (new JarFile(baseURL + servicename + ".jar"))
                  .getManifest()
                  .getMainAttributes()
                  .getValue("Service-Class");

          if (className == null) continue;

          Service serv = (Service) Class.forName(className, true, loader).newInstance();
          this.services.add(serv);
          serv.init(this);

          if (!service.isInstalled()) {
            serv.install();
            service.setInstalled();
            store.getServiceStore().updateService(service);
          }

          Logging.getLogger().info("Service '" + servicename + "' loaded.");
          this.connections.add(
              new ConnectInfo(servicename, serverIp, serverIp, port, "nokey", "service"));
        } catch (Exception e) {
          Logging.getLogger().warning("Unable to load service '" + servicename);
        }
      }
    } catch (Exception e) {
      Logging.getLogger().warning("Unable to load internal services : " + e);
      e.printStackTrace();
    }
  }
コード例 #10
0
 /**
  * get all types scanned. this is effectively similar to getting all subtypes of Object.
  *
  * <p>depends on SubTypesScanner configured with {@code SubTypesScanner(false)}, otherwise {@code
  * ReflectionsException} is thrown
  *
  * <p><i>note using this might be a bad practice. it is better to get types matching some
  * criteria, such as {@link #getSubTypesOf(Class)} or {@link #getTypesAnnotatedWith(Class)}</i>
  *
  * @return Set of String, and not of Class, in order to avoid definition of all types in PermGen
  */
 public Set<String> getAllTypes() {
   Set<String> allTypes =
       Sets.newHashSet(store.getAll(index(SubTypesScanner.class), Object.class.getName()));
   if (allTypes.isEmpty()) {
     throw new ReflectionsException(
         "Couldn't find subtypes of Object. "
             + "Make sure SubTypesScanner initialized to include Object class - new SubTypesScanner(false)");
   }
   return allTypes;
 }
コード例 #11
0
  private Object receiveMail() throws Exception {
    Folder folder = null;
    Store store = null;
    ConfigurationPropertyManager configManager =
        ConfigurationPropertyManager.getConfigurationPropertyManager();
    final String email_address = configManager.getPropValues("gmail_address");
    final String password = configManager.getPropValues("gmail_pw");

    try {
      Properties props = System.getProperties();
      props.setProperty("mail.store.protocol", "imaps");

      // Session session = Session.getDefaultInstance(props, null);
      Session session = Session.getInstance(props, new GMailAuthenticator(email_address, password));
      store = session.getStore("imaps");
      store.connect("imap.gmail.com", email_address, password);
      folder = store.getFolder("Inbox");
      folder.open(Folder.READ_WRITE);
      // Message messages[] = folder.getMessages();
      // search for all "unseen" messages
      Flags seen = new Flags(Flags.Flag.SEEN);
      FlagTerm unseenFlagTerm = new FlagTerm(seen, false);
      Message messages[] = folder.search(unseenFlagTerm);

      for (int i = 0; i < messages.length; i++) {
        folder.getMessage(
            messages[i].getMessageNumber()); // this will mark the retrieved messages as READ	    	
      }
      String s = updateEmailrepository(messages);
      // System.out.println(s);
      StringTerm st = new StringTermImpl(s);
      return st;

    } catch (Exception e) {
      System.out.println(e.toString());
    } finally {
      if (folder != null) {
        folder.close(true);
      }
    }
    return null;
  }
コード例 #12
0
  public static void main(String[] args) throws Throwable {
    String mailbox = null;
    boolean DEBUG = false;

    for (int i = 0; i < args.length; i++) {
      if (args[i].equals("-debug")) {
        DEBUG = true;

      } else if (mailbox == null) {
        mailbox = args[i];

      } else {
        usage("Spurious command line: " + args);
      }
    }

    if (mailbox == null) {
      usage("Missing mailbox");
    }

    // Get a connection to the mail server
    Properties props = new Properties();
    Session session = Session.getDefaultInstance(props, null);
    session.setDebug(DEBUG);

    Provider[] providers = session.getProviders();
    for (int i = 0; i < providers.length; i++) {
      Provider provider = providers[i];
      out.println(provider);
    }

    Store store = session.getStore("imap");
    Folder folder = store.getFolder(mailbox);
    Message[] messages = folder.getMessages();
    out.println("Folder " + folder.getName() + " with " + messages.length + " messages");
    for (int i = 0; i < messages.length; i++) {
      Message message = messages[i];
      out.println("  " + i + ": " + message.getSubject());
    }

    out.println("");
  }
コード例 #13
0
  /**
   * Send the plugin list to a client. The list depends of the client's groups
   *
   * @param source the user that asked this command
   */
  private void sendPluginList(ObjectConnection oc, String source) {
    Vector plist = new Vector();
    Iterator plugins;
    String line = "";

    try {
      UserConcept user = store.getUserStore().getUser(source);
      plugins = store.getPluginStore().getAuthorizedPlugins(user);

      while (plugins.hasNext()) {
        PluginConcept plugin = (PluginConcept) plugins.next();
        line = plugin.getName();
        line += " " + plugin.getVersion();
        plist.add(line);
      }
      oc.write(plist);
    } catch (Exception e) {
      Logging.getLogger().warning("Unable to send the plugin list.");
      e.printStackTrace();
    }
  }
コード例 #14
0
 /**
  * get types annotated with a given annotation, both classes and annotations, including annotation
  * member values matching
  *
  * <p>{@link java.lang.annotation.Inherited} is honored according to given honorInherited
  *
  * <p>depends on TypeAnnotationsScanner configured
  */
 public Set<Class<?>> getTypesAnnotatedWith(final Annotation annotation, boolean honorInherited) {
   Iterable<String> annotated =
       store.get(index(TypeAnnotationsScanner.class), annotation.annotationType().getName());
   Iterable<Class<?>> filter = filter(forNames(annotated, loaders()), withAnnotation(annotation));
   Iterable<String> classes =
       getAllAnnotated(
           names(filter),
           annotation.annotationType().isAnnotationPresent(Inherited.class),
           honorInherited);
   return Sets.newHashSet(
       concat(filter, forNames(filter(classes, not(in(Sets.newHashSet(annotated)))), loaders())));
 }
コード例 #15
0
 /** merges a Reflections instance metadata into this instance */
 public Reflections merge(final Reflections reflections) {
   if (reflections.store != null) {
     for (String indexName : reflections.store.keySet()) {
       Multimap<String, String> index = reflections.store.get(indexName);
       for (String key : index.keySet()) {
         for (String string : index.get(key)) {
           store.getOrCreate(indexName).put(key, string);
         }
       }
     }
   }
   return this;
 }
コード例 #16
0
  public static void main(String args[]) throws Exception {
    // String host = args[0];
    // String username = args[1];
    // String password = args[2];

    String host = "triggeremails.com";
    String username = "******";
    String password = "******";

    // Get session
    Session session = Session.getInstance(System.getProperties(), null);

    // Get the store
    Store store = session.getStore("pop3");
    store.connect(host, username, password);

    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_WRITE);

    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    // Get directory
    Message message[] = folder.getMessages();
    for (int i = 0, n = message.length; i < n; i++) {
      System.out.println(i + ": " + message[i].getFrom()[0] + "\t" + message[i].getSubject());

      System.out.println("Do you want to delete message? [YES to delete]");
      String line = reader.readLine();
      // Mark as deleted if appropriate
      if ("YES".equals(line)) {
        message[i].setFlag(Flags.Flag.DELETED, true);
      }
    }

    // Close connection
    folder.close(true);
    store.close();
  }
コード例 #17
0
  /**
   * constructs a Reflections instance and scan according to given {@link
   * org.reflections.Configuration}
   *
   * <p>it is preferred to use {@link org.reflections.util.ConfigurationBuilder}
   */
  public Reflections(final Configuration configuration) {
    this.configuration = configuration;
    store = new Store(configuration);

    if (configuration.getScanners() != null && !configuration.getScanners().isEmpty()) {
      // inject to scanners
      for (Scanner scanner : configuration.getScanners()) {
        scanner.setConfiguration(configuration);
        scanner.setStore(store.getOrCreate(scanner.getClass().getSimpleName()));
      }

      scan();
    }
  }
コード例 #18
0
 protected Iterable<String> getAllAnnotated(
     Iterable<String> annotated, boolean inherited, boolean honorInherited) {
   if (honorInherited) {
     if (inherited) {
       Iterable<String> subTypes =
           store.get(
               index(SubTypesScanner.class),
               filter(
                   annotated,
                   new Predicate<String>() {
                     public boolean apply(@Nullable String input) {
                       return !ReflectionUtils.forName(input, loaders()).isInterface();
                     }
                   }));
       return concat(subTypes, store.getAll(index(SubTypesScanner.class), subTypes));
     } else {
       return annotated;
     }
   } else {
     Iterable<String> subTypes =
         concat(annotated, store.getAll(index(TypeAnnotationsScanner.class), annotated));
     return concat(subTypes, store.getAll(index(SubTypesScanner.class), subTypes));
   }
 }
コード例 #19
0
 public void paintComponent(Graphics g) { // display
   if (isFirst) {
     myWidth = getWidth();
     myHeight = getHeight();
     define();
     isFirst = false;
   }
   g.clearRect(0, 0, getWidth(), getHeight());
   room.draw(g); // draw map
   store.draw(g); // draw sidebar
   // b.draw(g);
   theMinion.draw(g);
   if (to != null) { // tower selected movement
     to.draw(g, xval, yval, to);
   }
   for (Tower i : tplace) {
     i.draw(g, i);
   }
 }
コード例 #20
0
 /**
  * get all constructors annotated with a given annotation
  *
  * <p>depends on MethodAnnotationsScanner configured
  */
 public Set<Constructor> getConstructorsAnnotatedWith(
     final Class<? extends Annotation> annotation) {
   Iterable<String> methods =
       store.get(index(MethodAnnotationsScanner.class), annotation.getName());
   return getConstructorsFromDescriptors(methods, loaders());
 }
コード例 #21
0
  public static void ClaimsMsgShow(
      java.lang.String argvs[],
      Folder folder,
      Store store,
      biz.systempartners.claims.ClaimsViewer claimsViewer) {
    if (claimsViewer == null) {}

    int msgnum = -1;
    int optind = 0;
    InputStream msgStream = System.in;

    if (argvs != null) {

      for (optind = 0; optind < argvs.length; optind++) {
        if (argvs[optind].equals("-T")) {
          protocol = argvs[++optind];
        } else if (argvs[optind].equals("-H")) {
          host = argvs[++optind];
        } else if (argvs[optind].equals("-U")) {
          user = argvs[++optind];
        } else if (argvs[optind].equals("-P")) {
          password = argvs[++optind];
        } else if (argvs[optind].equals("-v")) {
          verbose = true;
        } else if (argvs[optind].equals("-D")) {
          debug = true;
        } else if (argvs[optind].equals("-f")) {
          mbox = argvs[++optind];
        } else if (argvs[optind].equals("-L")) {
          url = argvs[++optind];
        } else if (argvs[optind].equals("-p")) {
          port = Integer.parseInt(argvs[++optind]);
        } else if (argvs[optind].equals("-s")) {
          showStructure = true;
        } else if (argvs[optind].equals("-S")) {
          saveAttachments = true;
        } else if (argvs[optind].equals("-m")) {
          showMessage = true;
        } else if (argvs[optind].equals("-a")) {
          showAlert = true;
        } else if (argvs[optind].equals("--")) {
          optind++;
          break;
        } else if (argvs[optind].startsWith("-")) {
          System.out.println("Usage: msgshow [-L url] [-T protocol] [-H host] [-p port] [-U user]");
          System.out.println("\t[-P password] [-f mailbox] [msgnum] [-v] [-D] [-s] [-S] [-a]");
          System.out.println("or     msgshow -m [-v] [-D] [-s] [-S] < msg");
          System.exit(1);
        } else {
          break;
        }
      }
    }

    try {
      if (optind < argvs.length) msgnum = Integer.parseInt(argvs[optind]);
      //            msgnum = 1;

      // Get a Properties object
      Properties props = System.getProperties();

      // Get a Session object
      Session session = Session.getInstance(props, null);
      session.setDebug(debug);

      if (showMessage) {
        MimeMessage msg = new MimeMessage(session, msgStream);
        dumpPart(msg, claimsViewer);
        //	System.exit(0);
      }
      /*
                 // Get a Store object
                 Store store = null;
                 if (url != null) {
                     URLName urln = new URLName(url);
                     store = session.getStore(urln);
                     if (showAlert) {
                         store.addStoreListener(new StoreListener() {
                             public void notification(StoreEvent e) {
                                 String s;
                                 if (e.getMessageType() == StoreEvent.ALERT)
                                     s = "ALERT: ";
                                 else
                                     s = "NOTICE: ";
                                 System.out.println(s + e.getMessage());
                             }
                         });
                     }
                     store.connect();
                 } else {
                     if (protocol != null)
                         store = session.getStore(protocol);
                     else
                         store = session.getStore();

                     // Connect
                     if (host != null || user != null || password != null)
                         store.connect(host, port, user, password);
                     else
                         store.connect();
                 }


                 // Open the Folder

                 Folder folder = store.getDefaultFolder();
                 if (folder == null) {
                     System.out.println("No default folder");
                     System.exit(1);
                 }
      */
      //	    folder = folder.getFolder(mbox);
      if (folder == null) {
        System.out.println("Invalid folder");
        System.exit(1);
      }

      // try to open read/write and if that fails try read-only
      try {
        folder.open(Folder.READ_WRITE);
      } catch (MessagingException ex) {
        folder.open(Folder.READ_ONLY);
      }
      int totalMessages = folder.getMessageCount();

      if (totalMessages == 0) {
        System.out.println("Empty folder");
        folder.close(false);
        store.close();
        System.exit(1);
      }

      if (verbose) {
        int newMessages = folder.getNewMessageCount();
        System.out.println("Total messages = " + totalMessages);
        System.out.println("New messages = " + newMessages);
        System.out.println("-------------------------------");
      }

      if (msgnum == -1) {
        // Attributes & Flags for all messages ..
        Message[] msgs = folder.getMessages();

        // Use a suitable FetchProfile
        FetchProfile fp = new FetchProfile();
        fp.add(FetchProfile.Item.ENVELOPE);
        fp.add(FetchProfile.Item.FLAGS);
        fp.add("X-Mailer");
        folder.fetch(msgs, fp);

        for (int i = 0; i < msgs.length; i++) {
          System.out.println("--------------------------");
          System.out.println("MESSAGE #" + (i + 1) + ":");
          dumpEnvelope(msgs[i]);
          // dumpPart(msgs[i]);
        }
      } else {
        Message[] msgs = folder.getMessages();
        for (int n = 0; n < msgs.length; n++) {
          System.out.println("Getting message number: " + n + 1);
          Message m = null;

          try {
            m = folder.getMessage(msgnum + 1);
            // m.setDisposition(
            dumpPart(m, claimsViewer);
            //        m.setExpunged(true);
          } catch (IndexOutOfBoundsException iex) {
            System.out.println("Message number out of range");
          }
        }
        folder.setFlags(msgs, new Flags(Flags.Flag.DELETED), true);
      }
      //            folder.expunge();
      folder.close(true);

      store.close();
    } catch (Exception ex) {
      System.out.println("Oops, got exception! " + ex.getMessage());
      ex.printStackTrace();
      //	    System.exit(1);
    }
    //	System.exit(0);
  }
コード例 #22
0
 /**
  * get all given {@code constructors} usages in methods and constructors
  *
  * <p>depends on MemberUsageScanner configured
  */
 public Set<Member> getConstructorUsage(Constructor constructor) {
   return getMembersFromDescriptors(store.get(index(MemberUsageScanner.class), name(constructor)));
 }
コード例 #23
0
 /**
  * get all given {@code method} usages in methods and constructors
  *
  * <p>depends on MemberUsageScanner configured
  */
 public Set<Member> getMethodUsage(Method method) {
   return getMembersFromDescriptors(store.get(index(MemberUsageScanner.class), name(method)));
 }
コード例 #24
0
 /**
  * get all given {@code field} usages in methods and constructors
  *
  * <p>depends on MemberUsageScanner configured
  */
 public Set<Member> getFieldUsage(Field field) {
   return getMembersFromDescriptors(store.get(index(MemberUsageScanner.class), name(field)));
 }
コード例 #25
0
 /**
  * get parameter names of given {@code method}
  *
  * <p>depends on MethodParameterNamesScanner configured
  */
 public List<String> getMethodParamNames(Method method) {
   Iterable<String> names = store.get(index(MethodParameterNamesScanner.class), name(method));
   return !Iterables.isEmpty(names)
       ? Arrays.asList(Iterables.getOnlyElement(names).split(", "))
       : Arrays.<String>asList();
 }
コード例 #26
0
 /**
  * get resources relative paths where simple name (key) matches given namePredicate
  *
  * <p>depends on ResourcesScanner configured
  */
 public Set<String> getResources(final Predicate<String> namePredicate) {
   Iterable<String> resources =
       Iterables.filter(store.get(index(ResourcesScanner.class)).keySet(), namePredicate);
   return Sets.newHashSet(store.get(index(ResourcesScanner.class), resources));
 }
コード例 #27
0
 /**
  * gets all sub types in hierarchy of a given type
  *
  * <p>depends on SubTypesScanner configured
  */
 public <T> Set<Class<? extends T>> getSubTypesOf(final Class<T> type) {
   return Sets.newHashSet(
       ReflectionUtils.<T>forNames(
           store.getAll(index(SubTypesScanner.class), Arrays.asList(type.getName())), loaders()));
 }
コード例 #28
0
 /** get constructors with any parameter annotated with given annotation */
 public Set<Constructor> getConstructorsWithAnyParamAnnotated(
     Class<? extends Annotation> annotation) {
   return getConstructorsFromDescriptors(
       store.get(index(MethodParameterScanner.class), annotation.getName()), loaders());
 }
コード例 #29
0
 /** get constructors with parameter types matching given {@code types} */
 public Set<Constructor> getConstructorsMatchParams(Class<?>... types) {
   return getConstructorsFromDescriptors(
       store.get(index(MethodParameterScanner.class), names(types).toString()), loaders());
 }
コード例 #30
0
 /** get methods with return type match given type */
 public Set<Method> getMethodsReturn(Class returnType) {
   return getMethodsFromDescriptors(
       store.get(index(MethodParameterScanner.class), names(returnType)), loaders());
 }