Resolve build warnings; part 2

Change-Id: I76c1a5a4f759071f92eef0574abb20a99bfb32b7
This commit is contained in:
Todd Kennedy 2011-02-02 11:47:06 -08:00
parent 44de127691
commit 8546e21e1e
21 changed files with 493 additions and 500 deletions

View File

@ -36,7 +36,7 @@ public class BodyDescriptor {
private String boundary = null;
private String charset = "us-ascii";
private String transferEncoding = "7bit";
private Map parameters = new HashMap();
private Map<String, String> parameters = new HashMap<String, String>();
private boolean contentTypeSet = false;
private boolean contentTransferEncSet = false;
@ -97,9 +97,9 @@ public class BodyDescriptor {
sb.append(c);
}
Map params = getHeaderParams(sb.toString());
Map<String, String> params = getHeaderParams(sb.toString());
String main = (String) params.get("");
String main = params.get("");
if (main != null) {
main = main.toLowerCase().trim();
int index = main.indexOf('/');
@ -117,7 +117,7 @@ public class BodyDescriptor {
main = null;
}
}
String b = (String) params.get("boundary");
String b = params.get("boundary");
if (main != null
&& ((main.startsWith("multipart/") && b != null)
@ -130,7 +130,7 @@ public class BodyDescriptor {
boundary = b;
}
String c = (String) params.get("charset");
String c = params.get("charset");
if (c != null) {
c = c.trim();
if (c.length() > 0) {
@ -148,8 +148,8 @@ public class BodyDescriptor {
}
}
private Map getHeaderParams(String headerValue) {
Map result = new HashMap();
private Map<String, String> getHeaderParams(String headerValue) {
Map<String, String> result = new HashMap<String, String>();
// split main value and parameters
String main;
@ -198,7 +198,7 @@ public class BodyDescriptor {
paramValue = new StringBuffer();
state = IN_NAME;
// fall-through
// $FALL-THROUGH$
case IN_NAME:
if (c == '=') {
@ -232,7 +232,7 @@ public class BodyDescriptor {
if (!fallThrough)
break;
// fall-through
// $FALL-THROUGH$
case IN_VALUE:
fallThrough = false;
@ -253,6 +253,8 @@ public class BodyDescriptor {
if (!fallThrough)
break;
// $FALL-THROUGH$
case VALUE_DONE:
switch (c) {
case ';':
@ -322,17 +324,13 @@ public class BodyDescriptor {
/**
* Return true if the BodyDescriptor belongs to a message
*
* @return
*/
public boolean isMessage() {
return mimeType.equals("message/rfc822");
}
/**
* Retrun true if the BodyDescripotro belogns to a multipart
*
* @return
* Return true if the BodyDescripotro belongs to a multipart
*/
public boolean isMultipart() {
return mimeType.startsWith("multipart/");
@ -340,8 +338,6 @@ public class BodyDescriptor {
/**
* Return the MimeType
*
* @return mimeType
*/
public String getMimeType() {
return mimeType;
@ -349,8 +345,6 @@ public class BodyDescriptor {
/**
* Return the boundary
*
* @return boundary
*/
public String getBoundary() {
return boundary;
@ -358,8 +352,6 @@ public class BodyDescriptor {
/**
* Return the charset
*
* @return charset
*/
public String getCharset() {
return charset;
@ -367,17 +359,13 @@ public class BodyDescriptor {
/**
* Return all parameters for the BodyDescriptor
*
* @return parameters
*/
public Map getParameters() {
public Map<String, String> getParameters() {
return parameters;
}
/**
* Return the TransferEncoding
*
* @return transferEncoding
*/
public String getTransferEncoding() {
return transferEncoding;
@ -385,9 +373,6 @@ public class BodyDescriptor {
/**
* Return true if it's base64 encoded
*
* @return
*
*/
public boolean isBase64Encoded() {
return "base64".equals(transferEncoding);
@ -395,12 +380,12 @@ public class BodyDescriptor {
/**
* Return true if it's quoted-printable
* @return
*/
public boolean isQuotedPrintableEncoded() {
return "quoted-printable".equals(transferEncoding);
}
@Override
public String toString() {
return mimeType;
}

View File

@ -58,7 +58,7 @@ public class MimeStreamParser {
private static BitSet fieldChars = null;
private RootInputStream rootStream = null;
private LinkedList bodyDescriptors = new LinkedList();
private LinkedList<BodyDescriptor> bodyDescriptors = new LinkedList<BodyDescriptor>();
private ContentHandler handler = null;
private boolean raw = false;

View File

@ -69,10 +69,10 @@ public class ContentTypeField extends Field {
public static final String PARAM_CHARSET = "charset";
private String mimeType = "";
private Map parameters = null;
private Map<String, String> parameters = null;
private ParseException parseException;
protected ContentTypeField(String name, String body, String raw, String mimeType, Map parameters, ParseException parseException) {
protected ContentTypeField(String name, String body, String raw, String mimeType, Map<String, String> parameters, ParseException parseException) {
super(name, body, raw);
this.mimeType = mimeType;
this.parameters = parameters;
@ -132,7 +132,7 @@ public class ContentTypeField extends Field {
*/
public String getParameter(String name) {
return parameters != null
? (String) parameters.get(name.toLowerCase())
? parameters.get(name.toLowerCase())
: null;
}
@ -141,10 +141,11 @@ public class ContentTypeField extends Field {
*
* @return the parameters.
*/
public Map getParameters() {
return parameters != null
? Collections.unmodifiableMap(parameters)
: Collections.EMPTY_MAP;
public Map<String, String> getParameters() {
if (parameters != null) {
return Collections.unmodifiableMap(parameters);
}
return Collections.emptyMap();
}
/**
@ -210,7 +211,7 @@ public class ContentTypeField extends Field {
public Field parse(final String name, final String body, final String raw) {
ParseException parseException = null;
String mimeType = "";
Map parameters = null;
Map<String, String> parameters = null;
ContentTypeParser parser = new ContentTypeParser(new StringReader(body));
try {
@ -236,15 +237,15 @@ public class ContentTypeField extends Field {
if (type != null && subType != null) {
mimeType = (type + "/" + parser.getSubType()).toLowerCase();
ArrayList paramNames = parser.getParamNames();
ArrayList paramValues = parser.getParamValues();
ArrayList<String> paramNames = parser.getParamNames();
ArrayList<String> paramValues = parser.getParamValues();
if (paramNames != null && paramValues != null) {
for (int i = 0; i < paramNames.size() && i < paramValues.size(); i++) {
if (parameters == null)
parameters = new HashMap((int)(paramNames.size() * 1.3 + 1));
String paramName = ((String)paramNames.get(i)).toLowerCase();
String paramValue = ((String)paramValues.get(i));
parameters = new HashMap<String, String>((int)(paramNames.size() * 1.3 + 1));
String paramName = paramNames.get(i).toLowerCase();
String paramValue = paramValues.get(i);
parameters.put(paramName, paramValue);
}
}

View File

@ -20,7 +20,7 @@ import java.util.Map;
public class DelegatingFieldParser implements FieldParser {
private Map parsers = new HashMap();
private Map<String, FieldParser> parsers = new HashMap<String, FieldParser>();
private FieldParser defaultParser = new UnstructuredField.Parser();
/**
@ -33,7 +33,7 @@ public class DelegatingFieldParser implements FieldParser {
}
public FieldParser getParser(final String name) {
final FieldParser field = (FieldParser) parsers.get(name.toLowerCase());
final FieldParser field = parsers.get(name.toLowerCase());
if(field==null) {
return defaultParser;
}

View File

@ -38,7 +38,7 @@ public abstract class Address {
* method is needed to allow the behavior to be
* overridden by subclasses.
*/
final void addMailboxesTo(ArrayList results) {
final void addMailboxesTo(ArrayList<Address> results) {
doAddMailboxesTo(results);
}
@ -47,6 +47,6 @@ public abstract class Address {
* into the given ArrayList. Must be overridden by
* concrete subclasses.
*/
protected abstract void doAddMailboxesTo(ArrayList results);
protected abstract void doAddMailboxesTo(ArrayList<Address> results);
}

View File

@ -32,17 +32,17 @@ import java.util.ArrayList;
*/
public class AddressList {
private ArrayList addresses;
private ArrayList<Address> addresses;
/**
* @param addresses An ArrayList that contains only Address objects.
* @param dontCopy true iff it is not possible for the addresses ArrayList to be modified by someone else.
*/
public AddressList(ArrayList addresses, boolean dontCopy) {
public AddressList(ArrayList<Address> addresses, boolean dontCopy) {
if (addresses != null)
this.addresses = (dontCopy ? addresses : (ArrayList) addresses.clone());
this.addresses = (dontCopy ? addresses : new ArrayList<Address>(addresses));
else
this.addresses = new ArrayList(0);
this.addresses = new ArrayList<Address>(0);
}
/**
@ -58,7 +58,7 @@ public class AddressList {
public Address get(int index) {
if (0 > index || size() <= index)
throw new IndexOutOfBoundsException();
return (Address) addresses.get(index);
return addresses.get(index);
}
/**
@ -79,7 +79,7 @@ public class AddressList {
if (!groupDetected)
return new MailboxList(addresses, true);
ArrayList results = new ArrayList();
ArrayList<Address> results = new ArrayList<Address>();
for (int i = 0; i < size(); i++) {
Address addr = get(i);
addr.addMailboxesTo(results);
@ -101,8 +101,6 @@ public class AddressList {
}
}
/**
* Parse the address list string, such as the value
* of a From, To, Cc, Bcc, Sender, or Reply-To

View File

@ -23,7 +23,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import org.apache.james.mime4j.decoder.DecoderUtil;
import org.apache.james.mime4j.field.address.parser.*;
import org.apache.james.mime4j.field.address.parser.ASTaddr_spec;
import org.apache.james.mime4j.field.address.parser.ASTaddress;
import org.apache.james.mime4j.field.address.parser.ASTaddress_list;
@ -56,7 +55,7 @@ class Builder {
public AddressList buildAddressList(ASTaddress_list node) {
ArrayList list = new ArrayList();
ArrayList<Address> list = new ArrayList<Address>();
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
ASTaddress childNode = (ASTaddress) node.jjtGetChild(i);
Address address = buildAddress(childNode);
@ -96,7 +95,7 @@ class Builder {
private MailboxList buildGroupBody(ASTgroup_body node) {
ArrayList results = new ArrayList();
ArrayList<Address> results = new ArrayList<Address>();
ChildNodeIterator it = new ChildNodeIterator(node);
while (it.hasNext()) {
Node n = it.nextNode();
@ -166,7 +165,7 @@ class Builder {
}
private DomainList buildRoute(ASTroute node) {
ArrayList results = new ArrayList(node.jjtGetNumChildren());
ArrayList<String> results = new ArrayList<String>(node.jjtGetNumChildren());
ChildNodeIterator it = new ChildNodeIterator(node);
while (it.hasNext()) {
Node n = it.nextNode();
@ -212,7 +211,7 @@ class Builder {
}
}
private static class ChildNodeIterator implements Iterator {
private static class ChildNodeIterator implements Iterator<Node> {
private SimpleNode simpleNode;
private int index;
@ -232,7 +231,7 @@ class Builder {
return index < len;
}
public Object next() {
public Node next() {
return nextNode();
}

View File

@ -28,17 +28,17 @@ import java.util.ArrayList;
*
*/
public class DomainList {
private ArrayList domains;
private ArrayList<String> domains;
/**
* @param domains An ArrayList that contains only String objects.
* @param dontCopy true iff it is not possible for the domains ArrayList to be modified by someone else.
*/
public DomainList(ArrayList domains, boolean dontCopy) {
public DomainList(ArrayList<String> domains, boolean dontCopy) {
if (domains != null)
this.domains = (dontCopy ? domains : (ArrayList) domains.clone());
this.domains = (dontCopy ? domains : new ArrayList<String>(domains));
else
this.domains = new ArrayList(0);
this.domains = new ArrayList<String>(0);
}
/**
@ -56,7 +56,7 @@ public class DomainList {
public String get(int index) {
if (0 > index || size() <= index)
throw new IndexOutOfBoundsException();
return (String) domains.get(index);
return domains.get(index);
}
/**

View File

@ -53,6 +53,7 @@ public class Group extends Address {
return mailboxList;
}
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append(name);
@ -66,7 +67,8 @@ public class Group extends Address {
return buf.toString();
}
protected void doAddMailboxesTo(ArrayList results) {
@Override
protected void doAddMailboxesTo(ArrayList<Address> results) {
for (int i = 0; i < mailboxList.size(); i++)
results.add(mailboxList.get(i));
}

View File

@ -109,10 +109,12 @@ public class Mailbox extends Address {
+ domain + ">";
}
protected final void doAddMailboxesTo(ArrayList results) {
@Override
protected final void doAddMailboxesTo(ArrayList<Address> results) {
results.add(this);
}
@Override
public String toString() {
return getAddressString();
}

View File

@ -28,17 +28,17 @@ import java.util.ArrayList;
*/
public class MailboxList {
private ArrayList mailboxes;
private ArrayList<Address> mailboxes;
/**
* @param mailboxes An ArrayList that contains only Mailbox objects.
* @param dontCopy true iff it is not possible for the mailboxes ArrayList to be modified by someone else.
*/
public MailboxList(ArrayList mailboxes, boolean dontCopy) {
public MailboxList(ArrayList<Address> mailboxes, boolean dontCopy) {
if (mailboxes != null)
this.mailboxes = (dontCopy ? mailboxes : (ArrayList) mailboxes.clone());
this.mailboxes = (dontCopy ? mailboxes : new ArrayList<Address>(mailboxes));
else
this.mailboxes = new ArrayList(0);
this.mailboxes = new ArrayList<Address>(0);
}
/**
@ -54,7 +54,7 @@ public class MailboxList {
public Mailbox get(int index) {
if (0 > index || size() <= index)
throw new IndexOutOfBoundsException();
return (Mailbox) mailboxes.get(index);
return (Mailbox)mailboxes.get(index);
}
/**

View File

@ -64,6 +64,7 @@ public class NamedMailbox extends Mailbox {
*
* @see Mailbox#getAddressString(boolean)
*/
@Override
public String getAddressString(boolean includeRoute) {
return (name == null ? "" : name + " ") + super.getAddressString(includeRoute);
}

View File

@ -859,7 +859,7 @@ public class AddressListParser/*@bgen(jjtree)*/implements AddressListParserTreeC
return (jj_ntk = jj_nt.kind);
}
private java.util.Vector jj_expentries = new java.util.Vector();
private java.util.Vector<int[]> jj_expentries = new java.util.Vector<int[]>();
private int[] jj_expentry;
private int jj_kind = -1;
private int[] jj_lasttokens = new int[100];
@ -875,8 +875,8 @@ public class AddressListParser/*@bgen(jjtree)*/implements AddressListParserTreeC
jj_expentry[i] = jj_lasttokens[i];
}
boolean exists = false;
for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) {
int[] oldentry = (int[])(e.nextElement());
for (java.util.Enumeration<int[]> e = jj_expentries.elements(); e.hasMoreElements();) {
int[] oldentry = e.nextElement();
if (oldentry.length == jj_expentry.length) {
exists = true;
for (int i = 0; i < jj_expentry.length; i++) {
@ -927,7 +927,7 @@ public class AddressListParser/*@bgen(jjtree)*/implements AddressListParserTreeC
jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[])jj_expentries.elementAt(i);
exptokseq[i] = jj_expentries.elementAt(i);
}
return new ParseException(token, exptokseq, tokenImage);
}

View File

@ -3,16 +3,16 @@
package org.apache.james.mime4j.field.address.parser;
class JJTAddressListParserState {
private java.util.Stack nodes;
private java.util.Stack marks;
private java.util.Stack<Node> nodes;
private java.util.Stack<Integer> marks;
private int sp; // number of nodes on stack
private int mk; // current mark
private boolean node_created;
JJTAddressListParserState() {
nodes = new java.util.Stack();
marks = new java.util.Stack();
nodes = new java.util.Stack<Node>();
marks = new java.util.Stack<Integer>();
sp = 0;
mk = 0;
}
@ -36,7 +36,7 @@ class JJTAddressListParserState {
/* Returns the root node of the AST. It only makes sense to call
this after a successful parse. */
Node rootNode() {
return (Node)nodes.elementAt(0);
return nodes.elementAt(0);
}
/* Pushes a node on to the stack. */
@ -49,14 +49,14 @@ class JJTAddressListParserState {
stack. */
Node popNode() {
if (--sp < mk) {
mk = ((Integer)marks.pop()).intValue();
mk = marks.pop().intValue();
}
return (Node)nodes.pop();
return nodes.pop();
}
/* Returns the node currently on the top of the stack. */
Node peekNode() {
return (Node)nodes.peek();
return nodes.peek();
}
/* Returns the number of children on the stack in the current node
@ -70,7 +70,7 @@ class JJTAddressListParserState {
while (sp > mk) {
popNode();
}
mk = ((Integer)marks.pop()).intValue();
mk = marks.pop().intValue();
}
@ -86,7 +86,7 @@ class JJTAddressListParserState {
made the children of the definite node. Then the definite node
is pushed on to the stack. */
void closeNodeScope(Node n, int num) {
mk = ((Integer)marks.pop()).intValue();
mk = marks.pop().intValue();
while (num-- > 0) {
Node c = popNode();
c.jjtSetParent(n);
@ -106,7 +106,7 @@ class JJTAddressListParserState {
void closeNodeScope(Node n, boolean condition) {
if (condition) {
int a = nodeArity();
mk = ((Integer)marks.pop()).intValue();
mk = marks.pop().intValue();
while (a-- > 0) {
Node c = popNode();
c.jjtSetParent(n);
@ -116,7 +116,7 @@ class JJTAddressListParserState {
pushNode(n);
node_created = true;
} else {
mk = ((Integer)marks.pop()).intValue();
mk = marks.pop().intValue();
node_created = false;
}
}

View File

@ -17,18 +17,19 @@
package org.apache.james.mime4j.field.contenttype.parser;
import java.util.ArrayList;
import java.util.Vector;
public class ContentTypeParser implements ContentTypeParserConstants {
private String type;
private String subtype;
private ArrayList paramNames = new ArrayList();
private ArrayList paramValues = new ArrayList();
private ArrayList<String> paramNames = new ArrayList<String>();
private ArrayList<String> paramValues = new ArrayList<String>();
public String getType() { return type; }
public String getSubType() { return subtype; }
public ArrayList getParamNames() { return paramNames; }
public ArrayList getParamValues() { return paramValues; }
public ArrayList<String> getParamNames() { return paramNames; }
public ArrayList<String> getParamValues() { return paramValues; }
public static void main(String args[]) throws ParseException {
while (true) {
@ -221,7 +222,7 @@ public class ContentTypeParser implements ContentTypeParserConstants {
return (jj_ntk = jj_nt.kind);
}
private java.util.Vector jj_expentries = new java.util.Vector();
private Vector<int[]> jj_expentries = new Vector<int[]>();
private int[] jj_expentry;
private int jj_kind = -1;
@ -253,7 +254,7 @@ public class ContentTypeParser implements ContentTypeParserConstants {
}
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[])jj_expentries.elementAt(i);
exptokseq[i] = jj_expentries.elementAt(i);
}
return new ParseException(token, exptokseq, tokenImage);
}

View File

@ -18,7 +18,7 @@ package org.apache.james.mime4j.field.datetime.parser;
import org.apache.james.mime4j.field.datetime.DateTime;
import java.util.Calendar;
import java.util.Vector;
public class DateTimeParser implements DateTimeParserConstants {
private static final boolean ignoreMilitaryZoneOffset = true;
@ -521,7 +521,7 @@ public class DateTimeParser implements DateTimeParserConstants {
return (jj_ntk = jj_nt.kind);
}
private java.util.Vector jj_expentries = new java.util.Vector();
private Vector<int[]> jj_expentries = new Vector<int[]>();
private int[] jj_expentry;
private int jj_kind = -1;
@ -556,7 +556,7 @@ public class DateTimeParser implements DateTimeParserConstants {
}
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[])jj_expentries.elementAt(i);
exptokseq[i] = jj_expentries.elementAt(i);
}
return new ParseException(token, exptokseq, tokenImage);
}

View File

@ -44,8 +44,8 @@ import org.apache.james.mime4j.util.CharsetUtil;
* @version $Id: Header.java,v 1.3 2004/10/04 15:36:44 ntherning Exp $
*/
public class Header {
private List fields = new LinkedList();
private HashMap fieldMap = new HashMap();
private List<Field> fields = new LinkedList<Field>();
private HashMap<String, List<Field>> fieldMap = new HashMap<String, List<Field>>();
/**
* Creates a new empty <code>Header</code>.
@ -61,9 +61,11 @@ public class Header {
public Header(InputStream is) throws IOException {
final MimeStreamParser parser = new MimeStreamParser();
parser.setContentHandler(new AbstractContentHandler() {
@Override
public void endHeader() {
parser.stop();
}
@Override
public void field(String fieldData) {
addField(Field.parse(fieldData));
}
@ -77,9 +79,9 @@ public class Header {
* @param field the field to add.
*/
public void addField(Field field) {
List values = (List) fieldMap.get(field.getName().toLowerCase());
List<Field> values = fieldMap.get(field.getName().toLowerCase());
if (values == null) {
values = new LinkedList();
values = new LinkedList<Field>();
fieldMap.put(field.getName().toLowerCase(), values);
}
values.add(field);
@ -92,7 +94,7 @@ public class Header {
*
* @return the list of <code>Field</code> objects.
*/
public List getFields() {
public List<Field> getFields() {
return Collections.unmodifiableList(fields);
}
@ -104,9 +106,9 @@ public class Header {
* @return the field or <code>null</code> if none found.
*/
public Field getField(String name) {
List l = (List) fieldMap.get(name.toLowerCase());
List<Field> l = fieldMap.get(name.toLowerCase());
if (l != null && !l.isEmpty()) {
return (Field) l.get(0);
return l.get(0);
}
return null;
}
@ -117,8 +119,8 @@ public class Header {
* @param name the field name (e.g. From, Subject).
* @return the list of fields.
*/
public List getFields(String name) {
List l = (List) fieldMap.get(name.toLowerCase());
public List<Field> getFields(String name) {
List<Field> l = fieldMap.get(name.toLowerCase());
return Collections.unmodifiableList(l);
}
@ -128,9 +130,10 @@ public class Header {
*
* @return headers
*/
@Override
public String toString() {
StringBuffer str = new StringBuffer();
for (Iterator it = fields.iterator(); it.hasNext();) {
for (Iterator<Field> it = fields.iterator(); it.hasNext();) {
str.append(it.next().toString());
str.append("\r\n");
}

View File

@ -82,6 +82,7 @@ public class Message extends Entity implements Body {
*
* @see org.apache.james.mime4j.message.Entity#writeTo(java.io.OutputStream)
*/
@Override
public void writeTo(OutputStream out) throws IOException {
getHeader().writeTo(out);
@ -96,7 +97,7 @@ public class Message extends Entity implements Body {
private class MessageBuilder implements ContentHandler {
private Stack stack = new Stack();
private Stack<Object> stack = new Stack<Object>();
public MessageBuilder() {
}

View File

@ -45,7 +45,7 @@ import org.apache.james.mime4j.util.CharsetUtil;
public class Multipart implements Body {
private String preamble = "";
private String epilogue = "";
private List bodyParts = new LinkedList();
private List<BodyPart> bodyParts = new LinkedList<BodyPart>();
private Entity parent = null;
private String subType = "alternative";
@ -89,8 +89,8 @@ public class Multipart implements Body {
*/
public void setParent(Entity parent) {
this.parent = parent;
for (Iterator it = bodyParts.iterator(); it.hasNext();) {
((BodyPart) it.next()).setParent(parent);
for (Iterator<BodyPart> it = bodyParts.iterator(); it.hasNext();) {
it.next().setParent(parent);
}
}
@ -117,7 +117,7 @@ public class Multipart implements Body {
*
* @return the list of <code>BodyPart</code> objects.
*/
public List getBodyParts() {
public List<BodyPart> getBodyParts() {
return Collections.unmodifiableList(bodyParts);
}
@ -126,10 +126,10 @@ public class Multipart implements Body {
*
* @param bodyParts the new list of <code>BodyPart</code> objects.
*/
public void setBodyParts(List bodyParts) {
public void setBodyParts(List<BodyPart> bodyParts) {
this.bodyParts = bodyParts;
for (Iterator it = bodyParts.iterator(); it.hasNext();) {
((BodyPart) it.next()).setParent(parent);
for (Iterator<BodyPart> it = bodyParts.iterator(); it.hasNext();) {
it.next().setParent(parent);
}
}
@ -167,7 +167,7 @@ public class Multipart implements Body {
*/
public void writeTo(OutputStream out) throws IOException {
String boundary = getBoundary();
List bodyParts = getBodyParts();
List<BodyPart> bodyParts = getBodyParts();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, CharsetUtil.getCharset(getCharset())),8192);
@ -175,7 +175,7 @@ public class Multipart implements Body {
for (int i = 0; i < bodyParts.size(); i++) {
writer.write(boundary + "\r\n");
((BodyPart) bodyParts.get(i)).writeTo(out);
bodyParts.get(i).writeTo(out);
}
writer.write(getEpilogue() + "\r\n");

View File

@ -793,7 +793,7 @@ import org.apache.james.mime4j.LogFactory;
public class CharsetUtil {
private static Log log = LogFactory.getLog(CharsetUtil.class);
private static class Charset implements Comparable {
private static class Charset implements Comparable<Charset> {
private String canonical = null;
private String mime = null;
private String[] aliases = null;
@ -804,8 +804,7 @@ public class CharsetUtil {
this.aliases = aliases;
}
public int compareTo(Object o) {
Charset c = (Charset) o;
public int compareTo(Charset c) {
return this.canonical.compareTo(c.canonical);
}
}
@ -1003,23 +1002,23 @@ public class CharsetUtil {
* Contains the canonical names of character sets which can be used to
* decode bytes into Java chars.
*/
private static TreeSet decodingSupported = null;
private static TreeSet<String> decodingSupported = null;
/**
* Contains the canonical names of character sets which can be used to
* encode Java chars into bytes.
*/
private static TreeSet encodingSupported = null;
private static TreeSet<String> encodingSupported = null;
/**
* Maps character set names to Charset objects. All possible names of
* a charset will be mapped to the Charset.
*/
private static HashMap charsetMap = null;
private static HashMap<String, Charset> charsetMap = null;
static {
decodingSupported = new TreeSet();
encodingSupported = new TreeSet();
decodingSupported = new TreeSet<String>();
encodingSupported = new TreeSet<String>();
byte[] dummy = new byte[] {'d', 'u', 'm', 'm', 'y'};
for (int i = 0; i < JAVA_CHARSETS.length; i++) {
try {
@ -1036,7 +1035,7 @@ public class CharsetUtil {
}
}
charsetMap = new HashMap();
charsetMap = new HashMap<String, Charset>();
for (int i = 0; i < JAVA_CHARSETS.length; i++) {
Charset c = JAVA_CHARSETS[i];
charsetMap.put(c.canonical.toLowerCase(), c);
@ -1163,7 +1162,7 @@ public class CharsetUtil {
* @return the MIME preferred name or <code>null</code> if not known.
*/
public static String toMimeCharset(String charsetName) {
Charset c = (Charset) charsetMap.get(charsetName.toLowerCase());
Charset c = charsetMap.get(charsetName.toLowerCase());
if (c != null) {
return c.mime;
}
@ -1182,7 +1181,7 @@ public class CharsetUtil {
* @return the canonical Java name or <code>null</code> if not known.
*/
public static String toJavaCharset(String charsetName) {
Charset c = (Charset) charsetMap.get(charsetName.toLowerCase());
Charset c = charsetMap.get(charsetName.toLowerCase());
if (c != null) {
return c.canonical;
}

View File

@ -24,6 +24,7 @@ import com.android.email.provider.EmailContent.Message;
import org.apache.james.mime4j.field.Field;
import org.apache.james.mime4j.message.Body;
import org.apache.james.mime4j.message.BodyPart;
import org.apache.james.mime4j.message.Entity;
import org.apache.james.mime4j.message.Header;
import org.apache.james.mime4j.message.Multipart;
@ -210,11 +211,11 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
Field contentType = header.getField("content-type");
assertTrue(contentType.getBody().contains("multipart/alternative"));
Multipart multipart = (Multipart)mimeMessage.getBody();
List<Body> partList = multipart.getBodyParts();
List<BodyPart> partList = multipart.getBodyParts();
assertEquals(2, partList.size());
Entity part = (Entity)partList.get(0);
Entity part = partList.get(0);
assertEquals("text/plain", part.getMimeType());
part = (Entity)partList.get(1);
part = partList.get(1);
assertEquals("text/calendar", part.getMimeType());
header = part.getHeader();
assertNull(header.getField("content-disposition"));
@ -254,11 +255,11 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
Field contentType = header.getField("content-type");
assertTrue(contentType.getBody().contains("multipart/mixed"));
Multipart multipart = (Multipart)mimeMessage.getBody();
List<Body> partList = multipart.getBodyParts();
List<BodyPart> partList = multipart.getBodyParts();
assertEquals(2, partList.size());
Entity part = (Entity)partList.get(0);
Entity part = partList.get(0);
assertEquals("text/plain", part.getMimeType());
part = (Entity)partList.get(1);
part = partList.get(1);
assertEquals("text/html", part.getMimeType());
header = part.getHeader();
assertNotNull(header.getField("content-disposition"));