com.sonyericsson.hudson.plugins.metadata.model.values
Class AbstractMetadataValue

java.lang.Object
  extended by com.sonyericsson.hudson.plugins.metadata.model.values.AbstractMetadataValue
All Implemented Interfaces:
Metadata<MetadataValue>, MetadataValue, hudson.model.Describable<AbstractMetadataValue>, Serializable, Cloneable, Comparable<Object>
Direct Known Subclasses:
DateMetadataValue, NumberMetadataValue, StringMetadataValue, TreeNodeMetadataValue

@ExportedBean
public abstract class AbstractMetadataValue
extends Object
implements Serializable, hudson.model.Describable<AbstractMetadataValue>, MetadataValue

A metadata value to be set in a job or node.

See Also:
Serialized Form

Nested Class Summary
static class AbstractMetadataValue.AbstractMetaDataValueDescriptor
          The descriptor for the AbstractMetadataValue.
 
Field Summary
protected  String name
          The name of this metadata value.
 
Constructor Summary
protected AbstractMetadataValue(String name)
          Constructor with only a name.
protected AbstractMetadataValue(String name, String description)
          Constructor with name and description.
protected AbstractMetadataValue(String name, String description, boolean exposedToEnvironment)
          Constructor with name, description and exposedToEnvironment.
 
Method Summary
 void addEnvironmentVariables(hudson.EnvVars variables, boolean exposeAll)
          Adds the environment variables for this Metadata to the variables map.
 AbstractMetadataValue clone()
          Clones this MetadataValue.
 String getDescription()
          Get the description of this value.
 String getEnvironmentName()
          This function will generate the full environment variable name.
 String getFullName()
          This function will generate the full name.
 String getFullName(String separator)
          This function will generate the full name, using the chosen separator.
 String getFullNameFrom(MetadataParent<MetadataValue> base)
          Gives the full name.
 String[] getFullPath()
          Gives the full path as a String array..
 String getName()
          Get the name of this value.
 MetadataParent<MetadataValue> getParent()
          This value's parent.
 Object getValue()
          Get the value.
 boolean isExposedToEnvironment()
          Returns whether or not this should be exposed to the environment.
 boolean isGenerated()
          If this value is generated or user created.
 void replacementOf(MetadataValue old)
          A signal sent to this object that it is the replacement of another object.
 void setDescription(String description)
          Set the description of this value.
 void setExposeToEnvironment(boolean expose)
          Set whether this should be exposed to the environment or not.
 void setGenerated(boolean generated)
          Set if this value is generated or user created.
protected  void setName(String name)
          Set the name of this value.
 void setParent(MetadataParent<MetadataValue> parent)
          This value's parent.
protected  net.sf.json.JSONObject toAbstractJson()
          Converts this into a JSON Object without the value.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hudson.model.Describable
getDescriptor
 
Methods inherited from interface com.sonyericsson.hudson.plugins.metadata.model.values.MetadataValue
toJson
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

name

protected String name
The name of this metadata value.

Constructor Detail

AbstractMetadataValue

protected AbstractMetadataValue(String name,
                                String description,
                                boolean exposedToEnvironment)
Constructor with name, description and exposedToEnvironment.

Parameters:
name - The name of the definitions.
description - The description of the definitions.
exposedToEnvironment - If this value should be exposed as an environment variable.

AbstractMetadataValue

protected AbstractMetadataValue(String name,
                                String description)
Constructor with name and description.

Parameters:
name - The name of the definitions.
description - The description of the definitions.

AbstractMetadataValue

protected AbstractMetadataValue(String name)
Constructor with only a name.

Parameters:
name - The name of the definitions.
Method Detail

getDescription

@Exported
public String getDescription()
Get the description of this value.

Specified by:
getDescription in interface Metadata<MetadataValue>
Returns:
the description.

setDescription

public void setDescription(String description)
Set the description of this value.

Parameters:
description - the description.

getName

@Exported
public final String getName()
Get the name of this value.

Specified by:
getName in interface Metadata<MetadataValue>
Returns:
the name.

setName

protected void setName(String name)
Set the name of this value.

Parameters:
name - the name.

getValue

@Exported
public Object getValue()
Get the value.

Specified by:
getValue in interface Metadata<MetadataValue>
Returns:
the value.

getParent

public MetadataParent<MetadataValue> getParent()
This value's parent.

Specified by:
getParent in interface Metadata<MetadataValue>
Returns:
the parent.

setParent

public void setParent(MetadataParent<MetadataValue> parent)
This value's parent.

Specified by:
setParent in interface Metadata<MetadataValue>
Parameters:
parent - the parent.

isGenerated

public boolean isGenerated()
If this value is generated or user created.

Specified by:
isGenerated in interface MetadataValue
Returns:
true if generated.

setGenerated

public void setGenerated(boolean generated)
Set if this value is generated or user created.

Specified by:
setGenerated in interface MetadataValue
Parameters:
generated - true if generated.

getFullName

@Exported
public String getFullName(String separator)
This function will generate the full name, using the chosen separator.

Parameters:
separator - the separator to use.
Returns:
the full name.

getFullName

@Exported
public String getFullName()
This function will generate the full name.

Specified by:
getFullName in interface Metadata<MetadataValue>
Returns:
the full name.

getFullNameFrom

public String getFullNameFrom(MetadataParent<MetadataValue> base)
Description copied from interface: Metadata
Gives the full name.

Specified by:
getFullNameFrom in interface Metadata<MetadataValue>
Parameters:
base - the parent to calculate the path from.
Returns:
a dot separated path from the base up to this item.

getFullPath

public String[] getFullPath()
Description copied from interface: Metadata
Gives the full path as a String array..

Specified by:
getFullPath in interface Metadata<MetadataValue>
Returns:
the full name as a String array instead of a String.

replacementOf

public void replacementOf(MetadataValue old)
Description copied from interface: MetadataValue
A signal sent to this object that it is the replacement of another object. The intention from the system is that the object should take this opportunity to try and salvage as much as possible from the old object.

Specified by:
replacementOf in interface MetadataValue
Parameters:
old - the object that it is the replacement of.

addEnvironmentVariables

public void addEnvironmentVariables(hudson.EnvVars variables,
                                    boolean exposeAll)
Description copied from interface: MetadataValue
Adds the environment variables for this Metadata to the variables map.

Specified by:
addEnvironmentVariables in interface MetadataValue
Parameters:
variables - the map of current environment variables.
exposeAll - whether all Metadata should be added to the map. Inherited from the parent.

getEnvironmentName

@Exported
public String getEnvironmentName()
This function will generate the full environment variable name. The format will be MD_FULL_PATH_TO_CHILD

Returns:
the full environment variable name.

isExposedToEnvironment

public boolean isExposedToEnvironment()
Description copied from interface: Metadata
Returns whether or not this should be exposed to the environment.

Specified by:
isExposedToEnvironment in interface Metadata<MetadataValue>
Returns:
whether this should be exposed to the environment or not.

setExposeToEnvironment

public void setExposeToEnvironment(boolean expose)
Description copied from interface: Metadata
Set whether this should be exposed to the environment or not.

Specified by:
setExposeToEnvironment in interface Metadata<MetadataValue>
Parameters:
expose - true if this should be exposed, false if not.

toAbstractJson

protected net.sf.json.JSONObject toAbstractJson()
Converts this into a JSON Object without the value. Implementing classes can use this as a utility method for the name, type and description. And then just add the value.

Returns:
the half finished JSON Object.

clone

public AbstractMetadataValue clone()
                            throws CloneNotSupportedException
Description copied from interface: MetadataValue
Clones this MetadataValue.

Specified by:
clone in interface MetadataValue
Overrides:
clone in class Object
Returns:
a clone of this MetadataValue.
Throws:
CloneNotSupportedException - if it cannot be cloned.


Copyright © 2004-2013. All Rights Reserved.