hudson.model
Class Items

java.lang.Object
  extended by hudson.model.Items

public class Items
extends Object

Convenience methods related to Item.

Author:
Kohsuke Kawaguchi

Field Summary
static List<TopLevelItemDescriptor> LIST
          Deprecated. as of 1.286 Use all() for read access and Extension for registration.
static com.thoughtworks.xstream.XStream XSTREAM
          Used to load/save job configuration.
static XStream2 XSTREAM2
          Alias to XSTREAM so that one can access additional methods on XStream2 more easily.
 
Constructor Summary
Items()
           
 
Method Summary
static DescriptorExtensionList<TopLevelItem,TopLevelItemDescriptor> all()
          Returns all the registered TopLevelItemDescriptors.
static String computeRelativeNamesAfterRenaming(String oldFullName, String newFullName, String relativeNames, ItemGroup context)
          Compute the relative name of list of items after a rename occurred.
static
<T extends Item>
List<T>
fromNameList(ItemGroup context, String list, Class<T> type)
          Does the opposite of toNameList(Collection).
static
<T extends Item>
List<T>
fromNameList(String list, Class<T> type)
          Deprecated. as of 1.406 Use fromNameList(ItemGroup, String, Class)
static
<T extends Item>
List<T>
getAllItems(ItemGroup root, Class<T> type)
          Gets all the Items recursively in the ItemGroup tree and filter them by the given type.
static String getCanonicalName(ItemGroup context, String path)
          Computes the canonical full name of a relative path in an ItemGroup context, handling relative positions ".." and "." as absolute path starting with "/".
static XmlFile getConfigFile(File dir)
          The file we save our configuration.
static XmlFile getConfigFile(Item item)
          The file we save our configuration.
static TopLevelItemDescriptor getDescriptor(String fqcn)
           
static Item load(ItemGroup parent, File dir)
          Loads a Item from a config file.
static String toNameList(Collection<? extends Item> items)
          Converts a list of items into a comma-separated list of full names.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIST

public static final List<TopLevelItemDescriptor> LIST
Deprecated. as of 1.286 Use all() for read access and Extension for registration.
List of all installed TopLevelItem types.


XSTREAM

public static final com.thoughtworks.xstream.XStream XSTREAM
Used to load/save job configuration. When you extend Job in a plugin, try to put the alias so that it produces a reasonable XML.


XSTREAM2

public static final XStream2 XSTREAM2
Alias to XSTREAM so that one can access additional methods on XStream2 more easily.

Constructor Detail

Items

public Items()
Method Detail

all

public static DescriptorExtensionList<TopLevelItem,TopLevelItemDescriptor> all()
Returns all the registered TopLevelItemDescriptors.


getDescriptor

public static TopLevelItemDescriptor getDescriptor(String fqcn)

toNameList

public static String toNameList(Collection<? extends Item> items)
Converts a list of items into a comma-separated list of full names.


fromNameList

public static <T extends Item> List<T> fromNameList(String list,
                                                    Class<T> type)
Deprecated. as of 1.406 Use fromNameList(ItemGroup, String, Class)


fromNameList

public static <T extends Item> List<T> fromNameList(ItemGroup context,
                                                    String list,
                                                    Class<T> type)
Does the opposite of toNameList(Collection).


getCanonicalName

public static String getCanonicalName(ItemGroup context,
                                      String path)
Computes the canonical full name of a relative path in an ItemGroup context, handling relative positions ".." and "." as absolute path starting with "/". The resulting name is the item fullName from Jenkins root.


computeRelativeNamesAfterRenaming

public static String computeRelativeNamesAfterRenaming(String oldFullName,
                                                       String newFullName,
                                                       String relativeNames,
                                                       ItemGroup context)
Compute the relative name of list of items after a rename occurred. Used to manage job references as names in plugins to support ItemListener.onRenamed(hudson.model.Item, String, String).

In a hierarchical context, when a plugin has a reference to a job as ../foo/bar this method will handle the relative path as "foo" is renamed to "zot" to compute ../zot/bar

Parameters:
oldFullName - the old full name of the item
newFullName - the new full name of the item
relativeNames - coma separated list of Item relative names
context - the {link ItemGroup} relative names refer to
Returns:
relative name for the renamed item, based on the same ItemGroup context

load

public static Item load(ItemGroup parent,
                        File dir)
                 throws IOException
Loads a Item from a config file.

Parameters:
dir - The directory that contains the config file, not the config file itself.
Throws:
IOException

getConfigFile

public static XmlFile getConfigFile(File dir)
The file we save our configuration.


getConfigFile

public static XmlFile getConfigFile(Item item)
The file we save our configuration.


getAllItems

public static <T extends Item> List<T> getAllItems(ItemGroup root,
                                                   Class<T> type)
Gets all the Items recursively in the ItemGroup tree and filter them by the given type.

Since:
1.512


Copyright © 2004-2013. All Rights Reserved.