org.fusesource.fabric.commands.support
Class CommandUtils

java.lang.Object
  extended by org.fusesource.fabric.commands.support.CommandUtils

public final class CommandUtils
extends java.lang.Object

Various utility methods for the commands.


Method Summary
static int countContainersByVersion(Container[] containers, Version version)
          Counts the number of containers for the given version
static Container[] filterContainers(Container[] containers, java.lang.String filter)
          Filter the containers by id and profiles, using the given filter.
static boolean matchVersion(Container container, Version version)
          Does the container match the given version.
static Container[] sortContainers(Container[] containers)
          Sorts the containers.
static Profile[] sortProfiles(Profile[] profiles)
          Sorts the profiles.
static java.lang.String status(Container container)
          Lets trim the status to a maximum size of 100 chars (for example when it has an exception it may be long)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sortProfiles

public static Profile[] sortProfiles(Profile[] profiles)
Sorts the profiles.

Parameters:
profiles - the profiles
Returns:
the sorted profiles

sortContainers

public static Container[] sortContainers(Container[] containers)
Sorts the containers.

Parameters:
containers - the containers
Returns:
the sorted containers

filterContainers

public static Container[] filterContainers(Container[] containers,
                                           java.lang.String filter)
Filter the containers by id and profiles, using the given filter.

A container will be included if its id or profile ids contains part of the given filter.

Parameters:
containers - the containers
filter - optional filter to match
Returns:
the matching containers

matchVersion

public static boolean matchVersion(Container container,
                                   Version version)
Does the container match the given version.

If the version is null then the container matches.

Parameters:
container - the container
version - the version
Returns:
true if matches

status

public static java.lang.String status(Container container)
Lets trim the status to a maximum size of 100 chars (for example when it has an exception it may be long)

Parameters:
container - the container
Returns:
the provisional status

countContainersByVersion

public static int countContainersByVersion(Container[] containers,
                                           Version version)
Counts the number of containers for the given version

Parameters:
containers - the containers
version - the version
Returns:
number of containers of the given version


Copyright © 2012 FuseSource. All Rights Reserved.