@Override public SearchTerm build() { final List<IdRange> uidSetList = IdRange.parseRangeSequence(getParameter(0)); return new UidSearchTerm(uidSetList); } };
@Override public SearchTerm build() { final List<IdRange> idRanges = IdRange.parseRangeSequence(getParameter(0)); return new MessageNumberSearchTerm(idRanges); } };
/** * Reads a command "tag" from the request. */ public String tag(ImapRequestLineReader request) throws ProtocolException { CharacterValidator validator = new TagCharValidator(); return consumeWord(request, validator); }
// we just want the unseen mails which is not spam SearchTermBuilder builder = new SearchTermBuilder(); builder.unseen().body(Op.not, "Spam").subject(Op.not, "Spam") // which was sent from either foo or bar .from("foo@somewhere.com").from(Op.or, "bar@somewhere.com"); // .. and we could continue building the terms SearchTerm term = builder.build();
FetchRequest fetchRequest(ImapRequestLineReader request) throws ProtocolException { FetchRequest fetch = new FetchRequest(); // Parenthesis optional if single 'atom' char next = nextNonSpaceChar(request); boolean parenthesis = '(' == next; if (parenthesis) { consumeChar(request, '('); next = nextNonSpaceChar(request); while (next != ')') { addNextElement(request, fetch); next = nextNonSpaceChar(request); } consumeChar(request, ')'); } else { // Single item addNextElement(request, fetch); } return fetch; }
private Partial parsePartial(ImapRequestLineReader command) throws ProtocolException { consumeChar(command, '<'); int size = (int) consumeLong(command); // Assume <start> int start = 0; if (command.nextChar() == '.') { consumeChar(command, '.'); start = size; // Assume <start.size> , so switch fields size = (int) consumeLong(command); } consumeChar(command, '>'); return Partial.as(start, size); }
@Override protected void doProcess(ImapRequestLineReader request, ImapResponse response, ImapSession session) throws ProtocolException, FolderException { String commandName = parser.atom(request); ImapCommand command = commandFactory.getCommand(commandName); if (command == null || !(command instanceof UidEnabledCommand)) { throw new ProtocolException("Invalid UID command: '" + commandName + "'"); } ((UidEnabledCommand) command).doProcess(request, response, session, true); }
@Override public boolean isValid(char chr) { return isCHAR(chr) && !isAtomSpecial(chr) && !isListWildcard(chr) && !isQuotedSpecial(chr); }
/** * Reads an argument of type "atom" from the request. */ public String atom(ImapRequestLineReader request) throws ProtocolException { return consumeWord(request, new AtomCharValidator()); }
@Override public boolean isValid(char chr) { return isListWildcard(chr) || super.isValid(chr); } }
public static String uidsToRangeString(List<Long> uids) { return idRangesToString(convertUidsToIdRangeArray(uids)); }
/** * Reads an argument of type "number" from the request. */ public long number(ImapRequestLineReader request) throws ProtocolException { String digits = consumeWord(request, new DigitCharValidator()); return Long.parseLong(digits); }
protected boolean includes(IdRange[] idSet, long id) { for (IdRange idRange : idSet) { if (idRange.includes(id)) { return true; } } return false; } }
/** * @see CommandTemplate#doProcess */ @Override protected void doProcess(ImapRequestLineReader request, final ImapResponse response, ImapSession session) throws ProtocolException, FolderException { doProcess(request, response, session, false); }
public static Partial as(int start, int size) { Partial p = new Partial(); p.start = start; p.size = size; return p; } }
@Override public SearchTerm build() { return createFlagSearchTerm(getParameter(0), pKey == SearchKey.KEYWORD); } };
@Override public boolean isValid(char chr) { return chr != '+' && super.isValid(chr); } }
boolean isCharsetAware() { return key.isCharsetAware(); }
/** * Matches id against sequence numbers. * * @param id the identifier * @return true, if matching */ public boolean match(final long id) { for (IdRange idRange : idRanges) { if (idRange.includes(id)) { return true; } } return false; } }