creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1548464 - /creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/license/SimplePatternBasedLicense.java
Date Fri, 06 Dec 2013 09:35:09 GMT
Author: rdonkin
Date: Fri Dec  6 09:35:09 2013
New Revision: 1548464

URL: http://svn.apache.org/r1548464
Log:
Apply PMD Rules.

Modified:
    creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/license/SimplePatternBasedLicense.java

Modified: creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/license/SimplePatternBasedLicense.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/license/SimplePatternBasedLicense.java?rev=1548464&r1=1548463&r2=1548464&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/license/SimplePatternBasedLicense.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/license/SimplePatternBasedLicense.java
Fri Dec  6 09:35:09 2013
@@ -32,12 +32,8 @@ public class SimplePatternBasedLicense e
 
 	/** The patterns. */
 	private String[] patterns;
-
-	/**
-	 * Instantiates a new simple pattern based license.
-	 */
-	public SimplePatternBasedLicense() {
-	}
+	
+	private static final int ZERO = 0;
 
 	/**
 	 * Instantiates a new simple pattern based license.
@@ -51,8 +47,8 @@ public class SimplePatternBasedLicense e
 	 * @param pPatterns
 	 *            the patterns
 	 */
-	protected SimplePatternBasedLicense(Datum pLicenseFamilyCategory,
-			Datum pLicenseFamilyName, String pNotes, String[] pPatterns) {
+	protected SimplePatternBasedLicense(final Datum pLicenseFamilyCategory,
+			final Datum pLicenseFamilyName, final String pNotes, final String... pPatterns) {
 		super(pLicenseFamilyCategory, pLicenseFamilyName, pNotes);
 		setPatterns(pPatterns);
 	}
@@ -63,7 +59,7 @@ public class SimplePatternBasedLicense e
 	 * @return the patterns
 	 */
 	public String[] getPatterns() {
-		return patterns;
+		return patterns.clone();
 	}
 
 	/**
@@ -72,7 +68,7 @@ public class SimplePatternBasedLicense e
 	 * @param pPatterns
 	 *            the new patterns
 	 */
-	public void setPatterns(String[] pPatterns) {
+	public void setPatterns(final String... pPatterns) {
 		patterns = pPatterns;
 	}
 
@@ -83,18 +79,17 @@ public class SimplePatternBasedLicense e
 	 *            the line
 	 * @return true, if successful
 	 */
-	protected boolean matches(String pLine) {
-		if (pLine != null) {
-			final String[] pttrns = getPatterns();
-			if (pttrns != null) {
-				for (String pttrn : pttrns) {
-					if (pLine.indexOf(pttrn, 0) >= 0) {
-						return true;
-					}
+	protected boolean matches(final String pLine) {
+		boolean resultado = false;
+		final String[] pttrns = getPatterns();
+		if (pLine != null && pttrns != null) {
+			for (String pttrn : pttrns) {
+				if (pLine.indexOf(pttrn, 0) >= ZERO) {
+					resultado = true;
 				}
 			}
 		}
-		return false;
+		return resultado;
 	}
 
 	/*
@@ -113,7 +108,7 @@ public class SimplePatternBasedLicense e
 	 * org.apache.rat.analysis.IHeaderMatcher#match(org.apache.rat.api.Document,
 	 * java.lang.String)
 	 */
-	public boolean match(Document pSubject, String pLine) {
+	public boolean match(final Document pSubject, final String pLine) {
 		final boolean result = matches(pLine);
 		if (result) {
 			reportOnLicense(pSubject);



Mime
View raw message