de.smartics.maven.io
Class MojoIoUtils

Package class diagram package MojoIoUtils
java.lang.Object
  extended by de.smartics.maven.io.MojoIoUtils

public final class MojoIoUtils
     
     
extends Object

Utilities for Mojos working with IO.

Author:
Robert Reiner

Method Summary
static String normalizeFileName(String input)
          Normalises the file name to be used as a URL name.
static void provideDirectory(File directory)
          Ensures that the given directory is present and if not, creates it.
static void provideMojoDirectory(File directory)
          Ensures that the given directory is present and if not, creates it.
static File provideMojoDirectory(String dirName)
          Ensures that the directory with the given name is present and if not, creates it.
static void provideReportDirectory(File directory)
          Ensures that the given directory is present and if not, creates it.
static void serialize(Document document, OutputStream out)
          Writes the DOM document to the given stream.
static void serialize(Document document, OutputStream out, boolean prettyPrint)
          Writes the DOM document to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

provideMojoDirectory

public static File provideMojoDirectory(String dirName)
                                 throws MojoExecutionException
Ensures that the directory with the given name is present and if not, creates it.

Parameters:
dirName - the name of the directory to be created.
Throws:
MojoExecutionException - if the directory is not present and cannot be created.

provideDirectory

public static void provideDirectory(File directory)
                             throws IOException
Ensures that the given directory is present and if not, creates it.

Parameters:
directory - the directory to be created.
Throws:
IOException - if the directory is not present and cannot be created.

provideMojoDirectory

public static void provideMojoDirectory(File directory)
                                 throws MojoExecutionException
Ensures that the given directory is present and if not, creates it.

Parameters:
directory - the directory to be created.
Throws:
MojoExecutionException - if the directory is not present and cannot be created.

provideReportDirectory

public static void provideReportDirectory(File directory)
                                   throws MavenReportException
Ensures that the given directory is present and if not, creates it.

Parameters:
directory - the directory to be created.
Throws:
MavenReportException - if the directory is not present and cannot be created.

normalizeFileName

public static String normalizeFileName(String input)
Normalises the file name to be used as a URL name.

Implementation Notes:
Any character that is not a letter between A-Z (upper or lower case), a number or a dash, an underscore or a dot, will be mapped to an underscore. This algorithm is not part of the public API and stated here for informal reason. Any valid URL character may be added at a latter time. Client can be sure that the returned value contains only characters valid in an URL.
Parameters:
input - the file name to be normalised.
Returns:
the normalised filename.

serialize

public static void serialize(Document document,
                             OutputStream out)
                      throws TransformerException
Writes the DOM document to the given stream.

Parameters:
document - the document to write.
out - the stream to write to.
Throws:
TransformerException - on any problem writing to the stream.

serialize

public static void serialize(Document document,
                             OutputStream out,
                             boolean prettyPrint)
                      throws TransformerException
Writes the DOM document to the given stream.

Parameters:
document - the document to write.
out - the stream to write to.
Throws:
TransformerException - on any problem writing to the stream.


Copyright © 2006-2012 Kronseder & Reiner GmbH - smartics. All Rights Reserved.