conor 2003/07/14 03:28:42 Modified: src/main/org/apache/tools/ant/taskdefs/email MimeMailer.java src/main/org/apache/tools/ant/types Description.java Log: checkstyle Revision Changes Path 1.13 +65 -56 ant/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java Index: MimeMailer.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -u -r1.12 -r1.13 --- MimeMailer.java 28 May 2003 20:58:03 -0000 1.12 +++ MimeMailer.java 14 Jul 2003 10:28:41 -0000 1.13 @@ -67,12 +67,17 @@ import java.util.StringTokenizer; import java.util.Vector; import java.security.Security; +import java.security.Provider; import javax.activation.DataHandler; import javax.activation.FileDataSource; -import javax.mail.*; +import javax.mail.Authenticator; +import javax.mail.PasswordAuthentication; +import javax.mail.Session; import javax.mail.Message; +import javax.mail.Transport; +import javax.mail.MessagingException; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; @@ -89,8 +94,9 @@ * @since Ant 1.5 */ public class MimeMailer extends Mailer { - // Default character set - private static final String defaultCharset = System.getProperty("file.encoding"); + /** Default character set */ + private static final String DEFAULT_CHARSET + = System.getProperty("file.encoding"); // To work poperly with national charsets we have to use // implementation of interface javax.activation.DataSource @@ -104,9 +110,9 @@ private ByteArrayOutputStream out; public InputStream getInputStream() throws IOException { - if(data == null && out == null) + if (data == null && out == null) { throw new IOException("No data"); - else { + } else { if(out!=null) { data=(data!=null)?data.concat(out.toString(charset)):out.toString(charset); out=null; @@ -127,11 +133,12 @@ } public String getContentType() { - if(type !=null && type.indexOf("charset")>0 && type.startsWith("text/")) + if (type != null && type.indexOf("charset") > 0 && type.startsWith("text/")) { return type; + } // Must be like "text/plain; charset=windows-1251" - return type!=null?type.concat("; charset=".concat(charset)): - "text/plain".concat("; charset=".concat(charset)); + return type != null ? type.concat("; charset=".concat(charset)) + : "text/plain".concat("; charset=".concat(charset)); } public String getName() { @@ -160,11 +167,13 @@ Authenticator auth; if (SSL) { try { - java.security.Provider p=(java.security.Provider)Class.forName( "com.sun.net.ssl.internal.ssl.Provider").newInstance(); + Provider p + = (Provider) Class.forName("com.sun.net.ssl.internal.ssl.Provider").newInstance(); Security.addProvider(p); - } - catch (Exception e) { - throw new BuildException("could not instantiate ssl security provider, check that you have JSSE in your classpath"); + } catch (Exception e) { + throw new BuildException("could not instantiate ssl " + + "security provider, check that you have JSSE in " + + "your classpath"); } final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; // SMTP provider @@ -173,8 +182,7 @@ } if (user==null && password == null) { sesh = Session.getDefaultInstance(props, null); - } - else { + } else { props.put("mail.smtp.auth", "true"); auth = new SimpleAuthenticator(user,password); sesh = Session.getInstance(props,auth); @@ -205,13 +213,12 @@ if(charset!=null) { // Assign/reassign message charset from MimeType message.setCharset(charset); - } + } else { // Next: looking if charset having explict definition - else { charset = message.getCharset(); if(charset==null) { // Using default - charset=defaultCharset; + charset = DEFAULT_CHARSET; message.setCharset(charset); } } @@ -221,8 +228,9 @@ sds.setContentType(message.getMimeType()); sds.setCharset(charset); - if (subject != null) + if (subject != null) { msg.setSubject(subject,charset); + } msg.addHeader("Date", getDate()); PrintStream out = new PrintStream(sds.getOutputStream()); @@ -285,13 +293,15 @@ private String parseCharSetFromMimeType(String type){ int pos; - if(type==null || (pos=type.indexOf("charset"))<0) + if (type == null || (pos = type.indexOf("charset")) < 0) { return null; + } // Assuming mime type in form "text/XXXX; charset=XXXXXX" StringTokenizer token = new StringTokenizer(type.substring(pos),"=; "); token.nextToken();// Skip 'charset=' return token.nextToken(); } + static class SimpleAuthenticator extends Authenticator { private String user=null; private String password=null; @@ -302,8 +312,7 @@ public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(user, password); - } - - }} + } +} 1.13 +35 -27 ant/src/main/org/apache/tools/ant/types/Description.java Index: Description.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/Description.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -u -r1.12 -r1.13 --- Description.java 22 Apr 2003 07:35:17 -0000 1.12 +++ Description.java 14 Jul 2003 10:28:42 -0000 1.13 @@ -54,7 +54,11 @@ package org.apache.tools.ant.types; -import org.apache.tools.ant.*; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.ProjectHelper; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.UnknownElement; +import org.apache.tools.ant.Target; import org.apache.tools.ant.helper.ProjectHelperImpl; import java.util.Vector; @@ -79,6 +83,8 @@ /** * Adds descriptive text to the project. + * + * @param text the descriptive text */ public void addText(String text) { @@ -107,11 +113,14 @@ } private static void concatDescriptions(Project project, Target t, - StringBuffer description) - { - if( t==null ) return; + StringBuffer description) { + if (t == null) { + return; + } Vector tasks= findElementInTarget(project, t, "description"); - if( tasks==null ) return; + if (tasks == null) { + return; + } for( int i=0; i<tasks.size(); i++ ) { Task task=(Task)tasks.elementAt(i); if( ! ( task instanceof UnknownElement)) { @@ -126,9 +135,8 @@ } private static Vector findElementInTarget(Project project, - Target t, String name ) - { - Task tasks[]=t.getTasks(); + Target t, String name) { + Task[] tasks = t.getTasks(); Vector elems=new Vector(); for( int i=0; i<tasks.length; i++ ) { if( name.equals( tasks[i].getTaskName()) ) {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]