creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1548864 - /creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
Date Sat, 07 Dec 2013 11:14:14 GMT
Author: rdonkin
Date: Sat Dec  7 11:14:14 2013
New Revision: 1548864

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

Modified:
    creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java

Modified: creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java?rev=1548864&r1=1548863&r2=1548864&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
Sat Dec  7 11:14:14 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat.report.claim.impl.xml;
 
 import java.io.IOException;
@@ -30,120 +30,136 @@ import org.apache.rat.report.AbstractRep
 import org.apache.rat.report.xml.writer.IXmlWriter;
 
 public class SimpleXmlClaimReporter extends AbstractReport {
-    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 String FILE_TYPE_PREDICATE = "type";
-    public static final String ARCHIVE_TYPE_PREDICATE = "archive-type";
-    public static final String ARCHIVE_TYPE_UNREADABLE = "unreadable";
-    public static final String ARCHIVE_TYPE_READABLE = "readable";
-
-    private static final String NAME = "name";
-    private final IXmlWriter writer;
-    private boolean firstTime = true;
-
-    public SimpleXmlClaimReporter(final IXmlWriter writer) {
-        this.writer = writer;
-    }
-
-
-    /**
-     * Writes a single claim to the XML file.
-     * @param pPredicate The claims predicate.
-     * @param pObject The claims object.
-     * @param pLiteral Whether to write the object as an element (true),
-     *   or an attribute (false).
-     * @throws IOException An I/O error occurred while writing the claim.
-     * @throws RatException Another error occurred while writing the claim.
-     */
-    protected void writeClaim(String pPredicate, String pObject, boolean pLiteral)
-    throws IOException, RatException {
-        if (pLiteral) {
-            writer.openElement(pPredicate).content(pObject).closeElement();
-        } else {
-            writer.openElement(pPredicate).attribute(NAME, pObject).closeElement();
-        }
-    }
-
-    @Override
-    public void report(final Document subject) throws RatException {
-        try {
-            if (firstTime) {
-                firstTime = false;
-            } else {
-                writer.closeElement();
-            }
-            writer.openElement("resource").attribute(NAME, subject.getName());
-            writeDocumentClaims(subject);
-        } catch (IOException e) {
-            throw new RatException("XML writing failure: " + e.getMessage()
-                    + " subject: " + subject, e);
-        }
-    }
-
-    private void writeDocumentClaims(final Document subject) throws IOException, RatException
{
-        final MetaData metaData = subject.getMetaData();
-        writeHeaderSample(metaData);
-        writeHeaderCategory(metaData);
-        writeLicenseFamilyName(metaData);
-        writeApprovedLicense(metaData);
-        writeDocumentCategory(metaData);
-    }
-
-    private void writeApprovedLicense(final MetaData metaData) throws IOException, RatException
{
-        final String approvedLicense = metaData.value(MetaData.RAT_URL_APPROVED_LICENSE);
-        if (approvedLicense != null) {
-            writeClaim(LICENSE_APPROVAL_PREDICATE, approvedLicense, false);
-        }
-    }
-
-    private void writeLicenseFamilyName(final MetaData metaData) throws IOException, RatException
{
-        final String licenseFamilyName = metaData.value(MetaData.RAT_URL_LICENSE_FAMILY_NAME);
-        if (licenseFamilyName != null) {
-            writeClaim(LICENSE_FAMILY_PREDICATE, licenseFamilyName, false);
-        }
-    }
-
-    private void writeHeaderCategory(final MetaData metaData) throws IOException, RatException
{
-        final String headerCategory = metaData.value(MetaData.RAT_URL_HEADER_CATEGORY);
-        if (headerCategory != null) {
-            writeClaim(HEADER_TYPE_PREDICATE, headerCategory, false);
-        }
-    }
-
-    private void writeHeaderSample(final MetaData metaData) throws IOException, RatException
{
-        final String sample = metaData.value(MetaData.RAT_URL_HEADER_SAMPLE);
-        if (sample != null) {
-            writeClaim(HEADER_SAMPLE_PREDICATE, sample, true);
-        }
-    }
-
-    private void writeDocumentCategory(final MetaData metaData) throws IOException, RatException
{
-        final String documentCategory = metaData.value(MetaData.RAT_URL_DOCUMENT_CATEGORY);
-        if (documentCategory != null) {
-            writeClaim(FILE_TYPE_PREDICATE, documentCategory, false);
-        }
-    }
-
-    @Override
-    public void startReport() throws RatException {
-        try {
-            writer.openElement("rat-report")
-                .attribute("timestamp",
-                           DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT
-                           .format(Calendar.getInstance()));
-        } catch (IOException e) {
-            throw new RatException("Cannot open start element", e);
-        }
-    }
-
-    @Override
-    public void endReport() throws RatException {
-        try {
-            writer.closeDocument();
-        } catch (IOException e) {
-            throw new RatException("Cannot close last element", e);
-        }
-    }
+	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 String FILE_TYPE_PREDICATE = "type";
+	public static final String ARCHIVE_TYPE_PREDICATE = "archive-type";
+	public static final String ARCHIVE_TYPE_UNREADABLE = "unreadable";
+	public static final String ARCHIVE_TYPE_READABLE = "readable";
+
+	private static final String NAME = "name";
+	private final IXmlWriter writer;
+	private boolean firstTime = true;
+
+	public SimpleXmlClaimReporter(final IXmlWriter writer) {
+		this.writer = writer;
+	}
+
+	/**
+	 * Writes a single claim to the XML file.
+	 * 
+	 * @param pPredicate
+	 *            The claims predicate.
+	 * @param pObject
+	 *            The claims object.
+	 * @param pLiteral
+	 *            Whether to write the object as an element (true), or an
+	 *            attribute (false).
+	 * @throws IOException
+	 *             An I/O error occurred while writing the claim.
+	 * @throws RatException
+	 *             Another error occurred while writing the claim.
+	 */
+	protected void writeClaim(String pPredicate, String pObject,
+			boolean pLiteral) throws IOException, RatException {
+		if (pLiteral) {
+			writer.openElement(pPredicate).content(pObject).closeElement();
+		} else {
+			writer.openElement(pPredicate).attribute(NAME, pObject)
+					.closeElement();
+		}
+	}
+
+	@Override
+	public void report(final Document subject) throws RatException {
+		try {
+			if (firstTime) {
+				firstTime = false;
+			} else {
+				writer.closeElement();
+			}
+			writer.openElement("resource").attribute(NAME, subject.getName());
+			writeDocumentClaims(subject);
+		} catch (IOException e) {
+			throw new RatException("XML writing failure: " + e.getMessage()
+					+ " subject: " + subject, e);
+		}
+	}
+
+	private void writeDocumentClaims(final Document subject)
+			throws IOException, RatException {
+		final MetaData metaData = subject.getMetaData();
+		writeHeaderSample(metaData);
+		writeHeaderCategory(metaData);
+		writeLicenseFamilyName(metaData);
+		writeApprovedLicense(metaData);
+		writeDocumentCategory(metaData);
+	}
+
+	private void writeApprovedLicense(final MetaData metaData)
+			throws IOException, RatException {
+		final String approvedLicense = metaData
+				.value(MetaData.RAT_URL_APPROVED_LICENSE);
+		if (approvedLicense != null) {
+			writeClaim(LICENSE_APPROVAL_PREDICATE, approvedLicense, false);
+		}
+	}
+
+	private void writeLicenseFamilyName(final MetaData metaData)
+			throws IOException, RatException {
+		final String licenseFamilyName = metaData
+				.value(MetaData.RAT_URL_LICENSE_FAMILY_NAME);
+		if (licenseFamilyName != null) {
+			writeClaim(LICENSE_FAMILY_PREDICATE, licenseFamilyName, false);
+		}
+	}
+
+	private void writeHeaderCategory(final MetaData metaData)
+			throws IOException, RatException {
+		final String headerCategory = metaData
+				.value(MetaData.RAT_URL_HEADER_CATEGORY);
+		if (headerCategory != null) {
+			writeClaim(HEADER_TYPE_PREDICATE, headerCategory, false);
+		}
+	}
+
+	private void writeHeaderSample(final MetaData metaData) throws IOException,
+			RatException {
+		final String sample = metaData.value(MetaData.RAT_URL_HEADER_SAMPLE);
+		if (sample != null) {
+			writeClaim(HEADER_SAMPLE_PREDICATE, sample, true);
+		}
+	}
+
+	private void writeDocumentCategory(final MetaData metaData)
+			throws IOException, RatException {
+		final String documentCategory = metaData
+				.value(MetaData.RAT_URL_DOCUMENT_CATEGORY);
+		if (documentCategory != null) {
+			writeClaim(FILE_TYPE_PREDICATE, documentCategory, false);
+		}
+	}
+
+	@Override
+	public void startReport() throws RatException {
+		try {
+			writer.openElement("rat-report").attribute(
+					"timestamp",
+					DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT
+							.format(Calendar.getInstance()));
+		} catch (IOException e) {
+			throw new RatException("Cannot open start element", e);
+		}
+	}
+
+	@Override
+	public void endReport() throws RatException {
+		try {
+			writer.closeDocument();
+		} catch (IOException e) {
+			throw new RatException("Cannot close last element", e);
+		}
+	}
 }



Mime
View raw message