org.anadix.factories
Class SourceFactory

java.lang.Object
  extended by org.anadix.factories.SourceFactory

public final class SourceFactory
extends Object

Creates instances of Source for different types of sources

Version:
$Id: $
Author:
tomason

Method Summary
static Source newClassPathSource(String resource)
          Creates a new Source from a classpath resource.
static Source newClassPathSource(String resource, boolean cache)
          Creates a new Source from a classpath resource.
static Source newFileSource(File file)
          Creates a new source pointing at a file
static Source newFileSource(File file, boolean cache)
          Creates a new source pointing at a file
static Source newFileSource(String filename)
          Creates a new source pointing at a file
static Source newFileSource(String filename, boolean cache)
          Creates a new source pointing at a file
static Source newStringSource(String source)
          Creates a new source from a String
static Source newStringSource(String source, String description)
          Creates a new source from a String
static Source newURLSource(URL url)
          Creates a new Source from an URL resource.
static Source newURLSource(URL url, boolean cache)
          Creates a new Source from an URL resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newFileSource

public static Source newFileSource(File file)
                            throws SourceException
Creates a new source pointing at a file

Parameters:
file - - file to read a source from
Returns:
instance of Source
Throws:
SourceException - - if any error occurs during creation of new Source

newFileSource

public static Source newFileSource(File file,
                                   boolean cache)
                            throws SourceException
Creates a new source pointing at a file

Parameters:
file - - file to read a source from
cache - - whether to cache the result in memory
Returns:
instance of Source
Throws:
SourceException - - if any error occurs during creation of new Source

newFileSource

public static Source newFileSource(String filename)
                            throws SourceException
Creates a new source pointing at a file

Parameters:
filename - - path to file to read a source from
Returns:
instance of Source
Throws:
SourceException - - if any error occurs during creation of new Source

newFileSource

public static Source newFileSource(String filename,
                                   boolean cache)
                            throws SourceException
Creates a new source pointing at a file

Parameters:
filename - - path to file to read a source from
cache - - whether to cache the result in memory
Returns:
instance of Source
Throws:
SourceException - - if any error occurs during creation of new Source

newStringSource

public static Source newStringSource(String source)
Creates a new source from a String

Parameters:
source - - String containing the actual source
Returns:
instance of Source

newStringSource

public static Source newStringSource(String source,
                                     String description)
Creates a new source from a String

Parameters:
source - - String containing the actual source
description - - descripton of the Source
Returns:
instance of Source

newClassPathSource

public static Source newClassPathSource(String resource)
                                 throws SourceException
Creates a new Source from a classpath resource. The resource must be on classpath and reachable by default classloader!

Parameters:
resource - - path to the resource
Returns:
instance of Source
Throws:
SourceException - - if any error occurs during creation of new Source

newClassPathSource

public static Source newClassPathSource(String resource,
                                        boolean cache)
                                 throws SourceException
Creates a new Source from a classpath resource. The resource must be on classpath and reachable by default classloader!

Parameters:
resource - - path to the resource
cache - - whether to cache the result in memory
Returns:
instance of Source
Throws:
SourceException - - if any error occurs during creation of new Source

newURLSource

public static Source newURLSource(URL url)
                           throws SourceException
Creates a new Source from an URL resource. The URL must exist and be valid!

Parameters:
url - - URL to get resource from
Returns:
instance of Source
Throws:
SourceException - - if any error occurs during creation of new Source

newURLSource

public static Source newURLSource(URL url,
                                  boolean cache)
                           throws SourceException
Creates a new Source from an URL resource. The URL must exist and be valid!

Parameters:
url - - URL to get resource from
cache - - whether to cache the result in memory
Returns:
instance of Source
Throws:
SourceException - - if any error occurs during creation of new Source


Copyright © 2011. All Rights Reserved.