org.codehaus.mojo.mrm.impl
Class Utils

java.lang.Object
  extended by org.codehaus.mojo.mrm.impl.Utils

public final class Utils
extends Object

Utility class.

Since:
1.0

Method Summary
static InputStream asInputStream(Object content)
          Returns an input stream for the specified content.
static String getArtifactId(org.apache.maven.model.Model model)
          Extract the artifactId from an un-interpolated model.
static String getGAVPath(String groupId, String artifactId, String version)
          Converts a GAV coordinate into the repository path for the directory containing all artifacts at that GAV.
static String getGAVPathName(String groupId, String artifactId, String version)
          Converts a GAV coordinate into the base file path and name for all artifacts at that coordinate.
static String getGroupId(org.apache.maven.model.Model model)
          Extract the groupId from an un-interpolated model.
static String getVersion(org.apache.maven.model.Model model)
          Extract the version from an un-interpolated model.
static byte[] newEmptyJarContent()
          Creates an empty jar file.
static byte[] newEmptyMavenPluginJarContent(String groupId, String artifactId, String version)
          Creates an empty maven plugin jar file.
static String urlEncodePath(String path)
          Take a path and encode it for use as an URL parameter.
static String urlEncodePathSegment(String pathSegment)
          Take a path segment and encode it for use as an URL parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

asInputStream

public static InputStream asInputStream(Object content)
                                 throws IOException
Returns an input stream for the specified content. If the content is a byte array, the input stream will be a ByteArrayInputStream if the content is a File, the input stream will be a FileInputStream otherwise the content will be converted to a String and then into its UTF-8 representation and a ByteArrayInputStream returned.

Parameters:
content - The content.
Returns:
an input stream of the content.
Throws:
IOException - if things go wrong.
Since:
1.0

newEmptyJarContent

public static byte[] newEmptyJarContent()
                                 throws IOException
Creates an empty jar file.

Returns:
the empty jar file as a byte array.
Throws:
IOException - if things go wrong.
Since:
1.0

newEmptyMavenPluginJarContent

public static byte[] newEmptyMavenPluginJarContent(String groupId,
                                                   String artifactId,
                                                   String version)
                                            throws IOException
Creates an empty maven plugin jar file.

Parameters:
groupId - the group id of the plugin.
artifactId - the artifact id of the plugin.
version - the version of the plugin.
Returns:
the empty jar file as a byte array.
Throws:
IOException - if things go wrong.
Since:
1.0

getGAVPathName

public static String getGAVPathName(String groupId,
                                    String artifactId,
                                    String version)
Converts a GAV coordinate into the base file path and name for all artifacts at that coordinate.

Parameters:
groupId - the group id.
artifactId - the artifact id.
version - the version.
Returns:
the base filepath for artifacts at the specified coordinates.
Since:
1.0

getGAVPath

public static String getGAVPath(String groupId,
                                String artifactId,
                                String version)
Converts a GAV coordinate into the repository path for the directory containing all artifacts at that GAV.

Parameters:
groupId - the group id.
artifactId - the artifact id (may be null to just get the path of the groupId)
version - the version (may be null to just get the path of the groupId:artifactId)
Returns:
the path.
Since:
1.0

getVersion

public static String getVersion(org.apache.maven.model.Model model)
Extract the version from an un-interpolated model.

Parameters:
model - the model.
Returns:
the version of the project.
Since:
1.0

getArtifactId

public static String getArtifactId(org.apache.maven.model.Model model)
Extract the artifactId from an un-interpolated model.

Parameters:
model - the model.
Returns:
the artifactId of the project.
Since:
1.0

getGroupId

public static String getGroupId(org.apache.maven.model.Model model)
Extract the groupId from an un-interpolated model.

Parameters:
model - the model.
Returns:
the groupId of the project.
Since:
1.0

urlEncodePath

public static String urlEncodePath(String path)
                            throws UnsupportedEncodingException
Take a path and encode it for use as an URL parameter.

Parameters:
path - the path.
Returns:
the path encoded for use as an URL parameter.
Throws:
UnsupportedEncodingException - if the path cannot be encoded.
Since:
1.0

urlEncodePathSegment

public static String urlEncodePathSegment(String pathSegment)
                                   throws UnsupportedEncodingException
Take a path segment and encode it for use as an URL parameter.

Parameters:
pathSegment - the path segment.
Returns:
the path segment encoded for use as an URL parameter.
Throws:
UnsupportedEncodingException - if the path cannot be encoded.
Since:
1.0


Copyright © 2009-2011 Codehaus. All Rights Reserved.