Example usage for javax.mail Flags remove

List of usage examples for javax.mail Flags remove

Introduction

In this page you can find the example usage for javax.mail Flags remove.

Prototype

public void remove(Flags f) 

Source Link

Document

Remove all flags in the given Flags object from this Flags object.

Usage

From source file:org.apache.james.mailbox.store.StoreMessageManager.java

/**
 * Check if the given {@link Flags} contains {@link Flags} which are not
 * included in the returned {@link Flags} of
 * {@link #getPermanentFlags(MailboxSession)}. If any are found, these are
 * removed from the given {@link Flags} instance. The only exception is the
 * {@link Flag#RECENT} flag.//  w  w w.  j  ava2 s  .c o  m
 * 
 * This flag is never removed!
 * 
 * @param flags
 * @param session
 */
private void trimFlags(Flags flags, MailboxSession session) {

    Flags permFlags = getPermanentFlags(session);

    Flag[] systemFlags = flags.getSystemFlags();
    for (Flag f : systemFlags) {
        if (f != Flag.RECENT && permFlags.contains(f) == false) {
            flags.remove(f);
        }
    }
    // if the permFlags contains the special USER flag we can skip this as
    // all user flags are allowed
    if (permFlags.contains(Flags.Flag.USER) == false) {
        String[] uFlags = flags.getUserFlags();
        for (String uFlag : uFlags) {
            if (permFlags.contains(uFlag) == false) {
                flags.remove(uFlag);
            }
        }
    }

}