eu.lindenbaum.maven.util
Class ErlUtils

java.lang.Object
  extended by eu.lindenbaum.maven.util.ErlUtils

public final class ErlUtils
extends Object

Containing utilities related to erlang code execution.

Author:
Tobias Schlager , Gregory Haskins

Constructor Summary
ErlUtils()
           
 
Method Summary
static String toApplicationTuples(org.apache.maven.artifact.Artifact... artifacts)
          Returns a comma separated string of application version tuples taken from the given array of artifacts.
static String toApplicationTuples(CheckAppResult... applicationInfos)
          Returns a comma separated string of application version tuples taken from the given array of CheckAppResults.
static String toArtifactIdListing(Collection<org.apache.maven.artifact.Artifact> artifacts)
          Generates a simple comma separated list of applications derived from the artifacts listed as dependencies.
static String toFileList(Collection<File> list, String prefix, String postfix)
          Converts a Collection of files into a string containing a valid erlang list.
static int toInt(com.ericsson.otp.erlang.OtpErlangObject object)
          Converts an OtpErlangInt or an OtpErlangUInt into an int using the object specific conversion function.
static
<T> String
toList(Collection<T> list, Predicate<T> p, String prefix, String postfix)
          Converts a Collection into a string containing a valid erlang list.
static
<T> String
toList(T[] array, Predicate<T> p, String prefix, String postfix)
          Converts an array into a string containing a valid erlang list.
static String toModuleList(Collection<File> list, String prefix, String postfix)
          Converts a Collection of erlang source or beam files into a string containing a valid erlang list of module names.
static String toString(com.ericsson.otp.erlang.OtpErlangObject object)
          Converts an OtpErlangObject into a String using the object specific conversion function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ErlUtils

public ErlUtils()
Method Detail

toList

public static <T> String toList(T[] array,
                                Predicate<T> p,
                                String prefix,
                                String postfix)
Converts an array into a string containing a valid erlang list.

Parameters:
array - to convert, maybe null
p - optional predicat whether to include a specific list element, maybe null
prefix - to prepend to an entry
postfix - to append to an entry
Returns:
a string representing a valid erlang list

toList

public static <T> String toList(Collection<T> list,
                                Predicate<T> p,
                                String prefix,
                                String postfix)
Converts a Collection into a string containing a valid erlang list.

Parameters:
list - to convert
p - optional predicat whether to include a specific list element, maybe null
prefix - to prepend to an entry
postfix - to append to an entry
Returns:
a string representing a valid erlang list

toFileList

public static String toFileList(Collection<File> list,
                                String prefix,
                                String postfix)
Converts a Collection of files into a string containing a valid erlang list. The files will be converted using File.getAbsolutePath(). The files will be checked for null and existence. The prefix and postfix Strings will be prepended/appended to every element of the list. This may be used to quote the returned paths correctly as erlang strings.

Parameters:
list - to convert
prefix - to prepend to an entry
postfix - to append to an entry
Returns:
a string representing a valid erlang list

toModuleList

public static String toModuleList(Collection<File> list,
                                  String prefix,
                                  String postfix)
Converts a Collection of erlang source or beam files into a string containing a valid erlang list of module names. The files will be checked for null and existence. The prefix and postfix Strings will be prepended/appended to every element of the list. This may be used to quote the module list correctly.

Parameters:
list - to convert
prefix - to prepend to an entry
postfix - to append to an entry
Returns:
a string representing a valid erlang list

toString

public static String toString(com.ericsson.otp.erlang.OtpErlangObject object)
Converts an OtpErlangObject into a String using the object specific conversion function. If there is no specific string conversion function available the default OtpErlangObject.toString() is used. Empty OtpErlangLists will result in an empty String.

Parameters:
object - to convert
Returns:
a non-null, trimmed String object

toInt

public static int toInt(com.ericsson.otp.erlang.OtpErlangObject object)
Converts an OtpErlangInt or an OtpErlangUInt into an int using the object specific conversion function. If the conversion can't be performed, or throws an error during conversion, the value 0 is always returned.

Parameters:
object - to convert
Returns:
the object int value or 0 if unable to convert

toApplicationTuples

public static String toApplicationTuples(org.apache.maven.artifact.Artifact... artifacts)
Returns a comma separated string of application version tuples taken from the given array of artifacts. Result string will look like {"app1", "version1"}, {"app2", "version2"}, ....

Parameters:
artifacts - to convert into application version tuples
Returns:
a non-null String object

toApplicationTuples

public static String toApplicationTuples(CheckAppResult... applicationInfos)
Returns a comma separated string of application version tuples taken from the given array of CheckAppResults. Result string will look like {"app1", "version1"}, {"app2", "version2"}, ....

Parameters:
applicationInfos - to convert into application version tuples
Returns:
a non-null String object

toArtifactIdListing

public static String toArtifactIdListing(Collection<org.apache.maven.artifact.Artifact> artifacts)
Generates a simple comma separated list of applications derived from the artifacts listed as dependencies. Intended to be used to fill in ${APPLICATIONS} in ResourceGenerator.

Parameters:
artifacts - to convert into an artifactId listing
Returns:
a non-null String containing a valid erlang list


Copyright © 2011 Lindenbaum GmbH. All Rights Reserved.