You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by rd...@apache.org on 2009/05/20 17:23:54 UTC
svn commit: r776731 - in /incubator/rat/main/trunk:
apache-rat-core/src/main/java/org/apache/rat/document/
apache-rat-core/src/main/java/org/apache/rat/document/impl/
apache-rat-core/src/test/java/org/apache/rat/document/
apache-rat-plugin/src/main/jav...
Author: rdonkin
Date: Wed May 20 15:23:54 2009
New Revision: 776731
URL: http://svn.apache.org/viewvc?rev=776731&view=rev
Log:
RAT-53 Add content type to document https://issues.apache.org/jira/browse/RAT-53
Added:
incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/ContentType.java (with props)
incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/MetaData.java (with props)
Modified:
incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/IDocument.java
incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/impl/AbstractMonolithicDocument.java
incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/impl/FileDocument.java
incubator/rat/main/trunk/apache-rat-core/src/test/java/org/apache/rat/document/MockDocument.java
incubator/rat/main/trunk/apache-rat-core/src/test/java/org/apache/rat/document/MockLocation.java
incubator/rat/main/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/FilesReportable.java
incubator/rat/main/trunk/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java
Added: incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/ContentType.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/ContentType.java?rev=776731&view=auto
==============================================================================
--- incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/ContentType.java (added)
+++ incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/ContentType.java Wed May 20 15:23:54 2009
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ */
+package org.apache.rat.document;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Describe the MIME content type of a resource.
+ */
+public class ContentType {
+ private final String mediaType;
+ private final String subType;
+ private final Map/*<String, String>*/ parameters;
+
+ /**
+ * Constructs content types,
+ * performing an necessary conversions.
+ * @param mediaType not null
+ * @param subType not null
+ * @param parameters not null
+ */
+ public ContentType(final String mediaType, final String subType, final Map parameters) {
+ super();
+ this.mediaType = mediaType.toLowerCase(Locale.US);
+ this.subType = subType.toLowerCase(Locale.US);
+ this.parameters = new HashMap(parameters.size());
+ for (Iterator it=parameters.entrySet().iterator();it.hasNext();) {
+ final Map.Entry entry = (Map.Entry) it.next();
+ this.parameters.put(entry.getKey().toString().toLowerCase(Locale.US), entry.getValue());
+ }
+ }
+
+ /**
+ * Gets the media type,
+ * normalised to lower case.
+ * @return media type, not null
+ */
+ public String getMediaType() {
+ return mediaType;
+ }
+
+ /**
+ * Gets the media sub type
+ * normalised to lower case
+ * @return sub type, not null
+ */
+ public String getSubType() {
+ return subType;
+ }
+
+ /**
+ * Gets an immutable map
+ * containing all content type parameters
+ * with keys normalised to lower case.
+ * @return not null
+ */
+ public Map/*<String, String>*/ getParameters() {
+ return parameters;
+ }
+}
Propchange: incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/ContentType.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/IDocument.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/IDocument.java?rev=776731&r1=776730&r2=776731&view=diff
==============================================================================
--- incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/IDocument.java (original)
+++ incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/IDocument.java Wed May 20 15:23:54 2009
@@ -33,6 +33,12 @@
* a composite archive
*/
public Reader reader() throws IOException;
+
+ /**
+ * Gets data describing this resource.
+ * @return not null
+ */
+ public MetaData getMetaData();
/**
* Is this a composite document?
Added: incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/MetaData.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/MetaData.java?rev=776731&view=auto
==============================================================================
--- incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/MetaData.java (added)
+++ incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/MetaData.java Wed May 20 15:23:54 2009
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ */
+package org.apache.rat.document;
+
+/**
+ * Data about the subject.
+ */
+public class MetaData {
+
+ private ContentType contentType;
+
+ public MetaData() {
+ this(null);
+ }
+
+ public MetaData(final ContentType contentType) {
+ this.contentType = contentType;
+ }
+
+ /**
+ * Gets the content type for the subject.
+ * @return or null when the type is unknown
+ */
+ public ContentType getContentType() {
+ return contentType;
+ }
+
+ /**
+ * Sets the content type for this subject.
+ * @param contentType <code>ContentType</code>,
+ * or null when the content type is unknown
+ */
+ public void setContentType(final ContentType contentType) {
+ this.contentType = contentType;
+ }
+}
Propchange: incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/MetaData.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/impl/AbstractMonolithicDocument.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/impl/AbstractMonolithicDocument.java?rev=776731&r1=776730&r2=776731&view=diff
==============================================================================
--- incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/impl/AbstractMonolithicDocument.java (original)
+++ incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/impl/AbstractMonolithicDocument.java Wed May 20 15:23:54 2009
@@ -19,6 +19,7 @@
package org.apache.rat.document.impl;
import org.apache.rat.document.IDocument;
+import org.apache.rat.document.MetaData;
/**
@@ -26,9 +27,11 @@
*/
public abstract class AbstractMonolithicDocument implements IDocument {
private final String name;
+ private final MetaData metaData;
public AbstractMonolithicDocument(String pName) {
name = pName;
+ this.metaData = new MetaData();
}
public boolean isComposite() {
@@ -38,4 +41,8 @@
public String getName() {
return name;
}
+
+ public MetaData getMetaData() {
+ return metaData;
+ }
}
Modified: incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/impl/FileDocument.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/impl/FileDocument.java?rev=776731&r1=776730&r2=776731&view=diff
==============================================================================
--- incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/impl/FileDocument.java (original)
+++ incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/document/impl/FileDocument.java Wed May 20 15:23:54 2009
@@ -24,6 +24,7 @@
import java.io.Reader;
import org.apache.rat.document.IDocument;
+import org.apache.rat.document.MetaData;
/**
* Document wrapping a file of undetermined composition.
@@ -33,6 +34,7 @@
private final File file;
private final String name;
+ private final MetaData metaData = new MetaData();
public FileDocument(final File file) {
super();
@@ -52,5 +54,7 @@
return name;
}
-
+ public MetaData getMetaData() {
+ return metaData;
+ }
}
Modified: incubator/rat/main/trunk/apache-rat-core/src/test/java/org/apache/rat/document/MockDocument.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/apache-rat-core/src/test/java/org/apache/rat/document/MockDocument.java?rev=776731&r1=776730&r2=776731&view=diff
==============================================================================
--- incubator/rat/main/trunk/apache-rat-core/src/test/java/org/apache/rat/document/MockDocument.java (original)
+++ incubator/rat/main/trunk/apache-rat-core/src/test/java/org/apache/rat/document/MockDocument.java Wed May 20 15:23:54 2009
@@ -25,6 +25,7 @@
public Reader reader;
public String name;
+ private final MetaData metaData = new MetaData();
public MockDocument() {
this(null, "name");
@@ -51,4 +52,8 @@
public boolean isComposite() {
return false;
}
+
+ public MetaData getMetaData() {
+ return metaData;
+ }
}
Modified: incubator/rat/main/trunk/apache-rat-core/src/test/java/org/apache/rat/document/MockLocation.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/apache-rat-core/src/test/java/org/apache/rat/document/MockLocation.java?rev=776731&r1=776730&r2=776731&view=diff
==============================================================================
--- incubator/rat/main/trunk/apache-rat-core/src/test/java/org/apache/rat/document/MockLocation.java (original)
+++ incubator/rat/main/trunk/apache-rat-core/src/test/java/org/apache/rat/document/MockLocation.java Wed May 20 15:23:54 2009
@@ -25,6 +25,7 @@
public String name;
public String url;
+ private final MetaData metaData = new MetaData();
public MockLocation() {
this("name", "url");
@@ -57,4 +58,7 @@
throw new UnsupportedOperationException();
}
+ public MetaData getMetaData() {
+ return metaData;
+ }
}
Modified: incubator/rat/main/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/FilesReportable.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/FilesReportable.java?rev=776731&r1=776730&r2=776731&view=diff
==============================================================================
--- incubator/rat/main/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/FilesReportable.java (original)
+++ incubator/rat/main/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/FilesReportable.java Wed May 20 15:23:54 2009
@@ -27,6 +27,7 @@
import java.io.Reader;
import org.apache.rat.document.IDocument;
+import org.apache.rat.document.MetaData;
import org.apache.rat.document.impl.DocumentImplUtils;
import org.apache.rat.report.IReportable;
import org.apache.rat.report.RatReport;
@@ -71,7 +72,8 @@
private class FileDocument implements IDocument
{
private File file;
-
+ private final MetaData metaData = new MetaData();
+
void setFile( File file )
{
this.file = file;
@@ -91,5 +93,9 @@
{
return DocumentImplUtils.toName( file );
}
+
+ public MetaData getMetaData() {
+ return metaData;
+ }
}
}
Modified: incubator/rat/main/trunk/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java?rev=776731&r1=776730&r2=776731&view=diff
==============================================================================
--- incubator/rat/main/trunk/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java (original)
+++ incubator/rat/main/trunk/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java Wed May 20 15:23:54 2009
@@ -26,6 +26,7 @@
import java.util.Iterator;
import org.apache.rat.document.IDocument;
+import org.apache.rat.document.MetaData;
import org.apache.rat.document.impl.DocumentImplUtils;
import org.apache.rat.report.IReportable;
import org.apache.rat.report.RatReport;
@@ -60,6 +61,7 @@
private class ResourceDocument implements IDocument {
private Resource resource;
+ private final MetaData metaData = new MetaData();
public Resource getResource() {
return resource;
@@ -96,5 +98,9 @@
}
return false;
}
+
+ public MetaData getMetaData() {
+ return metaData;
+ }
}
}