private void parse() { parsed = true; location = null; RawField f = getRawField(); ByteSequence buf = f.getRaw(); int pos = f.getDelimiterIdx() + 1; if (buf == null) { String body = f.getBody(); if (body == null) { return; } buf = ContentUtil.encode(body); pos = 0; } RawFieldParser parser = RawFieldParser.DEFAULT; ParserCursor cursor = new ParserCursor(pos, buf.length()); String token = parser.parseValue(buf, cursor, null); StringBuilder sb = new StringBuilder(token.length()); for (int i = 0; i < token.length(); i++) { char ch = token.charAt(i); if (!CharsetUtil.isWhitespace(ch)) { sb.append(ch); } } this.location = sb.toString(); }
String token1 = parser.parseValue(buf, cursor, DELIM); try { major = Integer.parseInt(token1); cursor.updatePos(cursor.getPos() + 1); String token2 = parser.parseValue(buf, cursor, null); try { minor = Integer.parseInt(token2);
public Mailbox parseMailbox( final ByteSequence buf, final ParserCursor cursor, final BitSet delimiters) { BitSet bitset = RawFieldParser.INIT_BITSET(AT, OPENING_BRACKET); if (delimiters != null) { bitset.or(delimiters); } String openingText = this.parser.parseValue(buf, cursor, bitset); if (cursor.atEnd()) { return createMailbox(openingText); } int pos = cursor.getPos(); char current = (char) (buf.byteAt(pos) & 0xff); if (current == OPENING_BRACKET) { // name <localPart @ domain> form return parseMailboxAddress(openingText, buf, cursor); } else if (current == AT) { // localPart @ domain form cursor.updatePos(pos + 1); String domain = parseDomain(buf, cursor, delimiters); return new Mailbox(null, null, openingText, domain); } else { return createMailbox(openingText); } }
/** * Parses the sequence of bytes containing a field parameter delimited with semicolon into * {@link NameValuePair}. * * @param buf buffer with the sequence of bytes to be parsed * @param cursor defines the bounds and current position of the buffer */ public NameValuePair parseParameter(final ByteSequence buf, final ParserCursor cursor) { String name = parseToken(buf, cursor, EQUAL_OR_SEMICOLON); if (cursor.atEnd()) { return new NameValuePair(name, null); } int delim = buf.byteAt(cursor.getPos()); cursor.updatePos(cursor.getPos() + 1); if (delim == ';') { return new NameValuePair(name, null); } String value = parseValue(buf, cursor, SEMICOLON); if (!cursor.atEnd()) { cursor.updatePos(cursor.getPos() + 1); } return new NameValuePair(name, value); }
bitset.or(delimiters); String openingText = this.parser.parseValue(buf, cursor, bitset); if (cursor.atEnd()) { return createMailbox(openingText);
String localPart = this.parser.parseValue(buf, cursor, AT_AND_CLOSING_BRACKET); if (cursor.atEnd()) { return createMailbox(openingText, domainList, localPart, null);