creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1549239 - /creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/header/HeaderMatcher.java
Date Sun, 08 Dec 2013 21:00:33 GMT
Author: rdonkin
Date: Sun Dec  8 21:00:33 2013
New Revision: 1549239

URL: http://svn.apache.org/r1549239
Log:
Format Code.

Modified:
    creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/header/HeaderMatcher.java

Modified: creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/header/HeaderMatcher.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/header/HeaderMatcher.java?rev=1549239&r1=1549238&r2=1549239&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/header/HeaderMatcher.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/header/HeaderMatcher.java
Sun Dec  8 21:00:33 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat.header;
 
 import java.io.IOException;
@@ -25,80 +25,92 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 /**
- * <p>Matches headers.</p>
- * <p><strong>Usage:</strong></p>
+ * <p>
+ * Matches headers.
+ * </p>
+ * <p>
+ * <strong>Usage:</strong>
+ * </p>
  * <ol>
  * <li>{@link #read(Reader)} content</li>
  * <li>{@link #matches(Pattern)} against filtered content</li>
  * </ol>
- * <p><strong>Note:</strong> use only from a single thread.</p>
- *
+ * <p>
+ * <strong>Note:</strong> use only from a single thread.
+ * </p>
+ * 
  */
 public class HeaderMatcher {
 
-    private final FilteringSequenceFactory factory;
-    private final HeaderBean[] headers;
-    private CharSequence read;
-    private int lines;
-    
-    public HeaderMatcher(final CharFilter filter, final int capacity) {
-        this(filter, capacity, null);
-    }
-    
-    public HeaderMatcher(final CharFilter filter, final int capacity, final HeaderBean[]
headers) {
-        factory = new FilteringSequenceFactory(capacity, filter);
-        read = null;
-        this.headers = headers;
-    }
-    
-    public void read(Reader reader) throws IOException {
-        final LineNumberReader lineNumberReader = new LineNumberReader(reader);
-        read = factory.filter(lineNumberReader);
-        if (lineNumberReader.read() == -1) {
-            lines = lineNumberReader.getLineNumber();
-        } else {
-            lines = -1;
-        }
-        if (headers != null) {
-            final int length = headers.length;
-            for (int i=0;i<length;i++) {
-                final HeaderBean headerBean = headers[i];
-                if (headerBean != null) {
-                    final Pattern headerPattern = headerBean.getHeaderPattern();
-                    if (headerPattern != null) {
-                        final boolean matches = matches(headerPattern);
-                        headerBean.setMatch(matches);
-                    }
-                }
-            }
-        }
-    }
-    
-    /**
-     * <p>Seeks a match in the last headers read.</p>
-     * <p><strong>Note</strong> that this pattern
-     * must not contain filtered characters.
-     * </p>
-     * @param pattern <code>Pattern</code> to match
-     * @return true if the pattern matches,
-     * false otherwise or if {@link #read(Reader)} has not been
-     * called
-     */
-    public boolean matches(Pattern pattern) {
-        boolean result = false;
-        if (read != null) {
-            final Matcher matcher = pattern.matcher(read);
-            result = matcher.matches();
-        }
-        return result;
-    }
-    
-    /**
-     * Number of lines read.
-     * @return the number of lines in the file
-     * or -1 if the file has more lines than were read
-     */
-    public int lines() {
-        return lines;
-    }
+	private final FilteringSequenceFactory factory;
+	private final HeaderBean[] headers;
+	private CharSequence read;
+	private int lines;
+
+	public HeaderMatcher(final CharFilter filter, final int capacity) {
+		this(filter, capacity, null);
+	}
+
+	public HeaderMatcher(final CharFilter filter, final int capacity,
+			final HeaderBean[] headers) {
+		factory = new FilteringSequenceFactory(capacity, filter);
+		read = null;
+		this.headers = headers;
+	}
+
+	public void read(Reader reader) throws IOException {
+		final LineNumberReader lineNumberReader = new LineNumberReader(reader);
+		read = factory.filter(lineNumberReader);
+		if (lineNumberReader.read() == -1) {
+			lines = lineNumberReader.getLineNumber();
+		} else {
+			lines = -1;
+		}
+		if (headers != null) {
+			final int length = headers.length;
+			for (int i = 0; i < length; i++) {
+				final HeaderBean headerBean = headers[i];
+				if (headerBean != null) {
+					final Pattern headerPattern = headerBean.getHeaderPattern();
+					if (headerPattern != null) {
+						final boolean matches = matches(headerPattern);
+						headerBean.setMatch(matches);
+					}
+				}
+			}
+		}
+	}
+
+	/**
+	 * <p>
+	 * Seeks a match in the last headers read.
+	 * </p>
+	 * <p>
+	 * <strong>Note</strong> that this pattern must not contain filtered
+	 * characters.
+	 * </p>
+	 * 
+	 * @param pattern
+	 *            <code>Pattern</code> to match
+	 * @return true if the pattern matches, false otherwise or if
+	 *         {@link #read(Reader)} has not been called
+	 */
+	public boolean matches(Pattern pattern) {
+		boolean result = false;
+		if (read != null) {
+			final Matcher matcher = pattern.matcher(read);
+			result = matcher.matches();
+		}
+		return result;
+	}
+
+	/**
+	 * Number of lines read.
+	 * 
+	 * @return the number of lines in the file or -1 if the file has more lines
+	 *         than were read
+	 */
+	public int lines() {
+		return lines;
+	}
 }



Mime
View raw message