org.fuin.units4j.dependency
Class Utils

java.lang.Object
  extended by org.fuin.units4j.dependency.Utils

public final class Utils
extends java.lang.Object

Utilities for the package.


Method Summary
static com.thoughtworks.xstream.XStream createXStream()
          Creates a ready configured XStream instance.
static DependsOn findByName(java.util.List<DependsOn> allowed, java.lang.String pkgName)
          Find a dependency in a list by a package name.
static NotDependsOn findByName(java.util.List<NotDependsOn> forbidden, java.lang.String pkgName)
          Find a dependency in a list by a package name.
static Dependencies load(java.lang.Class<?> clasz, java.lang.String resourcePathAndName)
          Load dependencies from a resource.
static Dependencies load(java.io.File file)
          Load dependencies from a file.
static Dependencies load(java.io.InputStream inputStream)
          Load dependencies from an input stream.
static void save(java.io.File file, Dependencies dependencies)
          Write the dependencies to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createXStream

public static com.thoughtworks.xstream.XStream createXStream()
Creates a ready configured XStream instance.

Returns:
New XStream instance.

load

public static Dependencies load(java.io.File file)
Load dependencies from a file.

Parameters:
file - XML File to load - Cannot be null and must be a valid file.
Returns:
New dependencies instance.

load

public static Dependencies load(java.io.InputStream inputStream)
Load dependencies from an input stream.

Parameters:
inputStream - XML input stream to read - Cannot be null.
Returns:
New dependencies instance.

load

public static Dependencies load(java.lang.Class<?> clasz,
                                java.lang.String resourcePathAndName)
Load dependencies from a resource.

Parameters:
clasz - Class to use for loading the resource - Cannot be null.
resourcePathAndName - Name and path of the XML file (in the class path) - Cannot be null.
Returns:
New dependencies instance.

save

public static void save(java.io.File file,
                        Dependencies dependencies)
Write the dependencies to a file.

Parameters:
file - XML File - Cannot be null and must be a valid file.
dependencies - Dependencies to save.

findByName

public static DependsOn findByName(java.util.List<DependsOn> allowed,
                                   java.lang.String pkgName)
Find a dependency in a list by a package name.

Parameters:
allowed - List to search - Cannot be null.
pkgName - Name of the package to find - Cannot be null.
Returns:
Entry or null if nothing was found.

findByName

public static NotDependsOn findByName(java.util.List<NotDependsOn> forbidden,
                                      java.lang.String pkgName)
Find a dependency in a list by a package name.

Parameters:
forbidden - List to search - Cannot be null.
pkgName - Name of the package to find - Cannot be null.
Returns:
Entry or null if nothing was found.


Copyright © 2010 Future Invent Informationsmanagement GmbH. All Rights Reserved.