Modified: 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/SieveToXml.java
URL: 
http://svn.apache.org/viewvc/james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/SieveToXml.java?rev=1425888&r1=1425887&r2=1425888&view=diff
==============================================================================
--- 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/SieveToXml.java 
(original)
+++ 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/SieveToXml.java 
Wed Dec 26 12:05:08 2012
@@ -128,7 +128,7 @@ public class SieveToXml {
      * @param elementLocalName to be returned for all names, not null
      * @return not null
      */
-    public static final NameMapper uniformMapper(final String 
elementLocalName) {
+    public static NameMapper uniformMapper(final String elementLocalName) {
         return new NameMapper() {
             public String toElementName(String name) {
                 return elementLocalName;
@@ -143,13 +143,13 @@ public class SieveToXml {
      * Sieve Email Filtering: Sieves and display directives in 
XML</blockquote>.  
      * @return not null
      */
-    public static final NameMapper sieveInXmlMapper() {
+    public static NameMapper sieveInXmlMapper() {
         return new NameMapper() {
 
             public String toElementName(String name) {
                 boolean isControlCommand = false;
-                for (int i=0;i< CONTROL_COMMANDS.length;i++) {
-                    if (CONTROL_COMMANDS[i].equalsIgnoreCase(name)) {
+                for (String CONTROL_COMMAND : CONTROL_COMMANDS) {
+                    if (CONTROL_COMMAND.equalsIgnoreCase(name)) {
                         isControlCommand = true;
                         break;
                     }
@@ -327,9 +327,8 @@ public class SieveToXml {
      * @return hanlder, not null
      */
     public SieveHandler build(final Out out) {
-        final Worker worker = new Worker(nameAttributeName, namespaceUri, 
namespacePrefix, stringElementName, 
+        return new Worker(nameAttributeName, namespaceUri, namespacePrefix, 
stringElementName,
                 tagElementName, numberElementName, listElementName, 
commandNameMapper, testNameMapper, out);
-        return worker;
     }
     
     /**

Modified: 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/ToSieveHandlerFactory.java
URL: 
http://svn.apache.org/viewvc/james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/ToSieveHandlerFactory.java?rev=1425888&r1=1425887&r2=1425888&view=diff
==============================================================================
--- 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/ToSieveHandlerFactory.java
 (original)
+++ 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/ToSieveHandlerFactory.java
 Wed Dec 26 12:05:08 2012
@@ -81,7 +81,7 @@ public class ToSieveHandlerFactory {
             return append('{');
         }
         
-        /** @see SieveHandler#startCommand() */
+        /** */
         @Override
         public SieveHandler startCommand(String commandName) throws 
HaltTraversalException {
             commaRequiredBeforeNextTest = false;
@@ -92,7 +92,7 @@ public class ToSieveHandlerFactory {
             return append(commandName);
         }
         
-        /** @see SieveHandler#endCommand() */
+        /** */
         @Override
         public SieveHandler endCommand(String commandName) throws 
HaltTraversalException {
             if (!commandUsedBlock) {
@@ -185,7 +185,6 @@ public class ToSieveHandlerFactory {
 
         /**
          * Appends the given sequence.
-         * @param character to be appended
          * @return this
          * @throws HaltTraversalException when character cannot be written
          */

Modified: 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/XmlOut.java
URL: 
http://svn.apache.org/viewvc/james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/XmlOut.java?rev=1425888&r1=1425887&r2=1425888&view=diff
==============================================================================
--- james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/XmlOut.java 
(original)
+++ james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/XmlOut.java 
Wed Dec 26 12:05:08 2012
@@ -15,19 +15,14 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.jsieve.util;
 
+import org.apache.jsieve.util.SieveToXml.Out;
+
 import java.io.IOException;
 import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.Stack;
-
-import org.apache.jsieve.util.SieveToXml.Out;
+import java.util.*;
 
 /**
  * <p>Lightweight {@link Out} implementation.</p>
@@ -43,9 +38,9 @@ public final class XmlOut implements Sie
     private static final byte NAME_MASK = 1 << 2;
     private static final byte NAME_BODY_CHAR = NAME_MASK;
     private static final byte NAME_START_OR_BODY_CHAR = NAME_MASK | 
NAME_START_MASK;
-    
-    private final static boolean[] ALLOWED_CHARACTERS = new boolean[1 << 16]; 
-    
+
+    private final static boolean[] ALLOWED_CHARACTERS = new boolean[1 << 16];
+
     static {
         Arrays.fill(ALLOWED_CHARACTERS, false);
         ALLOWED_CHARACTERS[0x9] = true;
@@ -54,9 +49,9 @@ public final class XmlOut implements Sie
         Arrays.fill(ALLOWED_CHARACTERS, 0x20, 0xD7FF, true);
         Arrays.fill(ALLOWED_CHARACTERS, 0xE000, 0xFFFD, true);
     }
-    
-    private final static byte[] CHARACTER_CODES = new byte[1 << 16]; 
-                              
+
+    private final static byte[] CHARACTER_CODES = new byte[1 << 16];
+
     static {
         // Name ::= (Letter | '_' | ':') (NameChar)*
         CHARACTER_CODES['_'] = NAME_START_OR_BODY_CHAR;
@@ -398,29 +393,29 @@ public final class XmlOut implements Sie
         Arrays.fill(CHARACTER_CODES, 0x30FC, 0x30FE, NAME_BODY_CHAR);
 
     }
-    
+
     private final List<CharSequence> prefixesDefined;
     private final Writer writer;
     private final Stack<CharSequence> elementNames;
     private final Set<CharSequence> currentAttributes = new 
HashSet<CharSequence>();
-    
+
     boolean elementsWritten = false;
     boolean inElement = false;
     boolean prologWritten = false;
-    
+
     public XmlOut(final Writer writer) {
         this.writer = writer;
         this.elementNames = new Stack<CharSequence>();
         prefixesDefined = new ArrayList<CharSequence>();
     }
-    
+
     /**
      * Starts a document by writing a prolog.
      * Calling this method is optional.
      * When writing a document fragment, it should <em>not</em> be called.
-     * @throws OperationNotAllowedException 
-     * if called after the first element has been written
-     * or once a prolog has already been written
+     *
+     * @throws OperationNotAllowedException if called after the first element 
has been written
+     *                                      or once a prolog has already been 
written
      */
     public void startDocument() throws IOException {
         if (elementsWritten) {
@@ -432,14 +427,13 @@ public final class XmlOut implements Sie
         writer.write("<?xml version='1.0'?>");
         prologWritten = true;
     }
-    
+
     /**
      * Writes the start of an element.
-     * 
+     *
      * @param elementName the name of the element, not null
-     * @throws InvalidXmlException if the name is not valid for an xml element
-     * @throws OperationNotAllowedException 
-     * if called after the first element has been closed
+     * @throws InvalidXmlException          if the name is not valid for an 
xml element
+     * @throws OperationNotAllowedException if called after the first element 
has been closed
      */
     public void openElement(final CharSequence elementName) throws IOException 
{
         if (elementsWritten && elementNames.isEmpty()) {
@@ -458,25 +452,25 @@ public final class XmlOut implements Sie
         elementNames.push(elementName);
         currentAttributes.clear();
     }
-    
+
     /**
      * Writes an attribute of an element.
      * Note that this is only allowed directly after {@link 
#openElement(CharSequence)}
      * or {@link #attribute}.
-     * 
-     * @param name the attribute name, not null
+     *
+     * @param name  the attribute name, not null
      * @param value the attribute value, not null
-     * @throws InvalidXmlException if the name is not valid for an xml 
attribute 
-     * or if a value for the attribute has already been written
-     * @throws OperationNotAllowedException if called after {@link #content} 
-     * or {@link #closeElement()} or before any call to {@link #openElement}
+     * @throws InvalidXmlException          if the name is not valid for an 
xml attribute
+     *                                      or if a value for the attribute 
has already been written
+     * @throws OperationNotAllowedException if called after {@link #content}
+     *                                      or {@link #closeElement()} or 
before any call to {@link #openElement}
      */
     public void attribute(CharSequence name, CharSequence value) throws 
IOException {
         if (elementNames.isEmpty()) {
             if (elementsWritten) {
                 throw new OperationNotAllowedException("Root element has 
already been closed.");
             } else {
-                throw new OperationNotAllowedException("Close called before an 
element has been opened.");            
+                throw new OperationNotAllowedException("Close called before an 
element has been opened.");
             }
         }
         if (!isValidName(name)) {
@@ -496,27 +490,26 @@ public final class XmlOut implements Sie
         writer.write('\'');
         currentAttributes.add(name);
     }
-    
+
     private void writeAttributeContent(CharSequence content) throws 
IOException {
         writeEscaped(content, true);
     }
 
     /**
      * Writes content.
-     * Calling this method will automatically 
+     * Calling this method will automatically
      * Note that this method does not use CDATA.
-     * 
+     *
      * @param content the content to write
-     * @throws OperationNotAllowedException 
-     * if called before any call to {@link #openElement} 
-     * or after the first element has been closed
+     * @throws OperationNotAllowedException if called before any call to 
{@link #openElement}
+     *                                      or after the first element has 
been closed
      */
     public void content(CharSequence content) throws IOException {
         if (elementNames.isEmpty()) {
             if (elementsWritten) {
                 throw new OperationNotAllowedException("Root element has 
already been closed.");
             } else {
-                throw new OperationNotAllowedException("An element must be 
opened before content can be written.");            
+                throw new OperationNotAllowedException("An element must be 
opened before content can be written.");
             }
         }
         if (inElement) {
@@ -525,14 +518,14 @@ public final class XmlOut implements Sie
         writeBodyContent(content);
         inElement = false;
     }
-    
+
     private void writeBodyContent(final CharSequence content) throws 
IOException {
         writeEscaped(content, false);
     }
 
     private void writeEscaped(final CharSequence content, boolean 
isAttributeContent) throws IOException {
         final int length = content.length();
-        for (int i=0;i<length;i++) {
+        for (int i = 0; i < length; i++) {
             char character = content.charAt(i);
             if (character == '&') {
                 writer.write("&amp;");
@@ -551,28 +544,26 @@ public final class XmlOut implements Sie
             }
         }
     }
-    
+
     private boolean isOutOfRange(final char character) {
-        final boolean result = !ALLOWED_CHARACTERS[character];
-        return result;
+        return !ALLOWED_CHARACTERS[character];
     }
 
     /**
      * Closes the last element written.
-     * 
-     * @throws OperationNotAllowedException 
-     * if called before any call to {@link #openElement} 
-     * or after the first element has been closed
+     *
+     * @throws OperationNotAllowedException if called before any call to 
{@link #openElement}
+     *                                      or after the first element has 
been closed
      */
     public void closeElement() throws IOException {
         if (elementNames.isEmpty()) {
             if (elementsWritten) {
                 throw new OperationNotAllowedException("Root element has 
already been closed.");
             } else {
-                throw new OperationNotAllowedException("Close called before an 
element has been opened.");            
+                throw new OperationNotAllowedException("Close called before an 
element has been opened.");
             }
         }
-        final CharSequence elementName = (CharSequence) elementNames.pop();
+        final CharSequence elementName = elementNames.pop();
         if (inElement) {
             writer.write('/');
             writer.write('>');
@@ -585,41 +576,41 @@ public final class XmlOut implements Sie
         writer.flush();
         inElement = false;
     }
-                                                         
-    
+
+
     /**
      * Closes all pending elements.
      * When appropriate, resources are also flushed and closed.
      * No exception is raised when called upon a document whose
      * root element has already been closed.
-     * @throws OperationNotAllowedException 
-     * if called before any call to {@link #openElement} 
+     *
+     * @throws OperationNotAllowedException if called before any call to 
{@link #openElement}
      */
     public void closeDocument() throws IOException {
         if (elementNames.isEmpty()) {
             if (!elementsWritten) {
-                throw new OperationNotAllowedException("Close called before an 
element has been opened.");            
+                throw new OperationNotAllowedException("Close called before an 
element has been opened.");
             }
         }
-        while(!elementNames.isEmpty()) {
+        while (!elementNames.isEmpty()) {
             closeElement();
         }
         writer.flush();
     }
-    
+
     private void rawWrite(final CharSequence sequence) throws IOException {
-        for (int i=0;i<sequence.length();i++) {
+        for (int i = 0; i < sequence.length(); i++) {
             final char charAt = sequence.charAt(i);
             writer.write(charAt);
         }
     }
-    
+
     private boolean isValidName(final CharSequence sequence) {
         boolean result = true;
         final int length = sequence.length();
-        for (int i=0;i<length;i++) {
+        for (int i = 0; i < length; i++) {
             char character = sequence.charAt(i);
-            if (i==0) {
+            if (i == 0) {
                 if (!isValidNameStart(character)) {
                     result = false;
                     break;
@@ -633,24 +624,22 @@ public final class XmlOut implements Sie
         }
         return result;
     }
-    
+
     private boolean isValidNameStart(final char character) {
         final byte code = CHARACTER_CODES[character];
-        final boolean result = (code & NAME_START_MASK) > 0;
-        return result;
+        return (code & NAME_START_MASK) > 0;
     }
-    
+
     private boolean isValidNameBody(final char character) {
         final byte code = CHARACTER_CODES[character];
-        final boolean result = (code & NAME_MASK) > 0;
-        return result;
+        return (code & NAME_MASK) > 0;
     }
 
     public void attribute(CharSequence localName, CharSequence uri, 
CharSequence prefix, CharSequence value) throws IOException {
         final CharSequence name = toName(localName, uri, prefix);
         attribute(name, value);
     }
-    
+
     private CharSequence toName(CharSequence localName, CharSequence uri, 
CharSequence prefix) {
         final CharSequence name;
         if (prefix == null || "".equals(prefix) || uri == null || 
"".equals(uri)) {

Modified: 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/check/ScriptCheckMailAdapter.java
URL: 
http://svn.apache.org/viewvc/james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/check/ScriptCheckMailAdapter.java?rev=1425888&r1=1425887&r2=1425888&view=diff
==============================================================================
--- 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/check/ScriptCheckMailAdapter.java
 (original)
+++ 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/check/ScriptCheckMailAdapter.java
 Wed Dec 26 12:05:08 2012
@@ -19,17 +19,6 @@
 
 package org.apache.jsieve.util.check;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-
-import javax.mail.Header;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-
 import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.exception.SieveException;
 import org.apache.jsieve.mail.Action;
@@ -39,6 +28,12 @@ import org.apache.jsieve.mail.SieveMailE
 import org.apache.jsieve.parser.address.SieveAddressBuilder;
 import org.apache.jsieve.parser.generated.address.ParseException;
 
+import javax.mail.Header;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import java.io.IOException;
+import java.util.*;
+
 /**
  * Checks script execution for an email. The wrapped email is set by called
  * {@link #setMail}. Actions are recorded on {@link #executedActions} and can
@@ -59,7 +54,7 @@ public class ScriptCheckMailAdapter impl
 
     /**
      * Gets the wrapped email.
-     * 
+     *
      * @return <code>Message</code>, possibly null
      */
     public Message getMail() {
@@ -69,9 +64,8 @@ public class ScriptCheckMailAdapter impl
     /**
      * Sets the wrapped email and {@link #reset}s the adapter ready for another
      * execution.
-     * 
-     * @param mail
-     *                <code>Message</code>, possibly null
+     *
+     * @param mail <code>Message</code>, possibly null
      */
     public void setMail(Message mail) {
         this.mail = mail;
@@ -81,7 +75,7 @@ public class ScriptCheckMailAdapter impl
     /**
      * Method addAction adds an Action to the List of Actions to be performed 
by
      * the receiver.
-     * 
+     *
      * @param action
      */
     public void addAction(final Action action) {
@@ -99,25 +93,23 @@ public class ScriptCheckMailAdapter impl
     /**
      * Gets the actions accumulated when {@link #executedActions} was last
      * called.
-     * 
+     *
      * @return <code>List</code> of {@link Action}s, not null. This list is a
      *         modifiable copy
      */
     public List<Action> getExecutedActions() {
-        final ArrayList<Action> result = new 
ArrayList<Action>(executedActions);
-        return result;
+        return new ArrayList<Action>(executedActions);
     }
 
     /**
      * Method getActions answers the List of Actions accumulated by the
      * receiver. Implementations may elect to supply an unmodifiable 
collection.
-     * 
+     *
      * @return <code>List</code> of {@link Action}'s, not null, possibly
      *         unmodifiable
      */
     public List<Action> getActions() {
-        final List<Action> result = Collections.unmodifiableList(actions);
-        return result;
+        return Collections.unmodifiableList(actions);
     }
 
     /**
@@ -133,7 +125,7 @@ public class ScriptCheckMailAdapter impl
      * Method getHeader answers a List of all of the headers in the receiver
      * whose name is equal to the passed name. If no headers are found an empty
      * List is returned.
-     * 
+     *
      * @param name
      * @return <code>List</code> not null, possibly empty
      * @throws SieveMailException
@@ -157,7 +149,7 @@ public class ScriptCheckMailAdapter impl
     /**
      * Method getHeaderNames answers a List of all of the headers in the
      * receiver. No duplicates are allowed.
-     * 
+     *
      * @return <code>List</code>, not null possible empty, possible
      *         unmodifiable
      * @throws SieveMailException
@@ -169,7 +161,7 @@ public class ScriptCheckMailAdapter impl
             try {
                 results = new ArrayList<String>();
                 for (final Enumeration en = mail.getAllHeaders(); en
-                        .hasMoreElements();) {
+                        .hasMoreElements(); ) {
                     final Header header = (Header) en.nextElement();
                     final String name = header.getName();
                     if (!results.contains(name)) {
@@ -189,14 +181,14 @@ public class ScriptCheckMailAdapter impl
      * receiver with the passed name. If no headers are found an empty List is
      * returned.
      * </p>
-     * 
+     * <p/>
      * <p>
      * This method differs from getHeader(String) in that it ignores case and
      * the whitespace prefixes and suffixes of a header name when performing 
the
      * match, as required by RFC 3028. Thus "From", "from ", " From" and " 
from "
      * are considered equal.
      * </p>
-     * 
+     *
      * @param name
      * @return <code>List</code>, not null possibly empty
      * @throws SieveMailException
@@ -212,7 +204,7 @@ public class ScriptCheckMailAdapter impl
 
     /**
      * Method getSize answers the receiver's message size in octets.
-     * 
+     *
      * @return int
      * @throws SieveMailException
      */
@@ -231,7 +223,7 @@ public class ScriptCheckMailAdapter impl
     /**
      * Method getContentType returns string/mime representation of the message
      * type.
-     * 
+     *
      * @return String
      * @throws SieveMailException
      */
@@ -254,20 +246,18 @@ public class ScriptCheckMailAdapter impl
 
     /**
      * Parses the value from the given message into addresses.
-     * 
-     * @param headerName
-     *                header name, to be matched case insensitively
-     * @param message
-     *                <code>Message</code>, not null
+     *
+     * @param headerName header name, to be matched case insensitively
+     * @param message    <code>Message</code>, not null
      * @return <code>Address</code> array, not null possibly empty
      * @throws SieveMailException
      */
     public Address[] parseAddresses(final String headerName,
-            final Message message) throws SieveMailException {
+                                    final Message message) throws 
SieveMailException {
         try {
-           final SieveAddressBuilder builder = new SieveAddressBuilder();
+            final SieveAddressBuilder builder = new SieveAddressBuilder();
 
-            for (Enumeration en = message.getAllHeaders(); 
en.hasMoreElements();) {
+            for (Enumeration en = message.getAllHeaders(); 
en.hasMoreElements(); ) {
                 final Header header = (Header) en.nextElement();
                 final String name = header.getName();
                 if (name.trim().equalsIgnoreCase(headerName)) {
@@ -279,7 +269,7 @@ public class ScriptCheckMailAdapter impl
             return results;
 
         } catch (MessagingException ex) {
-           throw new SieveMailException(ex);
+            throw new SieveMailException(ex);
         } catch (ParseException ex) {
             throw new SieveMailException(ex);
         }
@@ -299,6 +289,7 @@ public class ScriptCheckMailAdapter impl
         return result;
     }
 
-    public void setContext(SieveContext context) {}
+    public void setContext(SieveContext context) {
+    }
 
 }

Modified: 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/check/ScriptChecker.java
URL: 
http://svn.apache.org/viewvc/james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/check/ScriptChecker.java?rev=1425888&r1=1425887&r2=1425888&view=diff
==============================================================================
--- 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/check/ScriptChecker.java
 (original)
+++ 
james/jsieve/trunk/util/src/main/java/org/apache/jsieve/util/check/ScriptChecker.java
 Wed Dec 26 12:05:08 2012
@@ -65,8 +65,7 @@ public class ScriptChecker {
             throws IOException, MessagingException {
         final FileInputStream messageStream = new FileInputStream(message);
         final FileInputStream scriptStream = new FileInputStream(script);
-        final Results results = check(messageStream, scriptStream);
-        return results;
+        return check(messageStream, scriptStream);
     }
 
     /**
@@ -220,7 +219,7 @@ public class ScriptChecker {
          * Prints out details of results.
          */
         public String toString() {
-            StringBuffer buffer = new StringBuffer("Results: ");
+            StringBuilder buffer = new StringBuilder("Results: ");
             if (pass) {
                 buffer.append("PASS");
             } else {



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to