/** * Parses the next token from this String. <p> * * Clients sit in a loop calling next() to parse successive * tokens until an EOF Token is returned. * * @return the next Token * @exception ParseException if the parse fails */ public Token next() throws ParseException { return next('\0', false); }
/** * Parses the next token from this String. <p> * * Clients sit in a loop calling next() to parse successive * tokens until an EOF Token is returned. * * @return the next Token * @exception ParseException if the parse fails */ public Token next() throws ParseException { return next('\0', false); }
/** * Parses the next token from this String. * If endOfAtom is not NUL, the token extends until the * endOfAtom character is seen, or to the end of the header. * This method is useful when parsing headers that don't * obey the MIME specification, e.g., by failing to quote * parameter values that contain spaces. * * @param endOfAtom if not NUL, character marking end of token * @return the next Token * @exception ParseException if the parse fails * @since JavaMail 1.5 */ public Token next(char endOfAtom) throws ParseException { return next(endOfAtom, false); }
/** * Parses the next token from this String. * If endOfAtom is not NUL, the token extends until the * endOfAtom character is seen, or to the end of the header. * This method is useful when parsing headers that don't * obey the MIME specification, e.g., by failing to quote * parameter values that contain spaces. * * @param endOfAtom if not NUL, character marking end of token * @return the next Token * @exception ParseException if the parse fails * @since JavaMail 1.5 */ public Token next(char endOfAtom) throws ParseException { return next(endOfAtom, false); }
static String getEncoding(MimePart part) throws MessagingException { String s = part.getHeader("Content-Transfer-Encoding", null); if (s == null) return null; s = s.trim(); // get rid of trailing spaces if (s.length() == 0) return null; // quick check for known values to avoid unnecessary use // of tokenizer. if (s.equalsIgnoreCase("7bit") || s.equalsIgnoreCase("8bit") || s.equalsIgnoreCase("quoted-printable") || s.equalsIgnoreCase("binary") || s.equalsIgnoreCase("base64")) return s; // Tokenize the header to obtain the encoding (skip comments) HeaderTokenizer h = new HeaderTokenizer(s, HeaderTokenizer.MIME); HeaderTokenizer.Token tk; int tkType; for (;;) { tk = h.next(); // get a token tkType = tk.getType(); if (tkType == HeaderTokenizer.Token.EOF) break; // done else if (tkType == HeaderTokenizer.Token.ATOM) return tk.getValue(); else // invalid token, skip it. continue; } return s; }
static String[] getContentLanguage(MimePart part) throws MessagingException { String s = part.getHeader("Content-Language", null); if (s == null) return null; // Tokenize the header to obtain the Language-tags (skip comments) HeaderTokenizer h = new HeaderTokenizer(s, HeaderTokenizer.MIME); List<String> v = new ArrayList<>(); HeaderTokenizer.Token tk; int tkType; while (true) { tk = h.next(); // get a language-tag tkType = tk.getType(); if (tkType == HeaderTokenizer.Token.EOF) break; // done else if (tkType == HeaderTokenizer.Token.ATOM) v.add(tk.getValue()); else // invalid token, skip it. continue; } if (v.isEmpty()) return null; String[] language = new String[v.size()]; v.toArray(language); return language; }
static String[] getContentLanguage(MimePart part) throws MessagingException { String s = part.getHeader("Content-Language", null); if (s == null) return null; // Tokenize the header to obtain the Language-tags (skip comments) HeaderTokenizer h = new HeaderTokenizer(s, HeaderTokenizer.MIME); List<String> v = new ArrayList<String>(); HeaderTokenizer.Token tk; int tkType; while (true) { tk = h.next(); // get a language-tag tkType = tk.getType(); if (tkType == HeaderTokenizer.Token.EOF) break; // done else if (tkType == HeaderTokenizer.Token.ATOM) v.add(tk.getValue()); else // invalid token, skip it. continue; } if (v.isEmpty()) return null; String[] language = new String[v.size()]; v.toArray(language); return language; }
static String getEncoding(MimePart part) throws MessagingException { String s = part.getHeader("Content-Transfer-Encoding", null); if (s == null) return null; s = s.trim(); // get rid of trailing spaces // quick check for known values to avoid unnecessary use // of tokenizer. if (s.equalsIgnoreCase("7bit") || s.equalsIgnoreCase("8bit") || s.equalsIgnoreCase("quoted-printable") || s.equalsIgnoreCase("binary") || s.equalsIgnoreCase("base64")) return s; // Tokenize the header to obtain the encoding (skip comments) HeaderTokenizer h = new HeaderTokenizer(s, HeaderTokenizer.MIME); HeaderTokenizer.Token tk; int tkType; for (;;) { tk = h.next(); // get a token tkType = tk.getType(); if (tkType == HeaderTokenizer.Token.EOF) break; // done else if (tkType == HeaderTokenizer.Token.ATOM) return tk.getValue(); else // invalid token, skip it. continue; } return s; }
HeaderTokenizer.Token tk = h.next(); int type = tk.getType(); String name, value; tk = h.next(); tk = h.next(); if ((char)tk.getType() != '=') throw new ParseException("In parameter list <" + s + ">" + tk = h.next(';', true); else if (parametersStrict) tk = h.next(); else tk = h.next(';'); type = tk.getType();
HeaderTokenizer.Token tk = h.next(); int type = tk.getType(); String name, value; tk = h.next(); tk = h.next(); if ((char)tk.getType() != '=') throw new ParseException("In parameter list <" + s + ">" + tk = h.next(';', true); else if (parametersStrict) tk = h.next(); else tk = h.next(';'); type = tk.getType();
tk = h.next(); if (tk.getType() != HeaderTokenizer.Token.ATOM) throw new ParseException("In Content-Type string <" + s + ">" + tk = h.next(); if ((char)tk.getType() != '/') throw new ParseException("In Content-Type string <" + s + ">" + tk = h.next(); if (tk.getType() != HeaderTokenizer.Token.ATOM) throw new ParseException("In Content-Type string <" + s + ">" +
tk = h.next(); if (tk.getType() != HeaderTokenizer.Token.ATOM) throw new ParseException("In Content-Type string <" + s + ">" + tk = h.next(); if ((char)tk.getType() != '/') throw new ParseException("In Content-Type string <" + s + ">" + tk = h.next(); if (tk.getType() != HeaderTokenizer.Token.ATOM) throw new ParseException("In Content-Type string <" + s + ">" +
/** * Parses the next token from this String. <p> * * Clients sit in a loop calling next() to parse successive * tokens until an EOF Token is returned. * * @return the next Token * @exception ParseException if the parse fails */ public Token next() throws ParseException { return next('\0', false); }
/** * Constructor that takes a ContentDisposition string. The String * is parsed into its constituents: dispostion and parameters. * A ParseException is thrown if the parse fails. * * @param s the ContentDisposition string. * @exception ParseException if the parse fails. * @since JavaMail 1.2 */ public ContentDisposition(String s) throws ParseException { HeaderTokenizer h = new HeaderTokenizer(s, HeaderTokenizer.MIME); HeaderTokenizer.Token tk; // First "disposition" .. tk = h.next(); if (tk.getType() != HeaderTokenizer.Token.ATOM) throw new ParseException("Expected disposition, got " + tk.getValue()); disposition = tk.getValue(); // Then parameters .. String rem = h.getRemainder(); if (rem != null) list = new ParameterList(rem); }
/** * Parses the next token from this String. <p> * * Clients sit in a loop calling next() to parse successive * tokens until an EOF Token is returned. * * @return the next Token * @exception ParseException if the parse fails */ public Token next() throws ParseException { return next('\0', false); }
/** * Parses the next token from this String. <p> * * Clients sit in a loop calling next() to parse successive * tokens until an EOF Token is returned. * * @return the next Token * @exception ParseException if the parse fails */ public Token next() throws ParseException { return next('\0', false); }
/** * Parses the next token from this String. <p> * * Clients sit in a loop calling next() to parse successive * tokens until an EOF Token is returned. * * @return the next Token * @exception ParseException if the parse fails */ public Token next() throws ParseException { return next('\0', false); }
/** * Parses the next token from this String. <p> * * Clients sit in a loop calling next() to parse successive * tokens until an EOF Token is returned. * * @return the next Token * @exception ParseException if the parse fails */ public Token next() throws ParseException { return next('\0', false); }
/** * Parses the next token from this String. <p> * * Clients sit in a loop calling next() to parse successive * tokens until an EOF Token is returned. * * @return the next Token * @exception ParseException if the parse fails */ public Token next() throws ParseException { return next('\0', false); }
tk = h.next(); if (tk.getType() != HeaderTokenizer.Token.ATOM) { if (contentDispositionStrict) {