Package javax.mail.internet

Examples of javax.mail.internet.ParseException


                }
                if (d == ']') {
                    break;
                }
                if (d < '0' || d > '9') {
                    throw new ParseException("Invalid number at position " + (pos + 1));
                }
                snumSB.append(d);
                pos++;
            }
            if (snumSB.toString().length() == 0) {
                throw new ParseException("Number not found at position " + (pos + 1));
            }
            try {
                int snum = Integer.parseInt(snumSB.toString());
                if (snum > 255) {
                    throw new ParseException("Invalid number at position " + (pos + 1));
                }
            } catch (NumberFormatException nfe) {
                throw new ParseException("Invalid number at position " + (pos + 1));
            }
            resultSB.append(snumSB.toString());
            if (address.charAt(pos) == ']') {
                if (octet < 3) {
                    throw new ParseException("End of number reached too quickly at " + (pos + 1));
                } else {
                    break;
                }
            }
            if (address.charAt(pos) == '.') {
                resultSB.append('.');
                pos++;
            }
        }
        if (address.charAt(pos) != ']') {
            throw new ParseException("Did not find closing bracket \"]\" in domain at position " + (pos + 1));
        }
        resultSB.append(']');
        pos++;
        return resultSB.toString();
    }
View Full Code Here


                continue;
            }
            if (ch == '.') {
                break;
            }
            throw new ParseException("Invalid character at " + pos);
        }
        String result = resultSB.toString();
        if (result.startsWith("-") || result.endsWith("-")) {
            throw new ParseException("Domain name cannot begin or end with a hyphen \"-\" at position " + (pos + 1));
        }
        return result;
    }
View Full Code Here

                userSB.append(parseQuotedLocalPart(address));
            } else {
                userSB.append(parseUnquotedLocalPart(address));
            }
            if (userSB.toString().length() == 0) {
                throw new ParseException("No local-part (user account) found at position " + (pos + 1));
            }

            //find @
            if (address.charAt(pos) != '@') {
                throw new ParseException("Did not find @ between local-part and domain at position " + (pos + 1));
            }
            pos++;

            //parse domain
            //<domain> ::=  <element> | <element> "." <domain>
            //<element> ::= <name> | "#" <number> | "[" <dotnum> "]"
            while (true) {
                if (address.charAt(pos) == '#') {
                    hostSB.append(parseNumber(address));
                } else if (address.charAt(pos) == '[') {
                    hostSB.append(parseDotNum(address));
                } else {
                    hostSB.append(parseDomainName(address));
                }
                if (pos >= address.length()) {
                    break;
                }
                if (address.charAt(pos) == '.') {
                    hostSB.append('.');
                    pos++;
                    continue;
                }
                break;
            }

            if (hostSB.toString().length() == 0) {
                throw new ParseException("No domain found at position " + (pos + 1));
            }
        } catch (ArrayIndexOutOfBoundsException aioobe) {
            throw new ParseException("Out of data at position " + (pos + 1));
        }

        user = userSB.toString();
        host = hostSB.toString();
    }
View Full Code Here

                resultSB.append('\\');
                pos++;
                //<x> ::= any one of the 128 ASCII characters (no exceptions)
                char x = address.charAt(pos);
                if (x < 0 || x > 128) {
                    throw new ParseException("Invalid \\ syntaxed character at position " + (pos + 1));
                }
                resultSB.append(x);
                pos++;
            } else {
                //<q> ::= any one of the 128 ASCII characters except <CR>,
                //<LF>, quote ("), or backslash (\)
                char q = address.charAt(pos);
                if (q <= 0 || q == '\n' || q == '\r' || q == '\"' || q == '\\') {
                    throw new ParseException("Unquoted local-part (user account) must be one of the 128 ASCI characters exception <CR>, <LF>, quote (\"), or backslash (\\) at position " + (pos + 1));
                }
                resultSB.append(q);
                pos++;
            }
        }
View Full Code Here

                resultSB.append('\\');
                pos++;
                //<x> ::= any one of the 128 ASCII characters (no exceptions)
                char x = address.charAt(pos);
                if (x < 0 || x > 128) {
                    throw new ParseException("Invalid \\ syntaxed character at position " + (pos + 1));
                }
                resultSB.append(x);
                pos++;
                lastCharDot = false;
            } else if (address.charAt(pos) == '.') {
                resultSB.append('.');
                pos++;
                lastCharDot = true;
            } else if (address.charAt(pos) == '@') {
                //End of local-part
                break;
            } else {
                //<c> ::= any one of the 128 ASCII characters, but not any
                //    <special> or <SP>
                //<special> ::= "<" | ">" | "(" | ")" | "[" | "]" | "\" | "."
                //    | "," | ";" | ":" | "@"  """ | the control
                //    characters (ASCII codes 0 through 31 inclusive and
                //    127)
                //<SP> ::= the space character (ASCII code 32)
                char c = address.charAt(pos);
                if (c <= 31 || c == 127 || c == ' ') {
                    throw new ParseException("Invalid character in local-part (user account) at position " + (pos + 1));
                }
                for (int i = 0; i < SPECIAL.length; i++) {
                    if (c == SPECIAL[i]) {
                        throw new ParseException("Invalid character in local-part (user account) at position " + (pos + 1));
                    }
                }
                resultSB.append(c);
                pos++;
                lastCharDot = false;
            }
        }
        if (lastCharDot) {
            throw new ParseException("local-part (user account) ended with a \".\", which is invalid.");
        }
        return resultSB.toString();
    }
View Full Code Here

            char d = address.charAt(pos);
            if (d == '.') {
                break;
            }
            if (d < '0' || d > '9') {
                throw new ParseException("In domain, did not find a number in # address at position " + (pos + 1));
            }
            resultSB.append(d);
            pos++;
        }
        return resultSB.toString();
View Full Code Here

                }
                if (d == ']') {
                    break;
                }
                if (d < '0' || d > '9') {
                    throw new ParseException("Invalid number at position " + (pos + 1));
                }
                snumSB.append(d);
                pos++;
            }
            if (snumSB.toString().length() == 0) {
                throw new ParseException("Number not found at position " + (pos + 1));
            }
            try {
                int snum = Integer.parseInt(snumSB.toString());
                if (snum > 255) {
                    throw new ParseException("Invalid number at position " + (pos + 1));
                }
            } catch (NumberFormatException nfe) {
                throw new ParseException("Invalid number at position " + (pos + 1));
            }
            resultSB.append(snumSB.toString());
            if (address.charAt(pos) == ']') {
                if (octet < 3) {
                    throw new ParseException("End of number reached too quickly at " + (pos + 1));
                } else {
                    break;
                }
            }
            if (address.charAt(pos) == '.') {
                resultSB.append('.');
                pos++;
            }
        }
        if (address.charAt(pos) != ']') {
            throw new ParseException("Did not find closing bracket \"]\" in domain at position " + (pos + 1));
        }
        resultSB.append(']');
        pos++;
        return resultSB.toString();
    }
View Full Code Here

                continue;
            }
            if (ch == '.') {
                break;
            }
            throw new ParseException("Invalid character at " + pos);
        }
        String result = resultSB.toString();
        if (result.startsWith("-") || result.endsWith("-")) {
            throw new ParseException("Domain name cannot begin or end with a hyphen \"-\" at position " + (pos + 1));
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of javax.mail.internet.ParseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.