susimail: type arguments

This commit is contained in:
str4d
2013-11-21 10:49:15 +00:00
parent 4bddf8ae0b
commit bff79cdae8
8 changed files with 58 additions and 56 deletions

View File

@ -119,7 +119,7 @@ public class Mail {
return null;
}
public static boolean getRecipientsFromList( ArrayList recipients, String text, boolean ok )
public static boolean getRecipientsFromList( ArrayList<String> recipients, String text, boolean ok )
{
if( text != null && text.length() > 0 ) {
String[] ccs = text.split( "," );
@ -141,12 +141,12 @@ public class Mail {
}
return ok;
}
public static void appendRecipients( StringBuilder buf, ArrayList recipients, String prefix )
public static void appendRecipients( StringBuilder buf, ArrayList<String> recipients, String prefix )
{
for( Iterator it = recipients.iterator(); it.hasNext(); ) {
for( Iterator<String> it = recipients.iterator(); it.hasNext(); ) {
buf.append( prefix );
prefix ="\t";
buf.append( (String)it.next() );
buf.append( it.next() );
buf.append( "\r\n" );
}
}
@ -217,12 +217,12 @@ public class Mail {
reply = Mail.getAddress( line.substring( 9 ).trim() );
}
else if( line.startsWith( "To:" ) ) {
ArrayList list = new ArrayList();
ArrayList<String> list = new ArrayList<String>();
Mail.getRecipientsFromList( list, line.substring( 3 ).trim(), true );
to = list.toArray();
}
else if( line.startsWith( "Cc:" ) ) {
ArrayList list = new ArrayList();
ArrayList<String> list = new ArrayList<String>();
Mail.getRecipientsFromList( list, line.substring( 3 ).trim(), true );
cc = list.toArray();
}

View File

@ -36,12 +36,12 @@ public class MailCache {
public static final boolean FETCH_ALL = false;
private POP3MailBox mailbox;
private Hashtable mails;
private Hashtable<String, Mail> mails;
private Object synchronizer;
MailCache( POP3MailBox mailbox ) {
this.mailbox = mailbox;
mails = new Hashtable();
mails = new Hashtable<String, Mail>();
synchronizer = new Object();
}
/**
@ -61,7 +61,7 @@ public class MailCache {
*/
synchronized( synchronizer ) {
mail = (Mail)mails.get( uidl );
mail = mails.get( uidl );
if( mail == null ) {
newMail = new Mail();

View File

@ -37,7 +37,7 @@ public class MailPart {
public String headerLines[], type, boundary, encoding, name,
filename, description, disposition, charset, version;
public int beginBody, begin, end;
public ArrayList parts = null;
public ArrayList<MailPart> parts = null;
public boolean multipart = false, message = false;
public ReadBuffer buffer = null;
@ -53,7 +53,7 @@ public class MailPart {
buffer = readBuffer;
if( parts == null )
parts = new ArrayList();
parts = new ArrayList<MailPart>();
else
parts.clear();

View File

@ -54,8 +54,8 @@ public class RequestWrapper {
private HttpServletRequest httpRequest = null;
private MultiPartRequest multiPartRequest = null;
private Hashtable cache;
private Hashtable cachedParameterNames;
private Hashtable<String, String> cache;
private Hashtable<String, Integer> cachedParameterNames;
/**
* do not call
*/
@ -66,7 +66,7 @@ public class RequestWrapper {
* @param httpRequest
*/
public RequestWrapper(HttpServletRequest httpRequest) {
cache = new Hashtable();
cache = new Hashtable<String, String>();
this.httpRequest = httpRequest;
String contentType = httpRequest.getContentType();
if( contentType != null && contentType.toLowerCase(Locale.US).startsWith( "multipart/form-data" ) ) {
@ -101,10 +101,10 @@ public class RequestWrapper {
/**
* @return List of request parameter names
*/
public Enumeration getParameterNames() {
public Enumeration<String> getParameterNames() {
if( multiPartRequest != null ) {
if( cachedParameterNames == null ) {
cachedParameterNames = new Hashtable();
cachedParameterNames = new Hashtable<String, Integer>();
String[] partNames = multiPartRequest.getPartNames();
for( int i = 0; i < partNames.length; i++ )
cachedParameterNames.put( partNames[i], Integer.valueOf( i ) );
@ -133,9 +133,9 @@ public class RequestWrapper {
{
String result = null;
if( multiPartRequest != null ) {
Hashtable params = multiPartRequest.getParams( partName );
for( Enumeration e = params.keys(); e.hasMoreElements(); ) {
String key = (String)e.nextElement();
Hashtable<String, String> params = multiPartRequest.getParams( partName );
for( Enumeration<String> e = params.keys(); e.hasMoreElements(); ) {
String key = e.nextElement();
if( key.toLowerCase(Locale.US).compareToIgnoreCase( "content-type") == 0 ) {
String value = (String)params.get( key );
int i = value.indexOf( ";" );

View File

@ -322,7 +322,7 @@ public class WebMail extends HttpServlet
String subject, body, showUIDL;
public MailPart showAttachment;
public String sentMail;
public ArrayList attachments;
public ArrayList<Attachment> attachments;
public boolean reallyDelete;
String themePath, imgPath;
boolean isMobile;
@ -875,8 +875,8 @@ public class WebMail extends HttpServlet
* @return message number or -1
*/
private static int getCheckedMessage(RequestWrapper request) {
for( Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
String parameter = (String)e.nextElement();
for( Enumeration<String> e = request.getParameterNames(); e.hasMoreElements(); ) {
String parameter = e.nextElement();
if( parameter.startsWith( "check" ) && request.getParameter( parameter ).compareTo( "1" ) == 0 ) {
String number = parameter.substring( 5 );
try {
@ -944,7 +944,7 @@ public class WebMail extends HttpServlet
attachment.setTransferEncoding( encodeTo );
attachment.setContentType( contentType );
if( sessionObject.attachments == null )
sessionObject.attachments = new ArrayList();
sessionObject.attachments = new ArrayList<Attachment>();
sessionObject.attachments.add( attachment );
}
else {
@ -962,8 +962,8 @@ public class WebMail extends HttpServlet
}
}
else if( sessionObject.attachments != null && buttonPressed( request, DELETE_ATTACHMENT ) ) {
for( Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
String parameter = (String)e.nextElement();
for( Enumeration<String> e = request.getParameterNames(); e.hasMoreElements(); ) {
String parameter = e.nextElement();
if( parameter.startsWith( "check" ) && request.getParameter( parameter ).compareTo( "1" ) == 0 ) {
String number = parameter.substring( 5 );
try {
@ -1108,8 +1108,8 @@ public class WebMail extends HttpServlet
else {
int numberDeleted = 0;
if( buttonPressed( request, REALLYDELETE ) ) {
for( Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
String parameter = (String)e.nextElement();
for( Enumeration<String> e = request.getParameterNames(); e.hasMoreElements(); ) {
String parameter = e.nextElement();
if( parameter.startsWith( "check" ) && request.getParameter( parameter ).compareTo( "1" ) == 0 ) {
String number = parameter.substring( 5 );
try {
@ -1440,10 +1440,10 @@ public class WebMail extends HttpServlet
if( prop.compareToIgnoreCase( "false" ) != 0 ) {
from = "<" + sessionObject.user + "@" + domain + ">";
}
ArrayList toList = new ArrayList();
ArrayList ccList = new ArrayList();
ArrayList bccList = new ArrayList();
ArrayList recipients = new ArrayList();
ArrayList<String> toList = new ArrayList<String>();
ArrayList<String> ccList = new ArrayList<String>();
ArrayList<String> bccList = new ArrayList<String>();
ArrayList<String> recipients = new ArrayList<String>();
String sender = null;

View File

@ -37,10 +37,10 @@ public class EncodingFactory {
public static final String CONFIG_ENCODING = "encodings";
private static Hashtable encodings = null;
private static Hashtable<String, Encoding> encodings = null;
static {
encodings = new Hashtable();
encodings = new Hashtable<String, Encoding>();
String list = Config.getProperty( CONFIG_ENCODING );
if( list != null ) {
String[] classNames = list.split( ";" );
@ -66,14 +66,14 @@ public class EncodingFactory {
*/
public static Encoding getEncoding( String name )
{
return name != null && name.length() > 0 ? (Encoding)encodings.get( name ) : null;
return name != null && name.length() > 0 ? encodings.get( name ) : null;
}
/**
* Returns list of available encodings;
*
* @return List of encodings
*/
public static Set availableEncodings()
public static Set<String> availableEncodings()
{
return encodings.keySet();
}

View File

@ -48,8 +48,10 @@ public class POP3MailBox {
private boolean connected = false;
private Hashtable headerList = null, bodyList = null, sizes = null, uidlToID = null;
private ArrayList uidlList = null;
private Hashtable<Integer, ReadBuffer> headerList = null, bodyList = null;
private Hashtable<Integer, Integer> sizes = null;
private Hashtable<String, Integer> uidlToID = null;
private ArrayList<String> uidlList = null;
private Socket socket = null;
@ -73,11 +75,11 @@ public class POP3MailBox {
this.port = port;
this.user = user;
this.pass = pass;
headerList = new Hashtable();
bodyList = new Hashtable();
uidlList = new ArrayList();
uidlToID = new Hashtable();
sizes = new Hashtable();
headerList = new Hashtable<Integer, ReadBuffer>();
bodyList = new Hashtable<Integer, ReadBuffer>();
uidlList = new ArrayList<String>();
uidlToID = new Hashtable<String, Integer>();
sizes = new Hashtable<Integer, Integer>();
synchronizer = new Object();
connect();
}
@ -313,7 +315,7 @@ public class POP3MailBox {
if(readBuffer != null) {
String[] lines = new String( readBuffer.content, 0, readBuffer.length ).split( "\r\n" );
if (lines != null) {
sizes = new Hashtable();
sizes = new Hashtable<Integer, Integer>();
for (int i = 0; i < lines.length; i++) {
int j = lines[i].indexOf(" ");
if (j != -1) {

View File

@ -62,7 +62,7 @@ public class MultiPartRequest
String _boundary;
String _encoding;
byte[] _byteBoundary;
MultiMap _partMap = new MultiMap(10);
MultiMap<String> _partMap = new MultiMap<String>(10);
int _char=-2;
boolean _lastPart=false;
@ -103,8 +103,8 @@ public class MultiPartRequest
*/
public String[] getPartNames()
{
Set s = _partMap.keySet();
return (String[]) s.toArray(new String[s.size()]);
Set<String> s = _partMap.keySet();
return s.toArray(new String[s.size()]);
}
/* ------------------------------------------------------------ */
@ -125,7 +125,7 @@ public class MultiPartRequest
*/
public String getString(String name)
{
List part = _partMap.getValues(name);
List<Object> part = _partMap.getValues(name);
if (part==null)
return null;
if (_encoding != null)
@ -151,7 +151,7 @@ public class MultiPartRequest
*/
public String[] getStrings(String name)
{
List parts = _partMap.getValues(name);
List<Object> parts = _partMap.getValues(name);
if (parts==null)
return null;
String[] strings = new String[parts.size()];
@ -185,7 +185,7 @@ public class MultiPartRequest
*/
public InputStream getInputStream(String name)
{
List part = (List)_partMap.getValues(name);
List<Object> part = _partMap.getValues(name);
if (part==null)
return null;
return new ByteArrayInputStream(((Part)part.get(0))._data);
@ -194,7 +194,7 @@ public class MultiPartRequest
/* ------------------------------------------------------------ */
public InputStream[] getInputStreams(String name)
{
List parts = (List)_partMap.getValues(name);
List<Object> parts = _partMap.getValues(name);
if (parts==null)
return null;
InputStream[] streams = new InputStream[parts.size()];
@ -209,9 +209,9 @@ public class MultiPartRequest
* @param name The part name
* @return Hashtable of parameters
*/
public Hashtable getParams(String name)
public Hashtable<String, String> getParams(String name)
{
List part = (List)_partMap.getValues(name);
List<Object> part = _partMap.getValues(name);
if (part==null)
return null;
return ((Part)part.get(0))._headers;
@ -220,7 +220,7 @@ public class MultiPartRequest
/* ------------------------------------------------------------ */
public Hashtable[] getMultipleParams(String name)
{
List parts = (List)_partMap.getValues(name);
List<Object> parts = _partMap.getValues(name);
if (parts==null)
return null;
Hashtable[] params = new Hashtable[parts.size()];
@ -237,7 +237,7 @@ public class MultiPartRequest
*/
public String getFilename(String name)
{
List part = (List)_partMap.getValues(name);
List<Object> part = _partMap.getValues(name);
if (part==null)
return null;
return ((Part)part.get(0))._filename;
@ -246,7 +246,7 @@ public class MultiPartRequest
/* ------------------------------------------------------------ */
public String[] getFilenames(String name)
{
List parts = (List)_partMap.getValues(name);
List<Object> parts = _partMap.getValues(name);
if (parts==null)
return null;
String[] filenames = new String[parts.size()];
@ -439,7 +439,7 @@ public class MultiPartRequest
{
String _name;
String _filename;
Hashtable _headers= new Hashtable(10);
Hashtable<String, String> _headers= new Hashtable<String, String>(10);
byte[] _data;
}
};