OpenNMS API 1.2.9

## org.opennms.web
Class Util

    java.lang.Object
      org.opennms.web.Util

public abstract class Util
extends java.lang.Object

Provides convenience functions for web-based interfaces.

Author:
  Lawrence Karnowski , OpenNMS

Nested Class Summary
`static class` `Util.IgnoreType`

Field Summary
`protected static java.lang.Boolean` `usePortInBaseUrls` Internal flag used to cache a servlet context parameter

Constructor Summary
`Util()`

Method Summary
`static java.lang.String` `calculateUrlBase(javax.servlet.http.HttpServletRequest request)` Return a string that represents the fully qualified URL for our servlet context, suitable for use in the HTML base tag.
`static java.lang.String[]` `createCommandArray(java.lang.String s, char delim)` Convenience method for creating arrays of strings suitable for use as command-line parameters when executing an external process.
`static java.lang.String` `decode(java.lang.String string)` Encapsulate the deprecated decode method to fix it in one place.
`static java.lang.String` `encode(java.lang.String string)` Encapsulate the deprecated encode method to fix it in one place.
`static java.lang.String` `getHostname(java.lang.String ipAddress)` Deprecated. Please use `NetworkElementFactory.getHostname` instead.
`static java.lang.String` `getHumanReadableIfSpeed(long ifSpeed)` Method used to convert an integer bits-per-second value and a more commonly recognized abbreviation for network interface speeds.
`static java.util.Map` `getOrderedMap(java.lang.String[][] names)`
`static java.lang.String` `htmlify(java.lang.String input)`
`static java.lang.String` `makeHiddenTags(javax.servlet.http.HttpServletRequest request)` Creates hidden tags for all the parameters given in the request.
`static java.lang.String` `makeHiddenTags(javax.servlet.http.HttpServletRequest request, java.util.Map additions)` Creates hidden tags for all the parameters given in the request.
`static java.lang.String` `makeHiddenTags(javax.servlet.http.HttpServletRequest request, java.util.Map additions, java.lang.String[] ignores)` Creates hidden tags for all the parameters given in the request plus the additions, except for the parameters and additions listed in the ignore list.
`static java.lang.String` `makeHiddenTags(javax.servlet.http.HttpServletRequest request, java.util.Map additions, java.lang.String[] ignores, Util.IgnoreType ignoreType)` Creates hidden tags for all the parameters given in the request plus the additions, except for the parmeters listed in the ignore list.
`static java.lang.String` `makeHiddenTags(javax.servlet.http.HttpServletRequest request, java.lang.String[] ignores)` Creates hidden tags for all the parameters given in the request.
`static java.lang.String` `makeQueryString(javax.servlet.http.HttpServletRequest request)` Creates a query string of the format "key1=value1&key2=value2" for each parameter in the given `HttpServletRequest`.
`static java.lang.String` `makeQueryString(javax.servlet.http.HttpServletRequest request, java.util.Map additions)` Creates a query string of the format "key1=value1&key2=value2" for each parameter in the given `HttpServletRequest` and key in given `Map`.
`static java.lang.String` `makeQueryString(javax.servlet.http.HttpServletRequest request, java.util.Map additions, java.lang.String[] ignores)` Creates a query string of the format "key1=value1&key2=value2" for each parameter in the given `HttpServletRequest` and key in given `Map` that is not listed in the ignore list.
`static java.lang.String` `makeQueryString(javax.servlet.http.HttpServletRequest request, java.util.Map additions, java.lang.String[] ignores, Util.IgnoreType ignoreType)` Creates a query string of the format "key1=value1&key2=value2" for each parameter in the given `HttpServletRequest` and key in given `Map` that is not listed in the ignore list.
`static java.lang.String` `makeQueryString(javax.servlet.http.HttpServletRequest request, java.lang.String[] ignores)` Creates a query string of the format "key1=value1&key2=value2" for each parameter in the given `HttpServletRequest` that is not listed in the ignore list.
`static java.lang.String` `resolveIpAddress(java.lang.String ipAddress)` Deprecated. Please use `NetworkElementFactory.getHostname` instead.
`static void` `streamToStream(java.io.InputStream in, java.io.OutputStream out)` Convenience method for reading data from an `InputStream` and then immediately writing that data to an `OutputStream` with a default buffer size of one kilobyte (1,024 bytes).
`static void` `streamToStream(java.io.InputStream in, java.io.OutputStream out, int bufferSize)` Convenience method for reading data from an `InputStream` and then immediately writing that data to an `OutputStream`.
`static void` `streamToStream(java.io.Reader in, java.io.Writer out)` Convenience method for reading data from a `Reader` and then immediately writing that data to a `Writer` with a default buffer size of one kilobyte (1,024 chars).
`static void` `streamToStream(java.io.Reader in, java.io.Writer out, int bufferSize)` Convenience method for reading data from a `Reader` and then immediately writing that data to a `Writer`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### usePortInBaseUrls

    protected static java.lang.Boolean usePortInBaseUrls

  Internal flag used to cache a servlet context parameter

Constructor Detail

### Util

    public Util()

Method Detail

### calculateUrlBase

    public static java.lang.String calculateUrlBase(javax.servlet.http.HttpServletRequest request)

  Return a string that represents the fully qualified URL for our servlet context, suitable for use in the HTML base tag.

  As an example, suppose your host was www.mycompany.com, you are serving from port 80, and your web application name was "opennms," then this method would return: `http://www.mycompany.com:80/opennms/`

  Parameters:
    `request` - the servlet request you are servicing

### getHostname

    public static java.lang.String getHostname(java.lang.String ipAddress)

  Deprecated. Please use `NetworkElementFactory.getHostname` instead.

  Convenience method for resolving the human-readable hostname for an IP address, if at all possible. If the hostname cannot be found, this method returns the IP address parameter.

  Parameters:
    `ipAddress` - the IP address for which you want the hostname

### encode

    public static java.lang.String encode(java.lang.String string)

  Encapsulate the deprecated encode method to fix it in one place.

  Parameters:
    `string` - string to be encoded
  Returns:
    encoded string

### decode

    public static java.lang.String decode(java.lang.String string)

  Encapsulate the deprecated decode method to fix it in one place.

  Parameters:
    `string` - string to be decoded
  Returns:
    decoded string

### resolveIpAddress

    public static java.lang.String resolveIpAddress(java.lang.String ipAddress)

  Deprecated. Please use `NetworkElementFactory.getHostname` instead.

  Convenience method for resolving the human-readable hostname for an IP address, if at all possible. If the hostname cannot be found, from the table, this method returns the IP address parameter. This method doesnt throw any exception.

  Parameters:
    `ipAddress` - the IP address for which you want the hostname

### getHumanReadableIfSpeed

    public static java.lang.String getHumanReadableIfSpeed(long ifSpeed)

  Method used to convert an integer bits-per-second value and a more commonly recognized abbreviation for network interface speeds. Feel free to expand it as necessary to accomodate different values.

  Parameters:
    `ifSpeed` - The bits-per-second value to be converted into a string description
  Returns:
    A string representation of the speed ("100 Mbps" for example)

### makeHiddenTags

    public static java.lang.String makeHiddenTags(javax.servlet.http.HttpServletRequest request)

  Creates hidden tags for all the parameters given in the request.

  Parameters:
    `request` - the `HttpServletRequest` to read the parameters from
  Returns:
    A string containing an HTML <input type="hidden" name=" `paramName`" value=" `paramValue`" /> tag for each parameter.

### makeHiddenTags

    public static java.lang.String makeHiddenTags(javax.servlet.http.HttpServletRequest request,
                                                  java.util.Map additions)

  Creates hidden tags for all the parameters given in the request.

  Parameters:
    `request` - the `HttpServletRequest` to read the parameters from
    `additions` - a map of extra parameters to create hidden tags for
  Returns:
    A string containing an HTML <input type="hidden" name=" `paramName`" value=" `paramValue`" /> tag for each parameter.

### makeHiddenTags

    public static java.lang.String makeHiddenTags(javax.servlet.http.HttpServletRequest request,
                                                  java.lang.String[] ignores)

  Creates hidden tags for all the parameters given in the request.

  Parameters:
    `request` - the `HttpServletRequest` to read the parameters from
    `ignores` - A string array containing request parameters to ignore
  Returns:
    A string containing an HTML <input type="hidden" name=" `paramName`" value=" `paramValue`" /> tag for each parameter.

### makeHiddenTags

    public static java.lang.String makeHiddenTags(javax.servlet.http.HttpServletRequest request,
                                                  java.util.Map additions,
                                                  java.lang.String[] ignores)

  Creates hidden tags for all the parameters given in the request plus the additions, except for the parameters and additions listed in the ignore list.

  Parameters:
    `request` - the `HttpServletRequest` to read the parameters from
    `additions` - a map of extra parameters to create hidden tags for
    `ignores` - the list of parameters not to create a hidden tag for
  Returns:
    A string containing an HTML <input type="hidden" name=" `paramName`" value=" `paramValue`" /> tag for each parameter not in the ignore list.

### makeHiddenTags

    public static java.lang.String makeHiddenTags(javax.servlet.http.HttpServletRequest request,
                                                  java.util.Map additions,
                                                  java.lang.String[] ignores,
                                                  Util.IgnoreType ignoreType)

  Creates hidden tags for all the parameters given in the request plus the additions, except for the parmeters listed in the ignore list.

  Parameters:
    `request` - the `HttpServletRequest` to read the parameters from
    `additions` - a map of extra parameters to create hidden tags for
    `ignores` - the list of parameters not to create a hidden tag for
    `ignoreType` - whether the ignore list applies to the request parameters, values in the additions map, or both
  Returns:
    A string containing an HTML <input type="hidden" name=" `paramName`" value=" `paramValue`" /> tag for each parameter not in the ignore list.

### makeQueryString

    public static java.lang.String makeQueryString(javax.servlet.http.HttpServletRequest request)

  Creates a query string of the format "key1=value1&key2=value2" for each parameter in the given `HttpServletRequest`.

  See Also:
    `makeQueryString( HttpServletRequest, Map, String[] )`

### makeQueryString

    public static java.lang.String makeQueryString(javax.servlet.http.HttpServletRequest request,
                                                   java.util.Map additions)

  Creates a query string of the format "key1=value1&key2=value2" for each parameter in the given `HttpServletRequest` and key in given `Map`.

  See Also:
    `makeQueryString( HttpServletRequest, Map, String[] )`

### makeQueryString

    public static java.lang.String makeQueryString(javax.servlet.http.HttpServletRequest request,
                                                   java.lang.String[] ignores)

  Creates a query string of the format "key1=value1&key2=value2" for each parameter in the given `HttpServletRequest` that is not listed in the ignore list.

  See Also:
    `makeQueryString( HttpServletRequest, Map, String[] )`

### makeQueryString

    public static java.lang.String makeQueryString(javax.servlet.http.HttpServletRequest request,
                                                   java.util.Map additions,
                                                   java.lang.String[] ignores)

  Creates a query string of the format "key1=value1&key2=value2" for each parameter in the given `HttpServletRequest` and key in given `Map` that is not listed in the ignore list.

  Parameters:
    `request` - the `HttpServletRequest` to read the parameters from
    `additions` - a mapping of strings to strings or string arrays to be included in the query string
    `ignores` - the list of parameters and map entries not to include
  Returns:
    A string in the x-www-form-urlencoded format that is suitable for adding to a URL as a query string.

### makeQueryString

    public static java.lang.String makeQueryString(javax.servlet.http.HttpServletRequest request,
                                                   java.util.Map additions,
                                                   java.lang.String[] ignores,
                                                   Util.IgnoreType ignoreType)

  Creates a query string of the format "key1=value1&key2=value2" for each parameter in the given `HttpServletRequest` and key in given `Map` that is not listed in the ignore list.

  Parameters:
    `request` - the `HttpServletRequest` to read the parameters from
    `additions` - a mapping of strings to strings or string arrays to be included in the query string
    `ignores` - the list of parameters and map entries not to include
  Returns:
    A string in the x-www-form-urlencoded format that is suitable for adding to a URL as a query string.

### getOrderedMap

    public static java.util.Map getOrderedMap(java.lang.String[][] names)

### streamToStream

    public static void streamToStream(java.io.Reader in,
                                      java.io.Writer out)
                               throws java.io.IOException

  Convenience method for reading data from a `Reader` and then immediately writing that data to a `Writer` with a default buffer size of one kilobyte (1,024 chars).

  Parameters:
    `in` - a data source
    `out` - a data sink
  Throws:
    `java.io.IOException`

### streamToStream

    public static void streamToStream(java.io.Reader in,
                                      java.io.Writer out,
                                      int bufferSize)
                               throws java.io.IOException

  Convenience method for reading data from a `Reader` and then immediately writing that data to a `Writer`.

  Parameters:
    `in` - a data source
    `out` - a data sink
    `bufferSize` - the size of the `char` buffer to use for each read/write
  Throws:
    `java.io.IOException`

### streamToStream

    public static void streamToStream(java.io.InputStream in,
                                      java.io.OutputStream out)
                               throws java.io.IOException

  Convenience method for reading data from an `InputStream` and then immediately writing that data to an `OutputStream` with a default buffer size of one kilobyte (1,024 bytes).

  Parameters:
    `in` - a data source
    `out` - a data sink
  Throws:
    `java.io.IOException`

### streamToStream

    public static void streamToStream(java.io.InputStream in,
                                      java.io.OutputStream out,
                                      int bufferSize)
                               throws java.io.IOException

  Convenience method for reading data from an `InputStream` and then immediately writing that data to an `OutputStream`.

  Parameters:
    `in` - a data source
    `out` - a data sink
    `bufferSize` - the size of the `byte` buffer to use for each read/write
  Throws:
    `java.io.IOException`

### createCommandArray

    public static java.lang.String[] createCommandArray(java.lang.String s,
                                                        char delim)

  Convenience method for creating arrays of strings suitable for use as command-line parameters when executing an external process.

  The default `Runtime.exec`method will split a single string based on spaces, but it does not respect spaces within quotation marks, and it will leave the quotation marks in the resulting substrings. This method solves those problems by replacing all in-quote spaces with the given delimiter, removes the quotes, and then splits the resulting string by the remaining out-of-quote spaces. It then goes through each substring and replaces the delimiters with spaces.

  Caveat: This method does not respect escaped quotes! It will simply remove them and leave the stray escape characters.

  Parameters:
    `s` - the string to split
    `delim` - a char that does not already exist in `s`
  Returns:
    An array of strings split by spaces outside of quotes.
  Throws:
    `java.lang.IllegalArgumentException` - If `s` is null or if `delim` already exists in `s`.

### htmlify

    public static java.lang.String htmlify(java.lang.String input)

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.