Java Code Examples for com.sun.xml.internal.messaging.saaj.util.FinalArrayList#toArray()

The following examples show how to use com.sun.xml.internal.messaging.saaj.util.FinalArrayList#toArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InternetHeaders.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return all the values for the specified header. The
 * values are String objects.  Returns <code>null</code>
 * if no headers with the specified name exist.
 *
 * @param   name header name
 * @return          array of header values, or null if none
 */
public String[] getHeader(String name) {
    // XXX - should we just step through in index order?
    FinalArrayList v = new FinalArrayList(); // accumulate return values

    int len = headers.size();
    for( int i=0; i<len; i++ ) {
        hdr h = (hdr) headers.get(i);
        if (name.equalsIgnoreCase(h.name)) {
            v.add(h.getValue());
        }
    }
    if (v.size() == 0)
        return (null);
    // convert Vector to an array for return
    return (String[]) v.toArray(new String[v.size()]);
}
 
Example 2
Source File: InternetHeaders.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return all the values for the specified header. The
 * values are String objects.  Returns <code>null</code>
 * if no headers with the specified name exist.
 *
 * @param   name header name
 * @return          array of header values, or null if none
 */
public String[] getHeader(String name) {
    // XXX - should we just step through in index order?
    FinalArrayList v = new FinalArrayList(); // accumulate return values

    int len = headers.size();
    for( int i=0; i<len; i++ ) {
        hdr h = (hdr) headers.get(i);
        if (name.equalsIgnoreCase(h.name)) {
            v.add(h.getValue());
        }
    }
    if (v.size() == 0)
        return (null);
    // convert Vector to an array for return
    return (String[]) v.toArray(new String[v.size()]);
}
 
Example 3
Source File: InternetHeaders.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return all the values for the specified header. The
 * values are String objects.  Returns <code>null</code>
 * if no headers with the specified name exist.
 *
 * @param   name header name
 * @return          array of header values, or null if none
 */
public String[] getHeader(String name) {
    // XXX - should we just step through in index order?
    FinalArrayList v = new FinalArrayList(); // accumulate return values

    int len = headers.size();
    for( int i=0; i<len; i++ ) {
        hdr h = (hdr) headers.get(i);
        if (name.equalsIgnoreCase(h.name)) {
            v.add(h.getValue());
        }
    }
    if (v.size() == 0)
        return (null);
    // convert Vector to an array for return
    return (String[]) v.toArray(new String[v.size()]);
}
 
Example 4
Source File: InternetHeaders.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return all the values for the specified header. The
 * values are String objects.  Returns <code>null</code>
 * if no headers with the specified name exist.
 *
 * @param   name header name
 * @return          array of header values, or null if none
 */
public String[] getHeader(String name) {
    // XXX - should we just step through in index order?
    FinalArrayList v = new FinalArrayList(); // accumulate return values

    int len = headers.size();
    for( int i=0; i<len; i++ ) {
        hdr h = (hdr) headers.get(i);
        if (name.equalsIgnoreCase(h.name)) {
            v.add(h.getValue());
        }
    }
    if (v.size() == 0)
        return (null);
    // convert Vector to an array for return
    return (String[]) v.toArray(new String[v.size()]);
}
 
Example 5
Source File: InternetHeaders.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return all the values for the specified header. The
 * values are String objects.  Returns <code>null</code>
 * if no headers with the specified name exist.
 *
 * @param   name header name
 * @return          array of header values, or null if none
 */
public String[] getHeader(String name) {
    // XXX - should we just step through in index order?
    FinalArrayList<String> v = new FinalArrayList<String>(); // accumulate return values

    int len = headers.size();
    for( int i=0; i<len; i++ ) {
        hdr h = headers.get(i);
        if (name.equalsIgnoreCase(h.name)) {
            v.add(h.getValue());
        }
    }
    if (v.size() == 0)
        return (null);
    // convert Vector to an array for return
    return v.toArray(new String[v.size()]);
}
 
Example 6
Source File: InternetHeaders.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return all the values for the specified header. The
 * values are String objects.  Returns <code>null</code>
 * if no headers with the specified name exist.
 *
 * @param   name header name
 * @return          array of header values, or null if none
 */
public String[] getHeader(String name) {
    // XXX - should we just step through in index order?
    FinalArrayList v = new FinalArrayList(); // accumulate return values

    int len = headers.size();
    for( int i=0; i<len; i++ ) {
        hdr h = (hdr) headers.get(i);
        if (name.equalsIgnoreCase(h.name)) {
            v.add(h.getValue());
        }
    }
    if (v.size() == 0)
        return (null);
    // convert Vector to an array for return
    return (String[]) v.toArray(new String[v.size()]);
}
 
Example 7
Source File: InternetHeaders.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return all the values for the specified header. The
 * values are String objects.  Returns <code>null</code>
 * if no headers with the specified name exist.
 *
 * @param   name header name
 * @return          array of header values, or null if none
 */
public String[] getHeader(String name) {
    // XXX - should we just step through in index order?
    FinalArrayList v = new FinalArrayList(); // accumulate return values

    int len = headers.size();
    for( int i=0; i<len; i++ ) {
        hdr h = (hdr) headers.get(i);
        if (name.equalsIgnoreCase(h.name)) {
            v.add(h.getValue());
        }
    }
    if (v.size() == 0)
        return (null);
    // convert Vector to an array for return
    return (String[]) v.toArray(new String[v.size()]);
}
 
Example 8
Source File: InternetHeaders.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return all the values for the specified header. The
 * values are String objects.  Returns <code>null</code>
 * if no headers with the specified name exist.
 *
 * @param   name header name
 * @return          array of header values, or null if none
 */
public String[] getHeader(String name) {
    // XXX - should we just step through in index order?
    FinalArrayList v = new FinalArrayList(); // accumulate return values

    int len = headers.size();
    for( int i=0; i<len; i++ ) {
        hdr h = (hdr) headers.get(i);
        if (name.equalsIgnoreCase(h.name)) {
            v.add(h.getValue());
        }
    }
    if (v.size() == 0)
        return (null);
    // convert Vector to an array for return
    return (String[]) v.toArray(new String[v.size()]);
}
 
Example 9
Source File: MimeBodyPart.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the languages specified in the Content-Language header
 * of this MimeBodyPart. The Content-Language header is defined by
 * RFC 1766. Returns <code>null</code> if this header is not
 * available or its value is absent. <p>
 *
 * This implementation uses <code>getHeader(name)</code>
 * to obtain the requisite header field.
 */
public String[] getContentLanguage() throws MessagingException {
    String s = 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);
    FinalArrayList v = new FinalArrayList();

    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.size() == 0)
        return null;

    return (String[])v.toArray(new String[v.size()]);
}
 
Example 10
Source File: MimeBodyPart.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the languages specified in the Content-Language header
 * of this MimeBodyPart. The Content-Language header is defined by
 * RFC 1766. Returns <code>null</code> if this header is not
 * available or its value is absent. <p>
 *
 * This implementation uses <code>getHeader(name)</code>
 * to obtain the requisite header field.
 */
public String[] getContentLanguage() throws MessagingException {
    String s = 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);
    FinalArrayList v = new FinalArrayList();

    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.size() == 0)
        return null;

    return (String[])v.toArray(new String[v.size()]);
}
 
Example 11
Source File: MimeBodyPart.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the languages specified in the Content-Language header
 * of this MimeBodyPart. The Content-Language header is defined by
 * RFC 1766. Returns <code>null</code> if this header is not
 * available or its value is absent. <p>
 *
 * This implementation uses <code>getHeader(name)</code>
 * to obtain the requisite header field.
 */
public String[] getContentLanguage() throws MessagingException {
    String s = 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);
    FinalArrayList v = new FinalArrayList();

    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.size() == 0)
        return null;

    return (String[])v.toArray(new String[v.size()]);
}
 
Example 12
Source File: MimeBodyPart.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the languages specified in the Content-Language header
 * of this MimeBodyPart. The Content-Language header is defined by
 * RFC 1766. Returns <code>null</code> if this header is not
 * available or its value is absent. <p>
 *
 * This implementation uses <code>getHeader(name)</code>
 * to obtain the requisite header field.
 */
public String[] getContentLanguage() throws MessagingException {
    String s = 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);
    FinalArrayList v = new FinalArrayList();

    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.size() == 0)
        return null;

    return (String[])v.toArray(new String[v.size()]);
}
 
Example 13
Source File: MimeBodyPart.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the languages specified in the Content-Language header
 * of this MimeBodyPart. The Content-Language header is defined by
 * RFC 1766. Returns <code>null</code> if this header is not
 * available or its value is absent. <p>
 *
 * This implementation uses <code>getHeader(name)</code>
 * to obtain the requisite header field.
 *
 * @return array of language tags
 * @exception MessagingException in case of error
 */
public String[] getContentLanguage() throws MessagingException {
    String s = 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);
    FinalArrayList<String> v = new FinalArrayList<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.size() == 0)
        return null;

    return v.toArray(new String[v.size()]);
}
 
Example 14
Source File: MimeBodyPart.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the languages specified in the Content-Language header
 * of this MimeBodyPart. The Content-Language header is defined by
 * RFC 1766. Returns <code>null</code> if this header is not
 * available or its value is absent. <p>
 *
 * This implementation uses <code>getHeader(name)</code>
 * to obtain the requisite header field.
 */
public String[] getContentLanguage() throws MessagingException {
    String s = 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);
    FinalArrayList v = new FinalArrayList();

    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.size() == 0)
        return null;

    return (String[])v.toArray(new String[v.size()]);
}
 
Example 15
Source File: MimeBodyPart.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the languages specified in the Content-Language header
 * of this MimeBodyPart. The Content-Language header is defined by
 * RFC 1766. Returns <code>null</code> if this header is not
 * available or its value is absent. <p>
 *
 * This implementation uses <code>getHeader(name)</code>
 * to obtain the requisite header field.
 */
public String[] getContentLanguage() throws MessagingException {
    String s = 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);
    FinalArrayList v = new FinalArrayList();

    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.size() == 0)
        return null;

    return (String[])v.toArray(new String[v.size()]);
}
 
Example 16
Source File: MimeBodyPart.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the languages specified in the Content-Language header
 * of this MimeBodyPart. The Content-Language header is defined by
 * RFC 1766. Returns <code>null</code> if this header is not
 * available or its value is absent. <p>
 *
 * This implementation uses <code>getHeader(name)</code>
 * to obtain the requisite header field.
 */
public String[] getContentLanguage() throws MessagingException {
    String s = 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);
    FinalArrayList v = new FinalArrayList();

    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.size() == 0)
        return null;

    return (String[])v.toArray(new String[v.size()]);
}