/** * Return the first fetch response item of the given class * for the given message number. * * @param r the responses * @param msgno the message number * @param c the class * @param <T> the type of fetch item * @return the fetch item */ public static <T extends Item> T getItem(Response[] r, int msgno, Class<T> c) { if (r == null) return null; for (int i = 0; i < r.length; i++) { if (r[i] == null || !(r[i] instanceof FetchResponse) || ((FetchResponse)r[i]).getNumber() != msgno) continue; FetchResponse f = (FetchResponse)r[i]; for (int j = 0; j < f.items.length; j++) { if (c.isInstance(f.items[j])) return c.cast(f.items[j]); } } return null; }
/** * Return the first fetch response item of the given class * for the given message number. * * @param r the responses * @param msgno the message number * @param c the class * @param <T> the type of fetch item * @return the fetch item */ public static <T extends Item> T getItem(Response[] r, int msgno, Class<T> c) { if (r == null) return null; for (int i = 0; i < r.length; i++) { if (r[i] == null || !(r[i] instanceof FetchResponse) || ((FetchResponse)r[i]).getNumber() != msgno) continue; FetchResponse f = (FetchResponse)r[i]; for (int j = 0; j < f.items.length; j++) { if (c.isInstance(f.items[j])) return c.cast(f.items[j]); } } return null; }
/** * Return all fetch response items of the given class * for the given message number. * * @param r the responses * @param msgno the message number * @param c the class * @param <T> the type of fetch items * @return the list of fetch items * @since JavaMail 1.5.2 */ public static <T extends Item> List<T> getItems(Response[] r, int msgno, Class<T> c) { List<T> items = new ArrayList<T>(); if (r == null) return items; for (int i = 0; i < r.length; i++) { if (r[i] == null || !(r[i] instanceof FetchResponse) || ((FetchResponse)r[i]).getNumber() != msgno) continue; FetchResponse f = (FetchResponse)r[i]; for (int j = 0; j < f.items.length; j++) { if (c.isInstance(f.items[j])) items.add(c.cast(f.items[j])); } } return items; }
/** * Return all fetch response items of the given class * for the given message number. * * @param r the responses * @param msgno the message number * @param c the class * @param <T> the type of fetch items * @return the list of fetch items * @since JavaMail 1.5.2 */ public static <T extends Item> List<T> getItems(Response[] r, int msgno, Class<T> c) { List<T> items = new ArrayList<>(); if (r == null) return items; for (int i = 0; i < r.length; i++) { if (r[i] == null || !(r[i] instanceof FetchResponse) || ((FetchResponse)r[i]).getNumber() != msgno) continue; FetchResponse f = (FetchResponse)r[i]; for (int j = 0; j < f.items.length; j++) { if (c.isInstance(f.items[j])) items.add(c.cast(f.items[j])); } } return items; }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public RFC822SIZE(FetchResponse r) throws ParsingException { msgno = r.getNumber(); r.skipSpaces(); size = r.readNumber(); } }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public UID(FetchResponse r) throws ParsingException { seqnum = r.getNumber(); r.skipSpaces(); uid = r.readLong(); } }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public UID(FetchResponse r) throws ParsingException { seqnum = r.getNumber(); r.skipSpaces(); uid = r.readLong(); } }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public RFC822SIZE(FetchResponse r) throws ParsingException { msgno = r.getNumber(); r.skipSpaces(); size = r.readLong(); } }
/** * Constructor, specifying header flag. * * @param r the FetchResponse * @param isHeader just header information? * @exception ParsingException for parsing failures */ public RFC822DATA(FetchResponse r, boolean isHeader) throws ParsingException { this.isHeader = isHeader; msgno = r.getNumber(); r.skipSpaces(); data = r.readByteArray(); }
/** * Constructor, specifying header flag. * * @param r the FetchResponse * @param isHeader just header information? * @exception ParsingException for parsing failures */ public RFC822DATA(FetchResponse r, boolean isHeader) throws ParsingException { this.isHeader = isHeader; msgno = r.getNumber(); r.skipSpaces(); data = r.readByteArray(); }
v.add(Integer.valueOf(fr.getNumber()));
v.add(Integer.valueOf(fr.getNumber()));
/** * Fetch the FLAGS for the given message. * * @param msgno the message number * @return the Flags * @exception ProtocolException for protocol failures */ public Flags fetchFlags(int msgno) throws ProtocolException { Flags flags = null; Response[] r = fetch(msgno, "FLAGS"); // Search for our FLAGS response for (int i = 0, len = r.length; i < len; i++) { if (r[i] == null || !(r[i] instanceof FetchResponse) || ((FetchResponse)r[i]).getNumber() != msgno) continue; FetchResponse fr = (FetchResponse)r[i]; if ((flags = fr.getItem(FLAGS.class)) != null) { r[i] = null; // remove this response break; } } // dispatch untagged responses notifyResponseHandlers(r); handleResult(r[r.length-1]); return flags; }
/** * Fetch the FLAGS for the given message. * * @param msgno the message number * @return the Flags * @exception ProtocolException for protocol failures */ public Flags fetchFlags(int msgno) throws ProtocolException { Flags flags = null; Response[] r = fetch(msgno, "FLAGS"); // Search for our FLAGS response for (int i = 0, len = r.length; i < len; i++) { if (r[i] == null || !(r[i] instanceof FetchResponse) || ((FetchResponse)r[i]).getNumber() != msgno) continue; FetchResponse fr = (FetchResponse)r[i]; if ((flags = fr.getItem(FLAGS.class)) != null) { r[i] = null; // remove this response break; } } // dispatch untagged responses notifyResponseHandlers(r); handleResult(r[r.length-1]); return flags; }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public INTERNALDATE(FetchResponse r) throws ParsingException { msgno = r.getNumber(); r.skipSpaces(); String s = r.readString(); if (s == null) throw new ParsingException("INTERNALDATE is NIL"); try { synchronized (mailDateFormat) { date = mailDateFormat.parse(s); } } catch (ParseException pex) { throw new ParsingException("INTERNALDATE parse error"); } }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public INTERNALDATE(FetchResponse r) throws ParsingException { msgno = r.getNumber(); r.skipSpaces(); String s = r.readString(); if (s == null) throw new ParsingException("INTERNALDATE is NIL"); try { synchronized (mailDateFormat) { date = mailDateFormat.parse(s); } } catch (ParseException pex) { throw new ParsingException("INTERNALDATE parse error"); } }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public MODSEQ(FetchResponse r) throws ParsingException { seqnum = r.getNumber(); r.skipSpaces(); if (r.readByte() != '(') throw new ParsingException("MODSEQ parse error"); modseq = r.readLong(); if (r.readByte() != ')') throw new ParsingException("MODSEQ parse error"); } }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public MODSEQ(FetchResponse r) throws ParsingException { seqnum = r.getNumber(); r.skipSpaces(); if (r.readByte() != '(') throw new ParsingException("MODSEQ parse error"); modseq = r.readLong(); if (!r.isNextNonSpace(')')) throw new ParsingException("MODSEQ parse error"); } }
/** * Constructor * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public BODY(FetchResponse r) throws ParsingException { msgno = r.getNumber(); r.skipSpaces(); if (r.readByte() != '[') throw new ParsingException( "BODY parse error: missing ``['' at section start"); section = r.readString(']'); if (r.readByte() != ']') throw new ParsingException( "BODY parse error: missing ``]'' at section end"); isHeader = section.regionMatches(true, 0, "HEADER", 0, 6); if (r.readByte() == '<') { // origin origin = r.readNumber(); r.skip(1); // skip '>'; } else origin = 0; data = r.readByteArray(); }
/** * Constructor * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public BODY(FetchResponse r) throws ParsingException { msgno = r.getNumber(); r.skipSpaces(); if (r.readByte() != '[') throw new ParsingException( "BODY parse error: missing ``['' at section start"); section = r.readString(']'); if (r.readByte() != ']') throw new ParsingException( "BODY parse error: missing ``]'' at section end"); isHeader = section.regionMatches(true, 0, "HEADER", 0, 6); if (r.readByte() == '<') { // origin origin = r.readNumber(); r.skip(1); // skip '>'; } else origin = 0; data = r.readByteArray(); }