net.sf.mmm.util.cli.base
Class CliClassContainer

java.lang.Object
  extended by net.sf.mmm.util.cli.base.CliClassContainer
Direct Known Subclasses:
CliState

public class CliClassContainer
extends Object

A CliClassContainer determines and holds the class-specific CLI-informations of a state-class.

Since:
2.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Nested Class Summary
private static class CliClassContainer.CliDefaultAnnotations
          This inner class is a dummy for getting default instances of CLI annotations.
protected static class CliClassContainer.CliModeFormatter
          This inner class converts a CliModeContainer to a String.
 
Field Summary
private  CliClass cliClass
           
private  CliStyle cliStyle
           
private  Map<String,CliModeContainer> id2ModeMap
           
private  org.slf4j.Logger logger
           
private  String name
           
private  Class<?> stateClass
           
 
Constructor Summary
CliClassContainer(Class<?> stateClass, org.slf4j.Logger logger)
          The constructor.
 
Method Summary
private  void addMode(CliMode mode, Class<?> annotatedClass)
          This method adds the given CliMode.
protected  void addMode(CliModeContainer mode)
          This method adds the given CliMode.
 CliClass getCliClass()
          This method gets the CliClass configured for the state-class.
 CliStyle getCliStyle()
          This method gets the style configured for the state-class.
 org.slf4j.Logger getLogger()
          This method gets the Logger.
 CliModeObject getMode(String id)
          This method gets the mode associated with the given ID.
 Collection<String> getModeIds()
          This method gets the Collection with the IDs of all registered CliModes.
 String getName()
          This method gets the name configured for the state-class.
 Class<?> getStateClass()
          This method gets the Class reflecting the state-object.
protected  NodeCycle<CliModeContainer> initializeModeRecursive(CliModeContainer mode)
          This method initializes the given CliModeContainer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stateClass

private final Class<?> stateClass
See Also:
getStateClass()

cliStyle

private final CliStyle cliStyle
See Also:
getCliStyle()

cliClass

private final CliClass cliClass
See Also:
getCliClass()

id2ModeMap

private final Map<String,CliModeContainer> id2ModeMap
See Also:
getMode(String)

name

private final String name
See Also:
getName()

logger

private final org.slf4j.Logger logger
See Also:
getLogger()
Constructor Detail

CliClassContainer

public CliClassContainer(Class<?> stateClass,
                         org.slf4j.Logger logger)
The constructor.

Parameters:
stateClass - is the state-class.
logger - is the Logger to use (e.g. for CliStyleHandling).
Method Detail

getLogger

public org.slf4j.Logger getLogger()
This method gets the Logger.

Returns:
the Logger.

initializeModeRecursive

protected NodeCycle<CliModeContainer> initializeModeRecursive(CliModeContainer mode)
                                                       throws NodeCycleException
This method initializes the given CliModeContainer.

Parameters:
mode - is the CliModeContainer to initialize.
Returns:
a NodeCycle if a cyclic dependency has been detected but is NOT yet complete or null if the initialization was successful.
Throws:
NodeCycleException - if a cyclic dependency was detected and completed.

addMode

private void addMode(CliMode mode,
                     Class<?> annotatedClass)
This method adds the given CliMode.

Parameters:
mode - is the CliMode to add.
annotatedClass - is the Class where the CliMode was annotated.

addMode

protected void addMode(CliModeContainer mode)
This method adds the given CliMode.

Parameters:
mode - is the CliMode to add.

getStateClass

public Class<?> getStateClass()
This method gets the Class reflecting the state-object.

Returns:
the state-class.

getCliStyle

public CliStyle getCliStyle()
This method gets the style configured for the state-class. If no such annotation is present, a default instance is returned.

Returns:
the CliStyle.

getCliClass

public CliClass getCliClass()
This method gets the CliClass configured for the state-class. If no such annotation is present, a default instance is returned.

Returns:
the CliClass.

getMode

public CliModeObject getMode(String id)
This method gets the mode associated with the given ID.

Parameters:
id - the ID of the requested CliMode.
Returns:
the requested CliMode or null if no such CliMode exists.

getModeIds

public Collection<String> getModeIds()
This method gets the Collection with the IDs of all registered CliModes.

Returns:
the mode-IDs.

getName

public String getName()
This method gets the name configured for the state-class.

Returns:
the annotated name or the class-name of the state-class if NOT configured.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.