hudson.plugins.analysis.graph
Class GraphConfiguration

java.lang.Object
  extended by hudson.plugins.analysis.graph.GraphConfiguration

public class GraphConfiguration
extends Object

Configuration properties of a trend graph.


Field Summary
protected static String SEPARATOR
          Separator of cookie values.
 
Constructor Summary
GraphConfiguration(BuildResultGraph... availableGraphs)
          Creates a new instance of GraphConfiguration.
GraphConfiguration(BuildResultGraph graph)
          Creates a new instance of GraphConfiguration.
GraphConfiguration(Collection<? extends BuildResultGraph> availableGraphs)
          Creates a new instance of GraphConfiguration.
 
Method Summary
static hudson.util.FormValidation checkHeight(String height)
          Performs on-the-fly validation on the trend graph height.
static GraphConfiguration createDeactivated()
          Creates a configuration for a deactivated graph.
static GraphConfiguration createDefault()
          Creates a default configuration.
protected  File createDefaultsFile(hudson.model.AbstractProject<?,?> project, String pluginName)
          Creates a file with for the default values.
 boolean equals(Object obj)
          
 int getBuildCount()
          Returns the number of builds to consider.
 String getBuildCountString()
          Returns the build count as a string.
 int getDayCount()
          Returns the number of days to consider.
 String getDayCountString()
          Returns the day count as a string.
 BuildResultGraph getGraph(String graphId)
          Returns the graph with the specified ID.
 BuildResultGraph getGraphType()
          Returns the type of the graph.
 int getHeight()
          Returns the height.
 Collection<BuildResultGraph> getRegisteredGraphs()
          Returns the registered graphs.
 int getWidth()
          Returns the width.
 int hashCode()
           
 boolean initializeFrom(int width, int height)
          Initializes this configuration with the specified values.
 boolean initializeFrom(int width, int height, int dayCount)
          Initializes this configuration with the specified values.
 boolean initializeFrom(net.sf.json.JSONObject value)
          Parses the provided JSON object and initializes the members.
 boolean initializeFrom(String value)
          Parses the provided string and initializes the members.
 boolean initializeFrom(String width, String height, String dayCountString)
          Initializes this configuration with the specified values.
 boolean initializeFromFile(File file)
          Reads the specified file, parses the content and initializes the members.
protected  boolean initializeLocal(net.sf.json.JSONObject localConfiguration)
          Parses the provided JSON object and initializes the members of the local configuration.
protected  boolean initializeLocal(String[] localConfiguration)
          Parses the provided array of string values and initializes the members of the local configuration.
 boolean isBuildCountDefined()
          Returns whether a valid build count is defined.
 boolean isDayCountDefined()
          Returns whether a valid day count is defined.
 boolean isDefault()
          Returns whether this instance is initialized with its default values.
protected static boolean isValid(int newWidth, int newHeight, int newBuildCount, int newDayCount, BuildResultGraph newGraphType)
          Returns whether the configuration parameters are valid.
protected static boolean isValidBuildCount(int newBuildCount)
          Returns if the build count is valid.
protected static boolean isValidHeight(int newHeight)
          Returns whether the width is valid.
protected static boolean isValidWidth(int newWidth)
          Returns whether the width is valid.
 boolean isVisible()
          Returns whether the trend graph is visible or not.
protected  String serializeBoolean(boolean value)
          Serializes a boolean.
 String serializeToString()
          Serializes the values of this configuration.
 String toString()
           
 boolean useBuildDateAsDomain()
          Returns whether the build date or the build number should be used as domain.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SEPARATOR

protected static final String SEPARATOR
Separator of cookie values.

See Also:
Constant Field Values
Constructor Detail

GraphConfiguration

public GraphConfiguration(Collection<? extends BuildResultGraph> availableGraphs)
Creates a new instance of GraphConfiguration.

Parameters:
availableGraphs - the available build graphs

GraphConfiguration

public GraphConfiguration(BuildResultGraph... availableGraphs)
Creates a new instance of GraphConfiguration.

Parameters:
availableGraphs - the available build graphs

GraphConfiguration

public GraphConfiguration(BuildResultGraph graph)
Creates a new instance of GraphConfiguration.

Parameters:
graph - the graph to use
Method Detail

createDeactivated

public static GraphConfiguration createDeactivated()
Creates a configuration for a deactivated graph.

Returns:
a configuration for a deactivated graph

createDefault

public static GraphConfiguration createDefault()
Creates a default configuration.

Returns:
a default configuration

initializeFrom

public boolean initializeFrom(String value)
Parses the provided string and initializes the members. If the string is not in the expected format, then false is returned and the members are reset to their default values.

Parameters:
value - the initialization value stored in the format width!height!buildCount!dayCount!graphType
Returns:
true is the initialization was successful, false otherwise
See Also:
serializeToString()

initializeFrom

public boolean initializeFrom(int width,
                              int height)
Initializes this configuration with the specified values.

Parameters:
width - the width of the graph
height - the height of the graph
Returns:
true is the initialization was successful, false otherwise

initializeFrom

public boolean initializeFrom(int width,
                              int height,
                              int dayCount)
Initializes this configuration with the specified values.

Parameters:
width - the width of the graph
height - the height of the graph
dayCount - the number of days to build the graph for
Returns:
true is the initialization was successful, false otherwise

initializeFrom

public boolean initializeFrom(String width,
                              String height,
                              String dayCountString)
Initializes this configuration with the specified values.

Parameters:
width - the width of the graph
height - the height of the graph
dayCountString - the number of days to build the graph for
Returns:
true is the initialization was successful, false otherwise

initializeLocal

protected boolean initializeLocal(String[] localConfiguration)
Parses the provided array of string values and initializes the members of the local configuration. If the values are not in the expected format, then false is returned and the members are reset to their default values.

The provided default implementation simply returns true.

Parameters:
localConfiguration - the initialization values
Returns:
true is the initialization was successful, false otherwise
See Also:
serializeToString()

initializeFrom

public boolean initializeFrom(net.sf.json.JSONObject value)
Parses the provided JSON object and initializes the members. If the JSON object is not in the expected format, then false is returned and the members are reset to their default values.

Parameters:
value - the initialization value
Returns:
true is the initialization was successful, false otherwise
See Also:
serializeToString()

initializeLocal

protected boolean initializeLocal(net.sf.json.JSONObject localConfiguration)
Parses the provided JSON object and initializes the members of the local configuration. If the values are not in the expected format, then false is returned and the members are reset to their default values.

The provided default implementation simply returns true.

Parameters:
localConfiguration - the initialization values
Returns:
true is the initialization was successful, false otherwise
See Also:
serializeToString()

initializeFromFile

public boolean initializeFromFile(File file)
Reads the specified file, parses the content and initializes the members. If the string is not in the expected format of the file could not be read, then false is returned and the members are reset to their default values.

Parameters:
file - the file with the initialization values
Returns:
true is the initialization was successful, false otherwise
See Also:
serializeToString()

createDefaultsFile

protected File createDefaultsFile(hudson.model.AbstractProject<?,?> project,
                                  String pluginName)
Creates a file with for the default values.

Parameters:
project - the project used as directory for the file
pluginName - the name of the plug-in
Returns:
the created file

getBuildCountString

public String getBuildCountString()
Returns the build count as a string. If no build count is defined, then an empty string is returned.

Returns:
the day count string

getDayCountString

public String getDayCountString()
Returns the day count as a string. If no day count is defined, then an empty string is returned.

Returns:
the day count string

serializeToString

public String serializeToString()
Serializes the values of this configuration.

Returns:
serialized configuration
See Also:
initializeFrom(String)

serializeBoolean

protected String serializeBoolean(boolean value)
Serializes a boolean.

Parameters:
value - the value
Returns:
serialized value

isValid

protected static boolean isValid(int newWidth,
                                 int newHeight,
                                 int newBuildCount,
                                 int newDayCount,
                                 BuildResultGraph newGraphType)
Returns whether the configuration parameters are valid.

Parameters:
newWidth - the new width
newHeight - the new height
newBuildCount - the new build count
newDayCount - the new day count
newGraphType - the new graph type
Returns:
true if the configuration parameters are valid, false otherwise.

isValidBuildCount

protected static boolean isValidBuildCount(int newBuildCount)
Returns if the build count is valid.

Parameters:
newBuildCount - the new build count
Returns:
true if the build count is valid.

isValidWidth

protected static boolean isValidWidth(int newWidth)
Returns whether the width is valid.

Parameters:
newWidth - the new width
Returns:
true if the width is valid, false otherwise

isValidHeight

protected static boolean isValidHeight(int newHeight)
Returns whether the width is valid.

Parameters:
newHeight - the new height
Returns:
true if the width is valid, false otherwise

getHeight

public int getHeight()
Returns the height.

Returns:
the height

getWidth

public int getWidth()
Returns the width.

Returns:
the width

useBuildDateAsDomain

public boolean useBuildDateAsDomain()
Returns whether the build date or the build number should be used as domain.

Returns:
the build date or the build number should be used as domain

getBuildCount

public int getBuildCount()
Returns the number of builds to consider.

Returns:
the number of builds to consider

isBuildCountDefined

public boolean isBuildCountDefined()
Returns whether a valid build count is defined.

Returns:
true if there is a valid build count is defined, false otherwise

getDayCount

public int getDayCount()
Returns the number of days to consider.

Returns:
the number of days to consider

isDayCountDefined

public boolean isDayCountDefined()
Returns whether a valid day count is defined.

Returns:
true if there is a valid day count is defined, false otherwise

getGraphType

public BuildResultGraph getGraphType()
Returns the type of the graph.

Returns:
the type

isDefault

public boolean isDefault()
Returns whether this instance is initialized with its default values.

Returns:
true if this instance is initialized with its default values.

isVisible

public boolean isVisible()
Returns whether the trend graph is visible or not.

Returns:
true, if the trend graph is visible, false otherwise

toString

public String toString()
Overrides:
toString in class Object

getRegisteredGraphs

public Collection<BuildResultGraph> getRegisteredGraphs()
Returns the registered graphs.

Returns:
the registered graphs

getGraph

public BuildResultGraph getGraph(String graphId)
Returns the graph with the specified ID.

Parameters:
graphId - the graph ID
Returns:
the graph with the specified ID. If the graph is not found, then DEFAULT_GRAPH is returned.

checkHeight

public static hudson.util.FormValidation checkHeight(String height)
Performs on-the-fly validation on the trend graph height.

Parameters:
height - the height
Returns:
the form validation

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object


Copyright © 2004-2012 Hudson. All Rights Reserved.