You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by jo...@apache.org on 2009/03/11 03:42:35 UTC
svn commit: r752358 [1/2] - in
/incubator/rat/main/branches/rat-output-semantics: ./ apache-rat-core/
apache-rat-core/src/main/java/org/apache/rat/analysis/
apache-rat-core/src/main/java/org/apache/rat/analysis/generation/
apache-rat-core/src/main/java...
Author: jochen
Date: Wed Mar 11 02:42:33 2009
New Revision: 752358
URL: http://svn.apache.org/viewvc?rev=752358&view=rev
Log:
Initial work on 0.7 with regard to RAT-14: Provide output semantics so that we can easily implement policies.
Added:
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BaseObject.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BasePredicate.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BaseSubject.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/HeaderTypeObject.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IObject.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IPredicate.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/ISubject.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseApprovalObject.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseFamilyCode.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseFamilyName.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/report/claim/MockSubject.java
Modified:
incubator/rat/main/branches/rat-output-semantics/ant-task-examples.xml
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/pom.xml
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/Claims.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/IHeaderMatcher.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/generation/GeneratedLicenseNotRequired.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/generation/JavaDocLicenseNotRequired.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/ApacheSoftwareLicense20.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/BaseLicense.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/DojoLicenseHeader.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/OASISLicense.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/TMF854LicenseHeader.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CDocLicense.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CLicense.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/util/HeaderMatcherMultiplexer.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/AcademicFree21LicenseFamily.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/Apache20LicenseFamily.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/ILicenseFamily.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/ModifiedBSDLicenseFamily.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/OASISLicenseFamily.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/W3CDocumentLicenseFamily.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/W3CSoftwareLicenseFamily.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/AbstractSingleClaimAnalyser.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/ConstantClaimAnalyser.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/DefaultAnalyserFactory.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/DocumentHeaderAnalyser.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/HeaderCheckWorker.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/ReadableArchiveAnalyser.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IClaimReporter.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexer.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/MockLicenseMatcher.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/generation/GeneratedLicenseNotRequiredTest.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/generation/JavaDocLicenseNotRequiredTest.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/license/ApacheSoftwareLicense20Test.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/license/MockStandardLicense.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/license/OASISLicenseTest.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/license/W3CLicenseTest.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/util/MatcherMultiplexerTest.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/policy/DefaultPolicyTest.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/report/analyser/ConstantClaimAnalyserTest.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/report/analyser/HeaderCheckWorkerTest.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/report/claim/impl/xml/MockClaimReporter.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporterTest.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexerTest.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-plugin/pom.xml
incubator/rat/main/branches/rat-output-semantics/apache-rat-plugin/src/test/it1/pom.xml
incubator/rat/main/branches/rat-output-semantics/apache-rat-plugin/src/test/it2/pom.xml
incubator/rat/main/branches/rat-output-semantics/apache-rat-plugin/src/test/it3/pom.xml
incubator/rat/main/branches/rat-output-semantics/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-tasks/pom.xml
incubator/rat/main/branches/rat-output-semantics/apache-rat-tasks/src/test/java/org/example/LicenseFamily.java
incubator/rat/main/branches/rat-output-semantics/apache-rat-tasks/src/test/java/org/example/Matcher.java
incubator/rat/main/branches/rat-output-semantics/apache-rat/pom.xml
incubator/rat/main/branches/rat-output-semantics/pom.xml
Modified: incubator/rat/main/branches/rat-output-semantics/ant-task-examples.xml
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/ant-task-examples.xml?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/ant-task-examples.xml (original)
+++ incubator/rat/main/branches/rat-output-semantics/ant-task-examples.xml Wed Mar 11 02:42:33 2009
@@ -22,7 +22,7 @@
</description>
<property name="src-dir" location="apache-rat-core/src/main/java"/>
- <property name="version" value="0.6-SNAPSHOT"/>
+ <property name="version" value="0.7-SNAPSHOT"/>
<property name="core-jar"
location="apache-rat-core/target/apache-rat-core-${version}.jar"/>
<property name="src-jar"
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/pom.xml?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/pom.xml (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/pom.xml Wed Mar 11 02:42:33 2009
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-project</artifactId>
- <version>0.6-SNAPSHOT</version>
+ <version>0.7-SNAPSHOT</version>
</parent>
<artifactId>apache-rat-core</artifactId>
<packaging>jar</packaging>
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/Claims.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/Claims.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/Claims.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/Claims.java Wed Mar 11 02:42:33 2009
@@ -19,52 +19,56 @@
package org.apache.rat.analysis;
import org.apache.rat.report.RatReportFailedException;
+import org.apache.rat.report.claim.BaseObject;
+import org.apache.rat.report.claim.BasePredicate;
+import org.apache.rat.report.claim.HeaderTypeObject;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.IPredicate;
+import org.apache.rat.report.claim.ISubject;
+import org.apache.rat.report.claim.LicenseApprovalObject;
+import org.apache.rat.report.claim.LicenseFamilyCode;
+import org.apache.rat.report.claim.LicenseFamilyName;
public class Claims {
-
- public static final String LICENSE_APPROVAL_PREDICATE = "license-approval";
- public static final String LICENSE_FAMILY_PREDICATE = "license-family";
- public static final String HEADER_SAMPLE_PREDICATE = "header-sample";
- public static final String HEADER_TYPE_PREDICATE = "header-type";
+ public static final IPredicate TYPE_PREDICATE = new BasePredicate("type");
+ public static final IPredicate ARCHIVE_TYPE_PREDICATE = new BasePredicate("archive-type");
+ public static final IPredicate LICENSE_APPROVAL_PREDICATE = new BasePredicate("license-approval");
+ public static final IPredicate LICENSE_FAMILY_PREDICATE = new BasePredicate("license-family");
+ public static final IPredicate HEADER_SAMPLE_PREDICATE = new BasePredicate("header-sample");
+ public static final IPredicate HEADER_TYPE_PREDICATE = new BasePredicate("header-type");
- public static void reportHeaderSampleClaim(final String sample, final String subject, IClaimReporter reporter) throws RatReportFailedException {
- reporter.claim(subject, HEADER_SAMPLE_PREDICATE, sample, true);
+ public static void reportHeaderSampleClaim(final String sample, final ISubject subject, IClaimReporter reporter) throws RatReportFailedException {
+ reporter.claim(subject, HEADER_SAMPLE_PREDICATE, new BaseObject(sample), true);
}
- public static void reportGeneratedHeaderTypeClaim(final String subject, IClaimReporter reporter) throws RatReportFailedException {
- reportHeaderTypeClaim("GEN ", subject, reporter);
+ public static void reportGeneratedHeaderTypeClaim(final ISubject subject, IClaimReporter reporter) throws RatReportFailedException {
+ reportHeaderTypeClaim(HeaderTypeObject.GENERATED, subject, reporter);
}
- public static void reportHeaderTypeClaim(final String type, final String subject, IClaimReporter reporter) throws RatReportFailedException {
+ public static void reportHeaderTypeClaim(final HeaderTypeObject type, final ISubject subject, IClaimReporter reporter) throws RatReportFailedException {
reporter.claim(subject, HEADER_TYPE_PREDICATE, type, false);
}
- public static void reportGeneratedClaims(final String subject, final String notes, final IClaimReporter reporter) throws RatReportFailedException {
+ public static void reportGeneratedClaims(final ISubject subject, final String notes, final IClaimReporter reporter) throws RatReportFailedException {
Claims.reportHeaderSampleClaim(notes, subject, reporter);
Claims.reportGeneratedHeaderTypeClaim(subject, reporter);
}
- public static void reportStandardClaims(final String subject, final String notes, final String code, final String name, final IClaimReporter reporter) throws RatReportFailedException {
+ public static void reportStandardClaims(final ISubject subject, final String notes, final HeaderTypeObject code, final LicenseFamilyName name, final IClaimReporter reporter) throws RatReportFailedException {
Claims.reportHeaderTypeClaim(code, subject, reporter);
Claims.reportHeaderSampleClaim(notes, subject, reporter);
-
reporter.claim(subject, LICENSE_FAMILY_PREDICATE, name, false);
}
- public static void reportLicenseApprovalClaim(final CharSequence subject, final boolean isAcceptable, final IClaimReporter reporter) throws RatReportFailedException {
- // TODO: replace with more finely grained system
- final String approvalValue = Boolean.toString(isAcceptable);
- // TODO: not very readable;
- // TODO: replace when license approval factored into separate phase
- // TODO: probably name='ASF'
- reporter.claim(subject, LICENSE_APPROVAL_PREDICATE, approvalValue, false);
+ public static void reportLicenseApprovalClaim(final ISubject subject, final boolean isAcceptable, final IClaimReporter reporter) throws RatReportFailedException {
+ final LicenseApprovalObject object = isAcceptable ? LicenseApprovalObject.TRUE : LicenseApprovalObject.FALSE;
+ reporter.claim(subject, LICENSE_APPROVAL_PREDICATE, object, false);
}
- public static final String ASL_CODE = "AL ";
- public static final String OASIS_CODE = "OASIS";
- public static final String W3CD_CODE = "W3CD ";
- public static final String W3C_CODE = "W3C ";
- public static final String DOJO = "DOJO ";
- public static final String TMF854 = "TMF ";
+ public static final LicenseFamilyCode ASL_CODE = new LicenseFamilyCode("AL ");
+ public static final LicenseFamilyCode OASIS_CODE = new LicenseFamilyCode("OASIS");
+ public static final LicenseFamilyCode W3CD_CODE = new LicenseFamilyCode("W3CD ");
+ public static final LicenseFamilyCode W3C_CODE = new LicenseFamilyCode("W3C ");
+ public static final LicenseFamilyCode DOJO = new LicenseFamilyCode("DOJO ");
+ public static final LicenseFamilyCode TMF854 = new LicenseFamilyCode("TMF ");
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/IHeaderMatcher.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/IHeaderMatcher.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/IHeaderMatcher.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/IHeaderMatcher.java Wed Mar 11 02:42:33 2009
@@ -19,6 +19,7 @@
package org.apache.rat.analysis;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
/**
* Matches text headers to known licenses.
@@ -40,6 +41,5 @@
* @param reporter TODO
* @return TODO
*/
- public boolean match(String subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException;
-
+ public boolean match(ISubject subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException;
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/generation/GeneratedLicenseNotRequired.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/generation/GeneratedLicenseNotRequired.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/generation/GeneratedLicenseNotRequired.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/generation/GeneratedLicenseNotRequired.java Wed Mar 11 02:42:33 2009
@@ -25,6 +25,7 @@
import org.apache.rat.analysis.RatHeaderAnalysisException;
import org.apache.rat.report.RatReportFailedException;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
public class GeneratedLicenseNotRequired implements IHeaderMatcher {
@@ -64,7 +65,7 @@
this.numberOfPatterns = linePatterns.length;
}
- public boolean match(String subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ public boolean match(ISubject subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
boolean result = false;
for (int i=0;i<numberOfPatterns;i++) {
if (linePatterns[i].matcher(line).matches()) {
@@ -76,7 +77,7 @@
return result;
}
- private void reportOnLicense(String subject, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ private void reportOnLicense(ISubject subject, IClaimReporter reporter) throws RatHeaderAnalysisException {
try {
Claims.reportGeneratedClaims(subject, "Generated files do not required license headers", reporter);
} catch (RatReportFailedException e) {
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/generation/JavaDocLicenseNotRequired.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/generation/JavaDocLicenseNotRequired.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/generation/JavaDocLicenseNotRequired.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/generation/JavaDocLicenseNotRequired.java Wed Mar 11 02:42:33 2009
@@ -25,6 +25,7 @@
import org.apache.rat.analysis.RatHeaderAnalysisException;
import org.apache.rat.report.RatReportFailedException;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
/**
* JavaDocs are generated and so no license is required.
@@ -36,7 +37,7 @@
private static final Pattern JAVADOC_REGEX = Pattern.compile(JAVADOC_REGEX_DEFN);
- public boolean match(String subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ public boolean match(ISubject subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
boolean result = JAVADOC_REGEX.matcher(line).matches();
if (result) {
reportOnLicense(subject, reporter);
@@ -44,7 +45,7 @@
return result;
}
- private void reportOnLicense(String subject, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ private void reportOnLicense(ISubject subject, IClaimReporter reporter) throws RatHeaderAnalysisException {
try {
Claims.reportGeneratedClaims(subject, "JavaDocs are generated and so license header is optional", reporter);
} catch (RatReportFailedException e) {
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/ApacheSoftwareLicense20.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/ApacheSoftwareLicense20.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/ApacheSoftwareLicense20.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/ApacheSoftwareLicense20.java Wed Mar 11 02:42:33 2009
@@ -23,6 +23,7 @@
import org.apache.rat.analysis.RatHeaderAnalysisException;
import org.apache.rat.license.Apache20LicenseFamily;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
/**
* Matches Apache Software License, Version 2.0
@@ -38,7 +39,7 @@
super(Claims.ASL_CODE, Apache20LicenseFamily.APACHE_SOFTWARE_LICENSE_NAME, "");
}
- public boolean match(String subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ public boolean match(ISubject subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
final boolean result = matches(line);
if (result) {
reportOnLicense(subject, reporter);
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/BaseLicense.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/BaseLicense.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/BaseLicense.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/BaseLicense.java Wed Mar 11 02:42:33 2009
@@ -22,22 +22,25 @@
import org.apache.rat.analysis.RatHeaderAnalysisException;
import org.apache.rat.report.RatReportFailedException;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
+import org.apache.rat.report.claim.LicenseFamilyCode;
+import org.apache.rat.report.claim.LicenseFamilyName;
public class BaseLicense {
- private final String code;
- private final String name;
+ private final LicenseFamilyCode code;
+ private final LicenseFamilyName name;
private final String notes;
- public BaseLicense(final String code, final String name, final String notes)
+ public BaseLicense(final LicenseFamilyCode code, final LicenseFamilyName name, final String notes)
{
this.code = code;
this.name = name;
this.notes = notes;
}
- public final void reportOnLicense(String subject, IClaimReporter reporter) throws RatHeaderAnalysisException {
- final String name = getName();
- final String code = getCode();
+ public final void reportOnLicense(ISubject subject, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ final LicenseFamilyName name = getName();
+ final LicenseFamilyCode code = getCode();
final String notes = getNotes();
try {
Claims.reportStandardClaims(subject, notes, code, name, reporter);
@@ -48,11 +51,11 @@
}
}
- public String getCode() {
+ public LicenseFamilyCode getCode() {
return code;
}
- public String getName() {
+ public LicenseFamilyName getName() {
return name;
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/DojoLicenseHeader.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/DojoLicenseHeader.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/DojoLicenseHeader.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/DojoLicenseHeader.java Wed Mar 11 02:42:33 2009
@@ -23,6 +23,7 @@
import org.apache.rat.analysis.RatHeaderAnalysisException;
import org.apache.rat.license.ModifiedBSDLicenseFamily;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
public class DojoLicenseHeader extends BaseLicense implements IHeaderMatcher {
@@ -49,7 +50,7 @@
}
- public boolean match(String subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ public boolean match(ISubject subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
final boolean result = matches(line);
if (result) {
reportOnLicense(subject, reporter);
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/OASISLicense.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/OASISLicense.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/OASISLicense.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/OASISLicense.java Wed Mar 11 02:42:33 2009
@@ -25,6 +25,7 @@
import org.apache.rat.analysis.RatHeaderAnalysisException;
import org.apache.rat.license.OASISLicenseFamily;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
/**
* Looks for documents contain the OASIS copyright claim plus derivative work clause.
@@ -48,7 +49,7 @@
super(Claims.OASIS_CODE, OASISLicenseFamily.OASIS_OPEN_LICENSE_NAME, "No modifications allowed");
}
- public boolean match(String subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ public boolean match(ISubject subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
boolean result = false;
if (copyrightMatch) {
line = line.toLowerCase();
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/TMF854LicenseHeader.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/TMF854LicenseHeader.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/TMF854LicenseHeader.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/TMF854LicenseHeader.java Wed Mar 11 02:42:33 2009
@@ -23,6 +23,7 @@
import org.apache.rat.analysis.RatHeaderAnalysisException;
import org.apache.rat.license.ModifiedBSDLicenseFamily;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
public class TMF854LicenseHeader extends BaseLicense implements IHeaderMatcher {
@@ -41,7 +42,7 @@
}
- public boolean match(String subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ public boolean match(ISubject subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
final boolean result = matches(line);
if (result) {
reportOnLicense(subject, reporter);
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CDocLicense.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CDocLicense.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CDocLicense.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CDocLicense.java Wed Mar 11 02:42:33 2009
@@ -20,6 +20,7 @@
import org.apache.rat.analysis.RatHeaderAnalysisException;
import org.apache.rat.license.W3CDocumentLicenseFamily;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
public class W3CDocLicense extends BaseLicense implements IHeaderMatcher {
@@ -33,7 +34,7 @@
}
- public boolean match(String subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ public boolean match(ISubject subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
boolean result = line != null && line.indexOf(COPYRIGHT_URL) != -1;
if (result) {
reportOnLicense(subject, reporter);
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CLicense.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CLicense.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CLicense.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CLicense.java Wed Mar 11 02:42:33 2009
@@ -23,6 +23,7 @@
import org.apache.rat.analysis.RatHeaderAnalysisException;
import org.apache.rat.license.W3CSoftwareLicenseFamily;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
public class W3CLicense extends BaseLicense implements IHeaderMatcher {
@@ -36,7 +37,7 @@
}
- public boolean match(String subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ public boolean match(ISubject subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
boolean result = line != null && line.indexOf(COPYRIGHT_URL) != -1;
if (result) {
reportOnLicense(subject, reporter);
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/util/HeaderMatcherMultiplexer.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/util/HeaderMatcherMultiplexer.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/util/HeaderMatcherMultiplexer.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/analysis/util/HeaderMatcherMultiplexer.java Wed Mar 11 02:42:33 2009
@@ -21,6 +21,7 @@
import org.apache.rat.analysis.IHeaderMatcher;
import org.apache.rat.analysis.RatHeaderAnalysisException;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
/**
* Delegates to an ordered set of matchers.
@@ -36,7 +37,7 @@
numberOfMatchers = matchers.length;
}
- public boolean match(String subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
+ public boolean match(ISubject subject, String line, IClaimReporter reporter) throws RatHeaderAnalysisException {
boolean result = false;
for (int i=0;i<numberOfMatchers;i++) {
result = matchers[i].match(subject, line, reporter);
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/AcademicFree21LicenseFamily.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/AcademicFree21LicenseFamily.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/AcademicFree21LicenseFamily.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/AcademicFree21LicenseFamily.java Wed Mar 11 02:42:33 2009
@@ -18,11 +18,12 @@
*/
package org.apache.rat.license;
-public class AcademicFree21LicenseFamily implements ILicenseFamily {
+import org.apache.rat.report.claim.LicenseFamilyName;
- public static final String ACADEMIC_FREE_LICENSE_FAMILY = "Academic Free License, Version 2.1";
+public class AcademicFree21LicenseFamily implements ILicenseFamily {
+ public static final LicenseFamilyName ACADEMIC_FREE_LICENSE_FAMILY = new LicenseFamilyName("Academic Free License, Version 2.1");
- public String getFamilyName() {
+ public LicenseFamilyName getFamilyName() {
return ACADEMIC_FREE_LICENSE_FAMILY;
}
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/Apache20LicenseFamily.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/Apache20LicenseFamily.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/Apache20LicenseFamily.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/Apache20LicenseFamily.java Wed Mar 11 02:42:33 2009
@@ -18,11 +18,12 @@
*/
package org.apache.rat.license;
-public final class Apache20LicenseFamily implements ILicenseFamily {
+import org.apache.rat.report.claim.LicenseFamilyName;
- public static final String APACHE_SOFTWARE_LICENSE_NAME = "Apache License Version 2.0";
+public final class Apache20LicenseFamily implements ILicenseFamily {
+ public static final LicenseFamilyName APACHE_SOFTWARE_LICENSE_NAME = new LicenseFamilyName("Apache License Version 2.0");
- public String getFamilyName() {
+ public LicenseFamilyName getFamilyName() {
return APACHE_SOFTWARE_LICENSE_NAME;
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/ILicenseFamily.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/ILicenseFamily.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/ILicenseFamily.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/ILicenseFamily.java Wed Mar 11 02:42:33 2009
@@ -18,6 +18,8 @@
*/
package org.apache.rat.license;
+import org.apache.rat.report.claim.LicenseFamilyName;
+
public interface ILicenseFamily {
- public String getFamilyName();
+ public LicenseFamilyName getFamilyName();
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/ModifiedBSDLicenseFamily.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/ModifiedBSDLicenseFamily.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/ModifiedBSDLicenseFamily.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/ModifiedBSDLicenseFamily.java Wed Mar 11 02:42:33 2009
@@ -18,13 +18,12 @@
*/
package org.apache.rat.license;
-public class ModifiedBSDLicenseFamily implements ILicenseFamily {
+import org.apache.rat.report.claim.LicenseFamilyName;
- public static final String MODIFIED_BSD_LICENSE_NAME = "Modified BSD License";
+public class ModifiedBSDLicenseFamily implements ILicenseFamily {
+ public static final LicenseFamilyName MODIFIED_BSD_LICENSE_NAME = new LicenseFamilyName("Modified BSD License");
- public String getFamilyName() {
+ public LicenseFamilyName getFamilyName() {
return MODIFIED_BSD_LICENSE_NAME;
}
-
-
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/OASISLicenseFamily.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/OASISLicenseFamily.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/OASISLicenseFamily.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/OASISLicenseFamily.java Wed Mar 11 02:42:33 2009
@@ -18,11 +18,12 @@
*/
package org.apache.rat.license;
-public final class OASISLicenseFamily implements ILicenseFamily {
+import org.apache.rat.report.claim.LicenseFamilyName;
- public static final String OASIS_OPEN_LICENSE_NAME = "OASIS Open License";
+public final class OASISLicenseFamily implements ILicenseFamily {
+ public static final LicenseFamilyName OASIS_OPEN_LICENSE_NAME = new LicenseFamilyName("OASIS Open License");
- public String getFamilyName() {
+ public LicenseFamilyName getFamilyName() {
return OASIS_OPEN_LICENSE_NAME;
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/W3CDocumentLicenseFamily.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/W3CDocumentLicenseFamily.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/W3CDocumentLicenseFamily.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/W3CDocumentLicenseFamily.java Wed Mar 11 02:42:33 2009
@@ -18,11 +18,12 @@
*/
package org.apache.rat.license;
-public class W3CDocumentLicenseFamily implements ILicenseFamily {
+import org.apache.rat.report.claim.LicenseFamilyName;
- public static final String W3C_DOCUMENT_COPYRIGHT_NAME = "W3C Document Copyright";
+public class W3CDocumentLicenseFamily implements ILicenseFamily {
+ public static final LicenseFamilyName W3C_DOCUMENT_COPYRIGHT_NAME = new LicenseFamilyName("W3C Document Copyright");
- public String getFamilyName() {
+ public LicenseFamilyName getFamilyName() {
return W3C_DOCUMENT_COPYRIGHT_NAME;
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/W3CSoftwareLicenseFamily.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/W3CSoftwareLicenseFamily.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/W3CSoftwareLicenseFamily.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/license/W3CSoftwareLicenseFamily.java Wed Mar 11 02:42:33 2009
@@ -18,12 +18,12 @@
*/
package org.apache.rat.license;
-public class W3CSoftwareLicenseFamily implements ILicenseFamily {
+import org.apache.rat.report.claim.LicenseFamilyName;
- public static final String W3C_SOFTWARE_COPYRIGHT_NAME = "W3C Software Copyright";
+public class W3CSoftwareLicenseFamily implements ILicenseFamily {
+ public static final LicenseFamilyName W3C_SOFTWARE_COPYRIGHT_NAME = new LicenseFamilyName("W3C Software Copyright");
- public String getFamilyName() {
+ public LicenseFamilyName getFamilyName() {
return W3C_SOFTWARE_COPYRIGHT_NAME;
}
-
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java Wed Mar 11 02:42:33 2009
@@ -19,6 +19,7 @@
package org.apache.rat.policy;
import java.util.Arrays;
+import java.util.Comparator;
import org.apache.rat.analysis.Claims;
import org.apache.rat.license.Apache20LicenseFamily;
@@ -29,20 +30,23 @@
import org.apache.rat.license.W3CSoftwareLicenseFamily;
import org.apache.rat.report.RatReportFailedException;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.IObject;
+import org.apache.rat.report.claim.IPredicate;
+import org.apache.rat.report.claim.ISubject;
+import org.apache.rat.report.claim.LicenseFamilyName;
public class DefaultPolicy implements IClaimReporter {
-
- private static final String[] APPROVED_LICENSES = {
+ private static final LicenseFamilyName[] APPROVED_LICENSES = {
Apache20LicenseFamily.APACHE_SOFTWARE_LICENSE_NAME, OASISLicenseFamily.OASIS_OPEN_LICENSE_NAME,
W3CSoftwareLicenseFamily.W3C_SOFTWARE_COPYRIGHT_NAME, W3CDocumentLicenseFamily.W3C_DOCUMENT_COPYRIGHT_NAME,
ModifiedBSDLicenseFamily.MODIFIED_BSD_LICENSE_NAME
};
- private static final String[] toNames(final ILicenseFamily[] approvedLicenses) {
- String[] results = null;
+ private static final LicenseFamilyName[] toNames(final ILicenseFamily[] approvedLicenses) {
+ LicenseFamilyName[] results = null;
if (approvedLicenses != null) {
final int length = approvedLicenses.length;
- results = new String[length];
+ results = new LicenseFamilyName[length];
for (int i=0;i<length;i++) {
results[i] = approvedLicenses[i].getFamilyName();
}
@@ -51,7 +55,7 @@
}
private final IClaimReporter reporter;
- private final String[] approvedLicenseNames;
+ private final LicenseFamilyName[] approvedLicenseNames;
public DefaultPolicy(final IClaimReporter reporter) {
this(reporter, APPROVED_LICENSES);
@@ -60,25 +64,30 @@
public DefaultPolicy(final IClaimReporter reporter, final ILicenseFamily[] approvedLicenses) {
this(reporter, toNames(approvedLicenses));
}
+
+ private static final Comparator licenseFamilyComparator = new Comparator(){
+ public int compare(Object arg0, Object arg1) {
+ return ((LicenseFamilyName) arg0).getValue().compareTo(((LicenseFamilyName) arg1).getValue());
+ }
+ };
- public DefaultPolicy(final IClaimReporter reporter, final String[] approvedLicenseNames) {
- super();
+ public DefaultPolicy(final IClaimReporter reporter, final LicenseFamilyName[] approvedLicenseNames) {
this.reporter = reporter;
if (approvedLicenseNames == null) {
this.approvedLicenseNames = APPROVED_LICENSES;
} else {
final int length = approvedLicenseNames.length;
- this.approvedLicenseNames = new String[length];
+ this.approvedLicenseNames = new LicenseFamilyName[length];
System.arraycopy(approvedLicenseNames, 0, this.approvedLicenseNames, 0, length);
}
- Arrays.sort(this.approvedLicenseNames);
+ Arrays.sort(this.approvedLicenseNames, licenseFamilyComparator);
}
- public void claim(CharSequence subject, CharSequence predicate,
- CharSequence object, boolean isLiteral)
+ public void claim(ISubject subject, IPredicate predicate,
+ IObject object, boolean isLiteral)
throws RatReportFailedException {
if (Claims.LICENSE_FAMILY_PREDICATE.equals(predicate)) {
- final boolean isApproved = Arrays.binarySearch(approvedLicenseNames, object) >= 0;
+ final boolean isApproved = Arrays.binarySearch(approvedLicenseNames, object, licenseFamilyComparator) >= 0;
Claims.reportLicenseApprovalClaim(subject, isApproved, reporter);
}
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/AbstractSingleClaimAnalyser.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/AbstractSingleClaimAnalyser.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/AbstractSingleClaimAnalyser.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/AbstractSingleClaimAnalyser.java Wed Mar 11 02:42:33 2009
@@ -22,15 +22,19 @@
import org.apache.rat.document.IDocumentAnalyser;
import org.apache.rat.document.RatDocumentAnalysisException;
import org.apache.rat.report.RatReportFailedException;
+import org.apache.rat.report.claim.BaseSubject;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.IObject;
+import org.apache.rat.report.claim.IPredicate;
+import org.apache.rat.report.claim.ISubject;
public abstract class AbstractSingleClaimAnalyser implements IDocumentAnalyser {
private final IClaimReporter reporter;
- private final CharSequence predicate;
+ private final IPredicate predicate;
private final boolean isLiteral;
- public AbstractSingleClaimAnalyser(final IClaimReporter reporter, final CharSequence predicate,
+ public AbstractSingleClaimAnalyser(final IClaimReporter reporter, final IPredicate predicate,
final boolean isLiteral) {
super();
this.reporter = reporter;
@@ -39,14 +43,14 @@
}
public void analyse(IDocument document) throws RatDocumentAnalysisException {
- final String name = document.getName();
+ final ISubject name = new BaseSubject(document);
try {
- final CharSequence object = toObject(document);
+ final IObject object = toObject(document);
reporter.claim(name, predicate, object, isLiteral);
} catch (RatReportFailedException e) {
throw new RatReportAnalysisResultException(e);
}
}
- protected abstract CharSequence toObject(final IDocument document) throws RatDocumentAnalysisException;
+ protected abstract IObject toObject(final IDocument document) throws RatDocumentAnalysisException;
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/ConstantClaimAnalyser.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/ConstantClaimAnalyser.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/ConstantClaimAnalyser.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/ConstantClaimAnalyser.java Wed Mar 11 02:42:33 2009
@@ -20,19 +20,21 @@
import org.apache.rat.document.IDocument;
import org.apache.rat.document.RatDocumentAnalysisException;
+import org.apache.rat.report.claim.HeaderTypeObject;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.IObject;
+import org.apache.rat.report.claim.IPredicate;
public class ConstantClaimAnalyser extends AbstractSingleClaimAnalyser {
+ private final HeaderTypeObject object;
- private final CharSequence object;
- public ConstantClaimAnalyser(final IClaimReporter reporter, final CharSequence predicate,
- final CharSequence object, final boolean isLiteral) {
+ public ConstantClaimAnalyser(final IClaimReporter reporter, final IPredicate predicate,
+ final HeaderTypeObject object, final boolean isLiteral) {
super(reporter, predicate, isLiteral);
this.object = object;
}
- protected CharSequence toObject(IDocument document) throws RatDocumentAnalysisException {
+ protected IObject toObject(IDocument document) throws RatDocumentAnalysisException {
return object;
}
-
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/DefaultAnalyserFactory.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/DefaultAnalyserFactory.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/DefaultAnalyserFactory.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/DefaultAnalyserFactory.java Wed Mar 11 02:42:33 2009
@@ -18,6 +18,7 @@
*/
package org.apache.rat.report.analyser;
+import org.apache.rat.analysis.Claims;
import org.apache.rat.analysis.IHeaderMatcher;
import org.apache.rat.document.IDocumentAnalyser;
import org.apache.rat.document.IDocumentMatcher;
@@ -28,6 +29,7 @@
import org.apache.rat.document.impl.util.DocumentAnalyserMultiplexer;
import org.apache.rat.document.impl.util.DocumentMatcherMultiplexer;
import org.apache.rat.document.impl.util.MatchNegator;
+import org.apache.rat.report.claim.HeaderTypeObject;
import org.apache.rat.report.claim.IClaimReporter;
/**
@@ -37,22 +39,22 @@
public class DefaultAnalyserFactory {
public static final IDocumentAnalyser createArchiveTypeAnalyser(final IClaimReporter reporter) {
- final AbstractSingleClaimAnalyser constantClaimAnalyser = new ConstantClaimAnalyser(reporter, "type", "archive", false);
+ final AbstractSingleClaimAnalyser constantClaimAnalyser = new ConstantClaimAnalyser(reporter, Claims.TYPE_PREDICATE, HeaderTypeObject.ARCHIVE, false);
return constantClaimAnalyser;
}
public static final IDocumentAnalyser createNoticeTypeAnalyser(final IClaimReporter reporter) {
- final AbstractSingleClaimAnalyser constantClaimAnalyser = new ConstantClaimAnalyser(reporter, "type", "notice", false);
+ final AbstractSingleClaimAnalyser constantClaimAnalyser = new ConstantClaimAnalyser(reporter, Claims.TYPE_PREDICATE, HeaderTypeObject.NOTICE, false);
return constantClaimAnalyser;
}
public static final IDocumentAnalyser createBinaryTypeAnalyser(final IClaimReporter reporter) {
- final AbstractSingleClaimAnalyser constantClaimAnalyser = new ConstantClaimAnalyser(reporter, "type", "binary", false);
+ final AbstractSingleClaimAnalyser constantClaimAnalyser = new ConstantClaimAnalyser(reporter, Claims.TYPE_PREDICATE, HeaderTypeObject.BINARY, false);
return constantClaimAnalyser;
}
public static final IDocumentAnalyser createStandardTypeAnalyser(final IClaimReporter reporter) {
- final AbstractSingleClaimAnalyser constantClaimAnalyser = new ConstantClaimAnalyser(reporter, "type", "standard", false);
+ final AbstractSingleClaimAnalyser constantClaimAnalyser = new ConstantClaimAnalyser(reporter, Claims.TYPE_PREDICATE, HeaderTypeObject.STANDARD, false);
return constantClaimAnalyser;
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/DocumentHeaderAnalyser.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/DocumentHeaderAnalyser.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/DocumentHeaderAnalyser.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/DocumentHeaderAnalyser.java Wed Mar 11 02:42:33 2009
@@ -26,7 +26,9 @@
import org.apache.rat.document.IDocument;
import org.apache.rat.document.IDocumentAnalyser;
import org.apache.rat.document.RatDocumentAnalysisException;
+import org.apache.rat.report.claim.BaseSubject;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
public class DocumentHeaderAnalyser implements IDocumentAnalyser {
@@ -44,9 +46,9 @@
Reader reader = null;
try {
reader = document.reader();
- final String name = document.getName();
+ final ISubject subject = new BaseSubject(document);
// TODO: worker function should be moved into this class
- HeaderCheckWorker worker = new HeaderCheckWorker(reader, matcher, reporter, name);
+ HeaderCheckWorker worker = new HeaderCheckWorker(reader, matcher, reporter, subject);
worker.read();
} catch (IOException e) {
throw new RatDocumentAnalysisException("Cannot read header", e);
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/HeaderCheckWorker.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/HeaderCheckWorker.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/HeaderCheckWorker.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/HeaderCheckWorker.java Wed Mar 11 02:42:33 2009
@@ -26,7 +26,10 @@
import org.apache.rat.analysis.IHeaderMatcher;
import org.apache.rat.analysis.RatHeaderAnalysisException;
import org.apache.rat.report.RatReportFailedException;
+import org.apache.rat.report.claim.HeaderTypeObject;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
+import org.apache.rat.report.claim.LicenseFamilyName;
/**
* <p>Reads from a stream to check license.</p>
@@ -40,7 +43,7 @@
private final BufferedReader reader;
private final IHeaderMatcher matcher;
private final IClaimReporter reporter;
- private final String name;
+ private final ISubject name;
private boolean match = false;
@@ -48,7 +51,7 @@
private boolean finished = false;
public HeaderCheckWorker(Reader reader, int numberOfRetainedHeaderLine,
- final IHeaderMatcher matcher, final IClaimReporter reporter, final String name) {
+ final IHeaderMatcher matcher, final IClaimReporter reporter, final ISubject name) {
this(new BufferedReader(reader), numberOfRetainedHeaderLine, matcher, reporter, name);
}
@@ -59,24 +62,24 @@
* @param name the name of the checked content, possibly null
* @param reader a <code>Reader</code> for the content, not null
*/
- public HeaderCheckWorker(Reader reader, final IHeaderMatcher matcher, final IClaimReporter reporter, final String name) {
+ public HeaderCheckWorker(Reader reader, final IHeaderMatcher matcher, final IClaimReporter reporter, final ISubject name) {
this(new BufferedReader(reader), matcher, reporter, name);
}
public HeaderCheckWorker(BufferedReader reader, final IHeaderMatcher matcher,
- final IClaimReporter reporter, final String name) {
+ final IClaimReporter reporter, final ISubject name) {
this(reader, DEFAULT_NUMBER_OF_RETAINED_HEADER_LINES, matcher, reporter, name);
}
public HeaderCheckWorker(BufferedReader reader, int numberOfRetainedHeaderLine, final IHeaderMatcher matcher,
- final IClaimReporter reporter, final String name) {
+ final IClaimReporter reporter, final ISubject name) {
this.reader = reader;
this.numberOfRetainedHeaderLines = numberOfRetainedHeaderLine;
this.matcher = matcher;
this.reporter = reporter;
this.name = name;
- }
-
+ }
+
public boolean isFinished() {
return finished;
}
@@ -90,7 +93,7 @@
if (!match) {
final String notes = headers.toString();
// TODO: this should be factored into a header matcher
- Claims.reportStandardClaims(name, notes, "?????", "UNKNOWN", reporter);
+ Claims.reportStandardClaims(name, notes, HeaderTypeObject.UNKNOWN, LicenseFamilyName.UNKNOWN_LICENSE_FAMILY, reporter);
}
} catch (IOException e) {
throw new RatHeaderAnalysisException("Cannot read header for " + name, e);
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/ReadableArchiveAnalyser.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/ReadableArchiveAnalyser.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/ReadableArchiveAnalyser.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/analyser/ReadableArchiveAnalyser.java Wed Mar 11 02:42:33 2009
@@ -20,22 +20,24 @@
import java.io.IOException;
+import org.apache.rat.analysis.Claims;
import org.apache.rat.document.IDocument;
import org.apache.rat.document.IDocumentCollection;
import org.apache.rat.document.RatDocumentAnalysisException;
+import org.apache.rat.report.claim.BaseObject;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.IObject;
public final class ReadableArchiveAnalyser extends AbstractSingleClaimAnalyser {
-
- public static final String READABLE_ARCHIVE_VALUE = "readable";
- public static final String UNREADABLE_ARCHIVE_VALUE = "unreadable";
+ public static final IObject READABLE_ARCHIVE_VALUE = new BaseObject("readable");
+ public static final IObject UNREADABLE_ARCHIVE_VALUE = new BaseObject("unreadable");
public ReadableArchiveAnalyser(IClaimReporter reporter) {
- super(reporter, "archive-type", false);
+ super(reporter, Claims.ARCHIVE_TYPE_PREDICATE, false);
}
- protected CharSequence toObject(IDocument document) throws RatDocumentAnalysisException {
+ protected IObject toObject(IDocument document) throws RatDocumentAnalysisException {
boolean readable = false;
try {
final IDocumentCollection contents = document.readArchive();
@@ -45,11 +47,9 @@
} catch (IOException e) {
readable = false;
}
- String result = UNREADABLE_ARCHIVE_VALUE;
if (readable) {
- result = READABLE_ARCHIVE_VALUE;
+ return READABLE_ARCHIVE_VALUE;
}
- return result;
+ return UNREADABLE_ARCHIVE_VALUE;
}
-
}
Added: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BaseObject.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BaseObject.java?rev=752358&view=auto
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BaseObject.java (added)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BaseObject.java Wed Mar 11 02:42:33 2009
@@ -0,0 +1,31 @@
+package org.apache.rat.report.claim;
+
+
+/**
+ * Default implementation of {@link IObject}.
+ */
+public class BaseObject implements IObject {
+ private final String value;
+
+ /**
+ * Creates a new instance with the given value.
+ */
+ public BaseObject(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public boolean equals(Object other) {
+ if (other == null || getClass() != other.getClass()) {
+ return false;
+ }
+ return value.equals(((BaseObject) other).value);
+ }
+
+ public int hashCode() {
+ return value.hashCode();
+ }
+}
Added: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BasePredicate.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BasePredicate.java?rev=752358&view=auto
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BasePredicate.java (added)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BasePredicate.java Wed Mar 11 02:42:33 2009
@@ -0,0 +1,31 @@
+package org.apache.rat.report.claim;
+
+
+/**
+ * Default implementation of {@link IPredicate}.
+ */
+public class BasePredicate implements IPredicate {
+ private final String name;
+
+ /**
+ * Creates a new instance.
+ */
+ public BasePredicate(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean equals(Object other) {
+ if (other == null || getClass() != other.getClass()) {
+ return false;
+ }
+ return name.equals(((BasePredicate) other).name);
+ }
+
+ public int hashCode() {
+ return name.hashCode();
+ }
+}
Added: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BaseSubject.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BaseSubject.java?rev=752358&view=auto
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BaseSubject.java (added)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/BaseSubject.java Wed Mar 11 02:42:33 2009
@@ -0,0 +1,33 @@
+package org.apache.rat.report.claim;
+
+import org.apache.rat.document.IDocument;
+
+
+
+/**
+ * Default implementation of {@link ISubject}.
+ */
+public class BaseSubject implements ISubject {
+ private final IDocument doc;
+
+ /**
+ * Creates a new instance.
+ */
+ public BaseSubject(IDocument document) {
+ if (document == null) {
+ throw new IllegalArgumentException("The document must not be null.");
+ }
+ doc = document;
+ }
+
+ public String getName() {
+ return doc.getName();
+ }
+
+ public boolean equals(Object other) {
+ if (other == null || getClass() != other.getClass()) {
+ return false;
+ }
+ return doc.equals(((BaseSubject) other).doc);
+ }
+}
Added: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/HeaderTypeObject.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/HeaderTypeObject.java?rev=752358&view=auto
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/HeaderTypeObject.java (added)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/HeaderTypeObject.java Wed Mar 11 02:42:33 2009
@@ -0,0 +1,24 @@
+package org.apache.rat.report.claim;
+
+import org.apache.rat.analysis.Claims;
+
+
+/**
+ * Implementation of {@link BaseObject} for
+ * {@link Claims#HEADER_TYPE_PREDICATE}.
+ */
+public class HeaderTypeObject extends BaseObject {
+ /**
+ * Creates a new instance with the given value.
+ */
+ public HeaderTypeObject(String pValue) {
+ super(pValue);
+ }
+
+ public static final HeaderTypeObject GENERATED = new HeaderTypeObject("GEN ");
+ public static final HeaderTypeObject UNKNOWN = new HeaderTypeObject("?????");
+ public static final HeaderTypeObject ARCHIVE = new HeaderTypeObject("archive");
+ public static final HeaderTypeObject NOTICE = new HeaderTypeObject("notice");
+ public static final HeaderTypeObject BINARY = new HeaderTypeObject("binary");
+ public static final HeaderTypeObject STANDARD = new HeaderTypeObject("standard");
+}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IClaimReporter.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IClaimReporter.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IClaimReporter.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IClaimReporter.java Wed Mar 11 02:42:33 2009
@@ -30,6 +30,6 @@
* @param isLiteral <code>true</code> is the object of this claim is a literal,
* <code>false</code> if the object of this claim is an identifier
*/
- public void claim(CharSequence subject, CharSequence predicate, CharSequence object, boolean isLiteral)
+ public void claim(ISubject subject, IPredicate predicate, IObject object, boolean isLiteral)
throws RatReportFailedException;
}
Added: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IObject.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IObject.java?rev=752358&view=auto
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IObject.java (added)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IObject.java Wed Mar 11 02:42:33 2009
@@ -0,0 +1,12 @@
+package org.apache.rat.report.claim;
+
+
+/**
+ * Interface of a claims object.
+ */
+public interface IObject {
+ /**
+ * Returns the objects value.
+ */
+ String getValue();
+}
Added: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IPredicate.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IPredicate.java?rev=752358&view=auto
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IPredicate.java (added)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/IPredicate.java Wed Mar 11 02:42:33 2009
@@ -0,0 +1,12 @@
+package org.apache.rat.report.claim;
+
+
+/**
+ * Interface of a predicate.
+ */
+public interface IPredicate {
+ /**
+ * Returns the predicates name.
+ */
+ String getName();
+}
Added: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/ISubject.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/ISubject.java?rev=752358&view=auto
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/ISubject.java (added)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/ISubject.java Wed Mar 11 02:42:33 2009
@@ -0,0 +1,13 @@
+package org.apache.rat.report.claim;
+
+
+/**
+ * A subject is a resource, which is being analyzed
+ * and matched.
+ */
+public interface ISubject {
+ /**
+ * Returns the subjects name.
+ */
+ String getName();
+}
Added: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseApprovalObject.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseApprovalObject.java?rev=752358&view=auto
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseApprovalObject.java (added)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseApprovalObject.java Wed Mar 11 02:42:33 2009
@@ -0,0 +1,31 @@
+package org.apache.rat.report.claim;
+
+import org.apache.rat.analysis.Claims;
+
+
+
+/**
+ * Implementation of {@link IObject} for the
+ * {@link Claims#LICENSE_APPROVAL_PREDICATE}.
+ */
+public class LicenseApprovalObject implements IObject {
+ private final boolean value;
+
+ /**
+ * Creates a new instance with the given value.
+ */
+ private LicenseApprovalObject(boolean pValue) {
+ value = pValue;
+ }
+
+ public String getValue() {
+ return String.valueOf(value);
+ }
+
+ public boolean getBooleanValue() {
+ return value;
+ }
+
+ public static final LicenseApprovalObject TRUE = new LicenseApprovalObject(true);
+ public static final LicenseApprovalObject FALSE = new LicenseApprovalObject(false);
+}
Added: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseFamilyCode.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseFamilyCode.java?rev=752358&view=auto
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseFamilyCode.java (added)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseFamilyCode.java Wed Mar 11 02:42:33 2009
@@ -0,0 +1,15 @@
+package org.apache.rat.report.claim;
+
+
+/**
+ * Extension of {@link HeaderTypeObject} for
+ * license family codes.
+ */
+public class LicenseFamilyCode extends HeaderTypeObject {
+ /**
+ * Creates a new instance with the given family code.
+ */
+ public LicenseFamilyCode(String pValue) {
+ super(pValue);
+ }
+}
Added: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseFamilyName.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseFamilyName.java?rev=752358&view=auto
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseFamilyName.java (added)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/LicenseFamilyName.java Wed Mar 11 02:42:33 2009
@@ -0,0 +1,13 @@
+package org.apache.rat.report.claim;
+
+
+/**
+ * A license family name.
+ */
+public class LicenseFamilyName extends BaseObject {
+ public LicenseFamilyName(String name) {
+ super(name);
+ }
+
+ public static final LicenseFamilyName UNKNOWN_LICENSE_FAMILY = new LicenseFamilyName("?????");
+}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java Wed Mar 11 02:42:33 2009
@@ -22,31 +22,34 @@
import org.apache.rat.report.RatReportFailedException;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.IObject;
+import org.apache.rat.report.claim.IPredicate;
+import org.apache.rat.report.claim.ISubject;
import org.apache.rat.report.xml.writer.IXmlWriter;
public class SimpleXmlClaimReporter implements IClaimReporter {
private static final String NAME = "name";
private final IXmlWriter writer;
- private CharSequence lastSubject;
+ private ISubject lastSubject;
public SimpleXmlClaimReporter(final IXmlWriter writer) {
this.writer = writer;
}
- public void claim(CharSequence subject, CharSequence predicate,
- CharSequence object, boolean isLiteral) throws RatReportFailedException {
+ public void claim(ISubject subject, IPredicate predicate,
+ IObject object, boolean isLiteral) throws RatReportFailedException {
try {
if (!(subject.equals(lastSubject))) {
if (lastSubject != null) {
writer.closeElement();
}
- writer.openElement("resource").attribute(NAME, subject);
+ writer.openElement("resource").attribute(NAME, subject.getName());
}
if (isLiteral) {
- writer.openElement(predicate).content(object).closeElement();
+ writer.openElement(predicate.getName()).content(object.getValue()).closeElement();
} else {
- writer.openElement(predicate).attribute(NAME, object).closeElement();
+ writer.openElement(predicate.getName()).attribute(NAME, object.getValue()).closeElement();
}
lastSubject = subject;
} catch (IOException e) {
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexer.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexer.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexer.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexer.java Wed Mar 11 02:42:33 2009
@@ -20,6 +20,9 @@
import org.apache.rat.report.RatReportFailedException;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.IObject;
+import org.apache.rat.report.claim.IPredicate;
+import org.apache.rat.report.claim.ISubject;
public class ClaimReporterMultiplexer implements IClaimReporter {
@@ -30,8 +33,8 @@
this.reporters = reporters;
}
- public void claim(CharSequence subject, CharSequence predicate,
- CharSequence object, boolean isLiteral)
+ public void claim(ISubject subject, IPredicate predicate,
+ IObject object, boolean isLiteral)
throws RatReportFailedException {
final int length = reporters.length;
for (int i=0;i<length;i++) {
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/MockLicenseMatcher.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/MockLicenseMatcher.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/MockLicenseMatcher.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/MockLicenseMatcher.java Wed Mar 11 02:42:33 2009
@@ -22,6 +22,7 @@
import java.util.List;
import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.ISubject;
public class MockLicenseMatcher implements IHeaderMatcher {
@@ -29,7 +30,7 @@
public int resets = 0;
public boolean result = true;
- public boolean match(String subject, String line, IClaimReporter reporter) {
+ public boolean match(ISubject subject, String line, IClaimReporter reporter) {
lines.add(line);
return result;
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/generation/GeneratedLicenseNotRequiredTest.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/generation/GeneratedLicenseNotRequiredTest.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/generation/GeneratedLicenseNotRequiredTest.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/generation/GeneratedLicenseNotRequiredTest.java Wed Mar 11 02:42:33 2009
@@ -21,6 +21,9 @@
import java.util.regex.Pattern;
import junit.framework.TestCase;
+
+import org.apache.rat.report.claim.ISubject;
+import org.apache.rat.report.claim.MockSubject;
import org.apache.rat.report.claim.impl.xml.MockClaimReporter;
public class GeneratedLicenseNotRequiredTest extends TestCase {
@@ -40,7 +43,8 @@
}
public void testMatch() throws Exception {
- assertFalse("Does not match regex", license.match("subject", "Not at all", reporter));
- assertTrue("Matches regex", license.match("subject", "This is Generated", reporter));
+ final ISubject subject = new MockSubject("subject");
+ assertFalse("Does not match regex", license.match(subject, "Not at all", reporter));
+ assertTrue("Matches regex", license.match(subject, "This is Generated", reporter));
}
}
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/generation/JavaDocLicenseNotRequiredTest.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/generation/JavaDocLicenseNotRequiredTest.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/generation/JavaDocLicenseNotRequiredTest.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/generation/JavaDocLicenseNotRequiredTest.java Wed Mar 11 02:42:33 2009
@@ -24,6 +24,8 @@
import junit.framework.TestCase;
+import org.apache.rat.report.claim.ISubject;
+import org.apache.rat.report.claim.MockSubject;
import org.apache.rat.report.claim.impl.xml.MockClaimReporter;
import org.apache.rat.test.utils.Resources;
@@ -62,8 +64,9 @@
boolean result = false;
BufferedReader in = new BufferedReader(new FileReader(file));
String line = in.readLine();
+ final ISubject subject = new MockSubject("subject");
while (line != null && !result) {
- result = license.match("subject", line, reporter);
+ result = license.match(subject, line, reporter);
line = in.readLine();
}
return result;
Modified: incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/license/ApacheSoftwareLicense20Test.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/license/ApacheSoftwareLicense20Test.java?rev=752358&r1=752357&r2=752358&view=diff
==============================================================================
--- incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/license/ApacheSoftwareLicense20Test.java (original)
+++ incubator/rat/main/branches/rat-output-semantics/apache-rat-core/src/test/java/org/apache/rat/analysis/license/ApacheSoftwareLicense20Test.java Wed Mar 11 02:42:33 2009
@@ -19,6 +19,9 @@
package org.apache.rat.analysis.license;
import junit.framework.TestCase;
+
+import org.apache.rat.report.claim.ISubject;
+import org.apache.rat.report.claim.MockSubject;
import org.apache.rat.report.claim.impl.xml.MockClaimReporter;
public class ApacheSoftwareLicense20Test extends TestCase {
@@ -50,16 +53,17 @@
public void testMatch() throws Exception {
ApacheSoftwareLicense20 worker = new ApacheSoftwareLicense20();
- assertTrue(worker.match("subject", ApacheSoftwareLicense20.FIRST_LICENSE_LINE, reporter));
- assertTrue(worker.match("subject", " Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
- assertTrue(worker.match("subject", "Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
- assertTrue(worker.match("subject", " * Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
- assertTrue(worker.match("subject", " // Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
- assertTrue(worker.match("subject", " /* Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
- assertTrue(worker.match("subject", " Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
- assertTrue(worker.match("subject", " ## Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
- assertTrue(worker.match("subject", " ## Licensed under the Apache License, Version 2.0 (the \"License\") ##);", reporter));
- assertFalse(worker.match("subject", "'Behold, Telemachus! (nor fear the sight,)", reporter));
+ final ISubject subject = new MockSubject("subject");
+ assertTrue(worker.match(subject, ApacheSoftwareLicense20.FIRST_LICENSE_LINE, reporter));
+ assertTrue(worker.match(subject, " Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
+ assertTrue(worker.match(subject, "Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
+ assertTrue(worker.match(subject, " * Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
+ assertTrue(worker.match(subject, " // Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
+ assertTrue(worker.match(subject, " /* Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
+ assertTrue(worker.match(subject, " Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
+ assertTrue(worker.match(subject, " ## Licensed under the Apache License, Version 2.0 (the \"License\");", reporter));
+ assertTrue(worker.match(subject, " ## Licensed under the Apache License, Version 2.0 (the \"License\") ##);", reporter));
+ assertFalse(worker.match(subject, "'Behold, Telemachus! (nor fear the sight,)", reporter));
}
}