org.apache.felix.webconsole.internal
Class Util

java.lang.Object
  extended by org.apache.felix.webconsole.internal.Util

public class Util
extends Object

The Util class contains various utility methods used internally by the web console implementation and the build-in plugins.


Field Summary
static String PAGE_LOGS
          Logs subpage
static String PAGE_VM_STAT
          vm statistics subpage
static String PAGE_WEBAPPS
          web apps subpage
static String PARAM_ACTION
          Parameter name
static String PARAM_CONTENT
          Parameter name
static String PARAM_SHUTDOWN
          Parameter name
static String VALUE_SHUTDOWN
          Parameter value
 
Constructor Summary
Util()
           
 
Method Summary
static String getHeaderValue(Bundle bundle, String headerName)
          Returns the value of the header or the empty string if the header is not available.
static String getName(Bundle bundle, Locale locale)
          Return a display name for the given bundle: If the bundle has a non-empty Bundle-Name manifest header that value is returned. Otherwise the symbolic name is returned if set Otherwise the bundle's location is returned if defined Finally, as a last resort, the bundles id is returned
static ArrayList list(Enumeration e)
          This method is the same as Collections#list(Enumeration).
static Locale parseLocaleString(String locale)
          This method expects a locale string in format language_COUNTRY, or language.
static void sort(Bundle[] bundles, Locale locale)
          Orders the bundles according to their name as returned by getName(Bundle, Locale), with the exception that the system bundle is always place as the first entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAGE_WEBAPPS

public static final String PAGE_WEBAPPS
web apps subpage

See Also:
Constant Field Values

PAGE_VM_STAT

public static final String PAGE_VM_STAT
vm statistics subpage

See Also:
Constant Field Values

PAGE_LOGS

public static final String PAGE_LOGS
Logs subpage

See Also:
Constant Field Values

PARAM_ACTION

public static final String PARAM_ACTION
Parameter name

See Also:
Constant Field Values

PARAM_CONTENT

public static final String PARAM_CONTENT
Parameter name

See Also:
Constant Field Values

PARAM_SHUTDOWN

public static final String PARAM_SHUTDOWN
Parameter name

See Also:
Constant Field Values

VALUE_SHUTDOWN

public static final String VALUE_SHUTDOWN
Parameter value

See Also:
Constant Field Values
Constructor Detail

Util

public Util()
Method Detail

getName

public static String getName(Bundle bundle,
                             Locale locale)
Return a display name for the given bundle:
  1. If the bundle has a non-empty Bundle-Name manifest header that value is returned.
  2. Otherwise the symbolic name is returned if set
  3. Otherwise the bundle's location is returned if defined
  4. Finally, as a last resort, the bundles id is returned

Parameters:
bundle - the bundle which name to retrieve
locale - the locale, in which the bundle name is requested
Returns:
the bundle name - see the description of the method for more details.

getHeaderValue

public static String getHeaderValue(Bundle bundle,
                                    String headerName)
Returns the value of the header or the empty string if the header is not available.

Parameters:
bundle - the bundle which header to retrieve
headerName - the name of the header to retrieve
Returns:
the header or empty string if it is not set

sort

public static void sort(Bundle[] bundles,
                        Locale locale)
Orders the bundles according to their name as returned by getName(Bundle, Locale), with the exception that the system bundle is always place as the first entry. If two bundles have the same name, they are ordered according to their version. If they have the same version, the bundle with the lower bundle id comes before the other.

Parameters:
bundles - the bundles to sort
locale - the locale, used to obtain the localized bundle name

list

public static final ArrayList list(Enumeration e)
This method is the same as Collections#list(Enumeration). The reason to duplicate it here, is that it is missing in OSGi/Minimum execution environment.

Parameters:
e - the enumeration which to convert
Returns:
the list containing all enumeration entries.

parseLocaleString

public static final Locale parseLocaleString(String locale)
This method expects a locale string in format language_COUNTRY, or language. The method will determine which is the correct form of locale string and construct a Locale object.

Parameters:
locale - the locale string, if null - default locale is returned
Returns:
a locale object
See Also:
Locale


Copyright © 2011 Apache Software Foundation. All Rights Reserved.