hudson.plugins.im.tools
Class MessageHelper

java.lang.Object
  extended by hudson.plugins.im.tools.MessageHelper

public class MessageHelper
extends java.lang.Object

Utility class to help message creation

Author:
vsellier, kutzi

Constructor Summary
MessageHelper()
           
 
Method Summary
static
<T> T[]
concat(T[] array1, T[]... arrays)
          Returns a new array which a concatenation of the argument arrays.
static
<T> T[]
copyOf(T[] original, int newLength)
          Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.
static
<T> T[]
copyOfRange(T[] original, int from, int to)
          Copies the specified range of the specified array into a new array.
static java.lang.String[] extractCommandLine(java.lang.String message)
          Parses a bot command from a given string.
static java.lang.String getBuildURL(hudson.model.AbstractBuild<?,?> build)
          Returns the full URL to the build details page for a given build.
static java.lang.String getJoinedName(java.lang.String[] args, int startIndex)
          Extracts a name from an argument array starting at a start index and removing quoting ".
static java.lang.String getTestUrl(hudson.tasks.test.TestResult result)
          Returns the full URL to the test details page for a given test result;
static java.lang.String join(java.lang.String[] array, int startIndex)
          Joins together all strings in the array - starting at startIndex - by using a single space as separator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageHelper

public MessageHelper()
Method Detail

getBuildURL

public static java.lang.String getBuildURL(hudson.model.AbstractBuild<?,?> build)
Returns the full URL to the build details page for a given build.


getTestUrl

public static java.lang.String getTestUrl(hudson.tasks.test.TestResult result)
Returns the full URL to the test details page for a given test result;


extractCommandLine

public static java.lang.String[] extractCommandLine(java.lang.String message)
Parses a bot command from a given string. The 1st entry in the array contains the command name itself. The following entries contain the command parameters, if any.


copyOfRange

public static <T> T[] copyOfRange(T[] original,
                                  int from,
                                  int to)
Copies the specified range of the specified array into a new array. The initial index of the range (from) must lie between zero and original.length, inclusive. The value at original[from] is placed into the initial element of the copy (unless from == original.length or from == to). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to), which must be greater than or equal to from, may be greater than original.length, in which case (byte)0 is placed in all elements of the copy whose index is greater than or equal to original.length - from. The length of the returned array will be to - from.

Parameters:
original - the array from which a range is to be copied
from - the initial index of the range to be copied, inclusive
to - the final index of the range to be copied, exclusive. (This index may lie outside the array.)
Returns:
a new array containing the specified range from the original array, truncated or padded with zeros to obtain the required length
Throws:
java.lang.ArrayIndexOutOfBoundsException - if from < 0 or from > original.length()
java.lang.IllegalArgumentException - if from > to
java.lang.NullPointerException - if original is null Note: Unfortunately in Java 5 there is no Arrays#copyOfRange, yet. So we have to implement it ourself.

copyOf

public static <T> T[] copyOf(T[] original,
                             int newLength)
Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain null. Such indices will exist if and only if the specified length is greater than that of the original array.

Parameters:
original - the array to be copied
newLength - the length of the copy to be returned
Returns:
a copy of the original array, truncated or padded with nulls to obtain the specified length
Throws:
java.lang.NegativeArraySizeException - if newLength is negative
java.lang.NullPointerException - if original is null Note: copied from java 6

concat

public static <T> T[] concat(T[] array1,
                             T[]... arrays)
Returns a new array which a concatenation of the argument arrays.


join

public static java.lang.String join(java.lang.String[] array,
                                    int startIndex)
Joins together all strings in the array - starting at startIndex - by using a single space as separator.


getJoinedName

public static java.lang.String getJoinedName(java.lang.String[] args,
                                             int startIndex)
Extracts a name from an argument array starting at a start index and removing quoting ".

Parameters:
args - the arguments
startIndex - the start index
Returns:
the job name as a single String
Throws:
java.lang.IndexOutOfBoundsException - if startIndex > args length


Copyright © 2010. All Rights Reserved.