public static String format(Flags flags) {
        StringBuilder buf = new StringBuilder();
        buf.append('(');
        if (flags.contains(Flags.Flag.ANSWERED)) {
            buf.append("\\Answered ");
        }
        if (flags.contains(Flags.Flag.DELETED)) {
            buf.append("\\Deleted ");
        }
        if (flags.contains(Flags.Flag.DRAFT)) {
            buf.append("\\Draft ");
        }
        if (flags.contains(Flags.Flag.FLAGGED)) {
            buf.append("\\Flagged ");
        }
        if (flags.contains(Flags.Flag.RECENT)) {
            buf.append("\\Recent ");
        }
        if (flags.contains(Flags.Flag.SEEN)) {
            buf.append("\\Seen ");
        }
        String[] userFlags = flags.getUserFlags();
        if(null!=userFlags) {
            for(String uf: userFlags) {
                buf.append(uf).append(' ');
            }
        }
        // Remove the trailing space, if necessary.
        if (buf.length() > 1) {
            buf.setLength(buf.length() - 1);
        }
        buf.append(')');
        return buf.toString();
    }
public static String format ( Flags flags ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( '(' ) ; if ( flags . contains ( Flags . Flag . ANSWERED ) ) { buf . append ( "\\Answered " ) ; } if ( flags . contains ( Flags . Flag . DELETED ) ) { buf . append ( "\\Deleted " ) ; } if ( flags . contains ( Flags . Flag . DRAFT ) ) { buf . append ( "\\Draft " ) ; } if ( flags . contains ( Flags . Flag . FLAGGED ) ) { buf . append ( "\\Flagged " ) ; } if ( flags . contains ( Flags . Flag . RECENT ) ) { buf . append ( "\\Recent " ) ; } if ( flags . contains ( Flags . Flag . SEEN ) ) { buf . append ( "\\Seen " ) ; } String [ ] userFlags = flags . getUserFlags ( ) ; if ( null != userFlags ) { for ( String uf : userFlags ) { buf . append ( uf ) . append ( ' ' ) ; } } if ( buf . length ( ) > 1 ) { buf . setLength ( buf . length ( ) - 1 ) ; } buf . append ( ')' ) ; return buf . toString ( ) ; }
Returns IMAP formatted String of MessageFlags for named user