Package com.google.code.com.sun.mail.util

Examples of com.google.code.com.sun.mail.util.LineInputStream


    }

    private void loadProvidersFromStream(InputStream is)
        throws IOException {
  if (is != null) {
      LineInputStream lis = new LineInputStream(is);
      String currLine;

      // load and process one line at a time using LineInputStream
      while ((currLine = lis.readLine()) != null) {

    if (currLine.startsWith("#"))
        continue;
    Provider.Type type = null;
    String protocol = null, className = null;
View Full Code Here


    !ignoreExistingBoundaryParameter)
      throw new MessagingException("Missing boundary parameter");

  try {
      // Skip and save the preamble
      LineInputStream lin = new LineInputStream(in);
      StringBuffer preamblesb = null;
      String line;
      String lineSeparator = null;
      while ((line = lin.readLine()) != null) {
    /*
     * Strip trailing whitespace.  Can't use trim method
     * because it's too aggressive.  Some bogus MIME
     * messages will include control characters in the
     * boundary string.
     */
    int i;
    for (i = line.length() - 1; i >= 0; i--) {
        char c = line.charAt(i);
        if (!(c == ' ' || c == '\t'))
      break;
    }
    line = line.substring(0, i + 1);
    if (boundary != null) {
        if (line.equals(boundary))
      break;
        if (line.length() == boundary.length() + 2 &&
          line.startsWith(boundary) && line.endsWith("--")) {
      line = null// signal end of multipart
      break;
        }
    } else {
        /*
         * Boundary hasn't been defined, does this line
         * look like a boundary?  If so, assume it is
         * the boundary and save it.
         */
        if (line.length() > 2 && line.startsWith("--")) {
      if (line.length() > 4 && line.endsWith("--")) {
          /*
           * The first boundary-like line we find is
           * probably *not* the end-of-multipart boundary
           * line.  More likely it's a line full of dashes
           * in the preamble text.  Just keep reading.
           */
      } else {
          boundary = line;
          break;
      }
        }
    }

    // save the preamble after skipping blank lines
    if (line.length() > 0) {
        // if we haven't figured out what the line separator
        // is, do it now
        if (lineSeparator == null) {
      try {
          lineSeparator =
        System.getProperty("line.separator", "\n");
      } catch (SecurityException ex) {
          lineSeparator = "\n";
      }
        }
        // accumulate the preamble
        if (preamblesb == null)
      preamblesb = new StringBuffer(line.length() + 2);
        preamblesb.append(line).append(lineSeparator);
    }
      }

      if (preamblesb != null)
    preamble = preamblesb.toString();

      if (line == null) {
    if (allowEmpty)
        return;
    else
        throw new MessagingException("Missing start boundary");
      }

      // save individual boundary bytes for easy comparison later
      byte[] bndbytes = ASCIIUtility.getBytes(boundary);
      int bl = bndbytes.length;
     
      /*
       * Read and process body parts until we see the
       * terminating boundary line (or EOF).
       */
      boolean done = false;
  getparts:
      while (!done) {
    InternetHeaders headers = null;
    if (sin != null) {
        start = sin.getPosition();
        // skip headers
        while ((line = lin.readLine()) != null && line.length() > 0)
      ;
        if (line == null) {
      if (!ignoreMissingEndBoundary)
          throw new MessagingException(
          "missing multipart end boundary");
View Full Code Here

    !ignoreExistingBoundaryParameter)
      throw new MessagingException("Missing boundary parameter");

  try {
      // Skip and save the preamble
      LineInputStream lin = new LineInputStream(in);
      StringBuffer preamblesb = null;
      String line;
      String lineSeparator = null;
      while ((line = lin.readLine()) != null) {
    /*
     * Strip trailing whitespace.  Can't use trim method
     * because it's too aggressive.  Some bogus MIME
     * messages will include control characters in the
     * boundary string.
     */
    int i;
    for (i = line.length() - 1; i >= 0; i--) {
        char c = line.charAt(i);
        if (!(c == ' ' || c == '\t'))
      break;
    }
    line = line.substring(0, i + 1);
    if (boundary != null) {
        if (line.equals(boundary))
      break;
        if (line.length() == boundary.length() + 2 &&
          line.startsWith(boundary) && line.endsWith("--")) {
      line = null// signal end of multipart
      break;
        }
    } else {
        /*
         * Boundary hasn't been defined, does this line
         * look like a boundary?  If so, assume it is
         * the boundary and save it.
         */
        if (line.length() > 2 && line.startsWith("--")) {
      if (line.length() > 4 && line.endsWith("--")) {
          /*
           * The first boundary-like line we find is
           * probably *not* the end-of-multipart boundary
           * line.  More likely it's a line full of dashes
           * in the preamble text.  Just keep reading.
           */
      } else {
          boundary = line;
          break;
      }
        }
    }

    // save the preamble after skipping blank lines
    if (line.length() > 0) {
        // if we haven't figured out what the line separator
        // is, do it now
        if (lineSeparator == null) {
      try {
          lineSeparator =
        System.getProperty("line.separator", "\n");
      } catch (SecurityException ex) {
          lineSeparator = "\n";
      }
        }
        // accumulate the preamble
        if (preamblesb == null)
      preamblesb = new StringBuffer(line.length() + 2);
        preamblesb.append(line).append(lineSeparator);
    }
      }

      if (preamblesb != null)
    preamble = preamblesb.toString();

      if (line == null) {
    if (allowEmpty)
        return;
    else
        throw new MessagingException("Missing start boundary");
      }

      // save individual boundary bytes for comparison later
      byte[] bndbytes = ASCIIUtility.getBytes(boundary);
      int bl = bndbytes.length;

      /*
       * Compile Boyer-Moore parsing tables.
       */

      // initialize Bad Character Shift table
      int[] bcs = new int[256];
      for (int i = 0; i < bl; i++)
    bcs[bndbytes[i] & 0xff] = i + 1;

      // initialize Good Suffix Shift table
      int[] gss = new int[bl];
  NEXT:
      for (int i = bl; i > 0; i--) {
    int j;  // the beginning index of the suffix being considered
    for (j = bl - 1; j >= i; j--) {
        // Testing for good suffix
        if (bndbytes[j] == bndbytes[j - i]) {
      // bndbytes[j..len] is a good suffix
      gss[j - 1] = i;
        } else {
           // No match. The array has already been
           // filled up with correct values before.
           continue NEXT;
        }
    }
    while (j > 0)
        gss[--j] = i;
      }
      gss[bl - 1] = 1;
      /*
       * Read and process body parts until we see the
       * terminating boundary line (or EOF).
       */
      boolean done = false;
  getparts:
      while (!done) {
    InternetHeaders headers = null;
    if (sin != null) {
        start = sin.getPosition();
        // skip headers
        while ((line = lin.readLine()) != null && line.length() > 0)
      ;
        if (line == null) {
      if (!ignoreMissingEndBoundary)
          throw new MessagingException(
          "missing multipart end boundary");
View Full Code Here

     */
    public synchronized int[] getSizes() throws MessagingException {
  checkOpen();
  int sizes[] = new int[total];
  InputStream is = null;
  LineInputStream lis = null;
  try {
      is = port.list();
      lis = new LineInputStream(is);
      String line;
      while ((line = lis.readLine()) != null) {
    try {
        StringTokenizer st = new StringTokenizer(line);
        int msgnum = Integer.parseInt(st.nextToken());
        int size = Integer.parseInt(st.nextToken());
        if (msgnum > 0 && msgnum <= total)
      sizes[msgnum - 1] = size;
    } catch (Exception e) {
    }
      }
  } catch (IOException ex) {
      // ignore it?
  } finally {
      try {
    if (lis != null)
        lis.close();
      } catch (IOException cex) { }
      try {
    if (is != null)
        is.close();
      } catch (IOException cex) { }
View Full Code Here

     */
    public void load(InputStream is) throws MessagingException {
  // Read header lines until a blank line. It is valid
  // to have BodyParts with no header lines.
  String line;
  LineInputStream lis = new LineInputStream(is);
  String prevline = null// the previous header line, as a string
  // a buffer to accumulate the header in, when we know it's needed
  StringBuffer lineBuffer = new StringBuffer();

  try {
      //while ((line = lis.readLine()) != null) {
      do {
    line = lis.readLine();
    if (line != null &&
      (line.startsWith(" ") || line.startsWith("\t"))) {
        // continuation of header
        if (prevline != null) {
      lineBuffer.append(prevline);
View Full Code Here

     */
    synchronized boolean uidl(String[] uids) throws IOException {
  Response r = multilineCommand("UIDL", 15 * uids.length);
  if (!r.ok)
      return false;
  LineInputStream lis = new LineInputStream(r.bytes);
  String line = null;
  while ((line = lis.readLine()) != null) {
      int i = line.indexOf(' ');
      if (i < 1 || i >= line.length())
    continue;
      int n = Integer.parseInt(line.substring(0, i));
      if (n > 0 && n <= uids.length)
View Full Code Here

    !ignoreExistingBoundaryParameter)
      throw new MessagingException("Missing boundary parameter");

  try {
      // Skip and save the preamble
      LineInputStream lin = new LineInputStream(in);
      StringBuffer preamblesb = null;
      String line;
      String lineSeparator = null;
      while ((line = lin.readLine()) != null) {
    /*
     * Strip trailing whitespace.  Can't use trim method
     * because it's too aggressive.  Some bogus MIME
     * messages will include control characters in the
     * boundary string.
     */
    int i;
    for (i = line.length() - 1; i >= 0; i--) {
        char c = line.charAt(i);
        if (!(c == ' ' || c == '\t'))
      break;
    }
    line = line.substring(0, i + 1);
    if (boundary != null) {
        if (line.equals(boundary))
      break;
        if (line.length() == boundary.length() + 2 &&
          line.startsWith(boundary) && line.endsWith("--")) {
      line = null// signal end of multipart
      break;
        }
    } else {
        /*
         * Boundary hasn't been defined, does this line
         * look like a boundary?  If so, assume it is
         * the boundary and save it.
         */
        if (line.length() > 2 && line.startsWith("--")) {
      if (line.length() > 4 && line.endsWith("--")) {
          /*
           * The first boundary-like line we find is
           * probably *not* the end-of-multipart boundary
           * line.  More likely it's a line full of dashes
           * in the preamble text.  Just keep reading.
           */
      } else {
          boundary = line;
          break;
      }
        }
    }

    // save the preamble after skipping blank lines
    if (line.length() > 0) {
        // if we haven't figured out what the line separator
        // is, do it now
        if (lineSeparator == null) {
      try {
          lineSeparator =
        System.getProperty("line.separator", "\n");
      } catch (SecurityException ex) {
          lineSeparator = "\n";
      }
        }
        // accumulate the preamble
        if (preamblesb == null)
      preamblesb = new StringBuffer(line.length() + 2);
        preamblesb.append(line).append(lineSeparator);
    }
      }

      if (preamblesb != null)
    preamble = preamblesb.toString();

      if (line == null) {
    if (allowEmpty)
        return;
    else
        throw new MessagingException("Missing start boundary");
      }

      // save individual boundary bytes for easy comparison later
      byte[] bndbytes = ASCIIUtility.getBytes(boundary);
      int bl = bndbytes.length;
     
      /*
       * Read and process body parts until we see the
       * terminating boundary line (or EOF).
       */
      boolean done = false;
  getparts:
      while (!done) {
    InternetHeaders headers = null;
    if (sin != null) {
        start = sin.getPosition();
        // skip headers
        while ((line = lin.readLine()) != null && line.length() > 0)
      ;
        if (line == null) {
      if (!ignoreMissingEndBoundary)
          throw new MessagingException(
          "missing multipart end boundary");
View Full Code Here

    !ignoreExistingBoundaryParameter)
      throw new MessagingException("Missing boundary parameter");

  try {
      // Skip and save the preamble
      LineInputStream lin = new LineInputStream(in);
      StringBuffer preamblesb = null;
      String line;
      String lineSeparator = null;
      while ((line = lin.readLine()) != null) {
    /*
     * Strip trailing whitespace.  Can't use trim method
     * because it's too aggressive.  Some bogus MIME
     * messages will include control characters in the
     * boundary string.
     */
    int i;
    for (i = line.length() - 1; i >= 0; i--) {
        char c = line.charAt(i);
        if (!(c == ' ' || c == '\t'))
      break;
    }
    line = line.substring(0, i + 1);
    if (boundary != null) {
        if (line.equals(boundary))
      break;
        if (line.length() == boundary.length() + 2 &&
          line.startsWith(boundary) && line.endsWith("--")) {
      line = null// signal end of multipart
      break;
        }
    } else {
        /*
         * Boundary hasn't been defined, does this line
         * look like a boundary?  If so, assume it is
         * the boundary and save it.
         */
        if (line.length() > 2 && line.startsWith("--")) {
      if (line.length() > 4 && line.endsWith("--")) {
          /*
           * The first boundary-like line we find is
           * probably *not* the end-of-multipart boundary
           * line.  More likely it's a line full of dashes
           * in the preamble text.  Just keep reading.
           */
      } else {
          boundary = line;
          break;
      }
        }
    }

    // save the preamble after skipping blank lines
    if (line.length() > 0) {
        // if we haven't figured out what the line separator
        // is, do it now
        if (lineSeparator == null) {
      try {
          lineSeparator =
        System.getProperty("line.separator", "\n");
      } catch (SecurityException ex) {
          lineSeparator = "\n";
      }
        }
        // accumulate the preamble
        if (preamblesb == null)
      preamblesb = new StringBuffer(line.length() + 2);
        preamblesb.append(line).append(lineSeparator);
    }
      }

      if (preamblesb != null)
    preamble = preamblesb.toString();

      if (line == null) {
    if (allowEmpty)
        return;
    else
        throw new MessagingException("Missing start boundary");
      }

      // save individual boundary bytes for comparison later
      byte[] bndbytes = ASCIIUtility.getBytes(boundary);
      int bl = bndbytes.length;

      /*
       * Compile Boyer-Moore parsing tables.
       */

      // initialize Bad Character Shift table
      int[] bcs = new int[256];
      for (int i = 0; i < bl; i++)
    bcs[bndbytes[i] & 0xff] = i + 1;

      // initialize Good Suffix Shift table
      int[] gss = new int[bl];
  NEXT:
      for (int i = bl; i > 0; i--) {
    int j;  // the beginning index of the suffix being considered
    for (j = bl - 1; j >= i; j--) {
        // Testing for good suffix
        if (bndbytes[j] == bndbytes[j - i]) {
      // bndbytes[j..len] is a good suffix
      gss[j - 1] = i;
        } else {
           // No match. The array has already been
           // filled up with correct values before.
           continue NEXT;
        }
    }
    while (j > 0)
        gss[--j] = i;
      }
      gss[bl - 1] = 1;
      /*
       * Read and process body parts until we see the
       * terminating boundary line (or EOF).
       */
      boolean done = false;
  getparts:
      while (!done) {
    InternetHeaders headers = null;
    if (sin != null) {
        start = sin.getPosition();
        // skip headers
        while ((line = lin.readLine()) != null && line.length() > 0)
      ;
        if (line == null) {
      if (!ignoreMissingEndBoundary)
          throw new MessagingException(
          "missing multipart end boundary");
View Full Code Here

    }

    private void loadProvidersFromStream(InputStream is)
        throws IOException {
  if (is != null) {
      LineInputStream lis = new LineInputStream(is);
      String currLine;

      // load and process one line at a time using LineInputStream
      while ((currLine = lis.readLine()) != null) {

    if (currLine.startsWith("#"))
        continue;
    Provider.Type type = null;
    String protocol = null, className = null;
View Full Code Here

     */
    public synchronized int[] getSizes() throws MessagingException {
  checkOpen();
  int sizes[] = new int[total];
  InputStream is = null;
  LineInputStream lis = null;
  try {
      is = port.list();
      lis = new LineInputStream(is);
      String line;
      while ((line = lis.readLine()) != null) {
    try {
        StringTokenizer st = new StringTokenizer(line);
        int msgnum = Integer.parseInt(st.nextToken());
        int size = Integer.parseInt(st.nextToken());
        if (msgnum > 0 && msgnum <= total)
      sizes[msgnum - 1] = size;
    } catch (Exception e) {
    }
      }
  } catch (IOException ex) {
      // ignore it?
  } finally {
      try {
    if (lis != null)
        lis.close();
      } catch (IOException cex) { }
      try {
    if (is != null)
        is.close();
      } catch (IOException cex) { }
View Full Code Here

TOP

Related Classes of com.google.code.com.sun.mail.util.LineInputStream

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.