Package org.soulwing.jdbc.source
Class ResourceSQLSource
- java.lang.Object
-
- org.soulwing.jdbc.source.ReaderSQLSource
-
- org.soulwing.jdbc.source.ResourceSQLSource
-
- All Implemented Interfaces:
Closeable,AutoCloseable,SQLSource
public class ResourceSQLSource extends ReaderSQLSource
AnSQLSourcethat reads SQL statements from a resource that can be located using a URL.- Author:
- Carl Harris
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceResourceSQLSource.ResourceAccessorAn accessor for a resource.
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_ENCODING
-
Constructor Summary
Constructors Constructor Description ResourceSQLSource(URL location, String encoding)Constructs a new SQL source for a resource at the specified location, which uses the specified encoding.ResourceSQLSource(URL location, String encoding, Scanner scanner)Constructs a new SQL source for a resource at the specified location, which uses the specified encoding.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ResourceSQLSourcewith(String location)Creates a new SQL source for a resource relative to the root of the classpath, which uses thedefault encoding.static ResourceSQLSourcewith(String name, Class<?> relativeToClass)Creates a new SQL source for a resource in the same package as the given class, which uses thedefault encoding.static ResourceSQLSourcewith(String name, Class<?> relativeToClass, String encoding)Creates a new SQL source for a resource in the same package as the given class which uses the specified encoding.static ResourceSQLSourcewith(String name, Class<?> relativeToClass, String encoding, Scanner scanner)Creates a new SQL source for a resource in the same package as the given class which uses the specified encoding.static ResourceSQLSourcewith(String name, Class<?> relativeToClass, Scanner scanner)Creates a new SQL source for a resource in the same package as the given class, which uses thedefault encoding.static ResourceSQLSourcewith(String name, ClassLoader classLoader)Creates a new SQL source for a resource relative to the root of the given class loader, which uses thedefault encoding.static ResourceSQLSourcewith(String name, ClassLoader classLoader, String encoding)Creates a new SQL source for a resource relative to the root of the given class loader, which uses the specified encoding.static ResourceSQLSourcewith(String name, ClassLoader classLoader, String encoding, Scanner scanner)Creates a new SQL source for a resource relative to the root of the given class loader, which uses the specified encoding.static ResourceSQLSourcewith(String name, ClassLoader classLoader, Scanner scanner)Creates a new SQL source for a resource relative to the root of the given class loader, which uses thedefault encoding.static ResourceSQLSourcewith(String location, String encoding)Creates a new SQL source for a resource relative to the root of the classpath, which uses the specified encoding.static ResourceSQLSourcewith(String location, String encoding, Scanner scanner)Creates a new SQL source for a resource relative to the root of the classpath, which uses the specified encoding.static ResourceSQLSourcewith(String name, ResourceSQLSource.ResourceAccessor accessor)Creates a new SQL source for a resource that will be obtained from the given resource accessor and which uses thedefault encoding.static ResourceSQLSourcewith(String name, ResourceSQLSource.ResourceAccessor accessor, String encoding)Creates a new SQL source for a resource that will be obtained from the given resource accessor and which uses the specified encoding.static ResourceSQLSourcewith(String name, ResourceSQLSource.ResourceAccessor accessor, String encoding, Scanner scanner)Creates a new SQL source for a resource that will be obtained from the given resource accessor and which uses the specified encoding.static ResourceSQLSourcewith(String name, ResourceSQLSource.ResourceAccessor accessor, Scanner scanner)Creates a new SQL source for a resource that will be obtained from the given resource accessor and which uses thedefault encoding.static ResourceSQLSourcewith(String location, Scanner scanner)Creates a new SQL source for a resource relative to the root of the classpath, which uses thedefault encoding.static ResourceSQLSourcewith(URI location)Creates a new SQL source for a resource at the specified location, which uses the specified encoding.static ResourceSQLSourcewith(URI location, String encoding)Creates a new SQL source for a resource at the specified location, which uses the specified encoding.static ResourceSQLSourcewith(URI location, String encoding, Scanner scanner)Creates a new SQL source for a resource at the specified location, which uses the specified encoding.static ResourceSQLSourcewith(URI location, Scanner scanner)Creates a new SQL source for a resource at the specified location, which uses the specified encoding.static ResourceSQLSourcewith(URL location)Creates a new SQL source for a resource at the specified location, which uses the specified encoding.static ResourceSQLSourcewith(URL location, String encoding)Creates a new SQL source for a resource at the specified location, which uses the specified encoding.static ResourceSQLSourcewith(URL location, String encoding, Scanner scanner)Creates a new SQL source for a resource at the specified location, which uses the specified encoding.static ResourceSQLSourcewith(URL location, Scanner scanner)Creates a new SQL source for a resource at the specified location, which uses the specified encoding.-
Methods inherited from class org.soulwing.jdbc.source.ReaderSQLSource
close, next
-
-
-
-
Field Detail
-
DEFAULT_ENCODING
public static final String DEFAULT_ENCODING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ResourceSQLSource
public ResourceSQLSource(URL location, String encoding)
Constructs a new SQL source for a resource at the specified location, which uses the specified encoding.- Parameters:
location- location of the resource; this URL may use theclasspath:scheme to specify a resource relative to the root of the classpath which will be accessing using the thread context class loaderencoding- character set name- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
ResourceSQLSource
public ResourceSQLSource(URL location, String encoding, Scanner scanner)
Constructs a new SQL source for a resource at the specified location, which uses the specified encoding.- Parameters:
location- location of the resource; this URL may use theclasspath:scheme to specify a resource relative to the root of the classpath which will be accessing using the thread context class loaderencoding- character set namescanner- scanner to use for SQL dialect- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
-
Method Detail
-
with
public static ResourceSQLSource with(String name, Class<?> relativeToClass)
Creates a new SQL source for a resource in the same package as the given class, which uses thedefault encoding.- Parameters:
name- name of the resourcerelativeToClass- class that provides the package location of the resource- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String name, Class<?> relativeToClass, Scanner scanner)
Creates a new SQL source for a resource in the same package as the given class, which uses thedefault encoding.- Parameters:
name- name of the resourcerelativeToClass- class that provides the package location of the resourcescanner- scanner to use for SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String name, Class<?> relativeToClass, String encoding)
Creates a new SQL source for a resource in the same package as the given class which uses the specified encoding.- Parameters:
name- name of the resourcerelativeToClass- class that provides the package location of the resourceencoding- character set name- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String name, Class<?> relativeToClass, String encoding, Scanner scanner)
Creates a new SQL source for a resource in the same package as the given class which uses the specified encoding.- Parameters:
name- name of the resourcerelativeToClass- class that provides the package location of the resourceencoding- character set namescanner- scanner to use for the SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String name, ClassLoader classLoader)
Creates a new SQL source for a resource relative to the root of the given class loader, which uses thedefault encoding.- Parameters:
name- name of the resourceclassLoader- class loader that will be used to access the resource- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String name, ClassLoader classLoader, Scanner scanner)
Creates a new SQL source for a resource relative to the root of the given class loader, which uses thedefault encoding.- Parameters:
name- name of the resourceclassLoader- class loader that will be used to access the resourcescanner- scanner to use for the SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String name, ClassLoader classLoader, String encoding)
Creates a new SQL source for a resource relative to the root of the given class loader, which uses the specified encoding.- Parameters:
name- name of the resourceclassLoader- class loader that will be used to access the resourceencoding- character set name- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String name, ClassLoader classLoader, String encoding, Scanner scanner)
Creates a new SQL source for a resource relative to the root of the given class loader, which uses the specified encoding.- Parameters:
name- name of the resourceclassLoader- class loader that will be used to access the resourceencoding- character set namescanner- scanner to use for the SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String name, ResourceSQLSource.ResourceAccessor accessor, Scanner scanner)
Creates a new SQL source for a resource that will be obtained from the given resource accessor and which uses thedefault encoding.- Parameters:
name- name of the resourceaccessor- accessor that will be used to obtain a URL for the resourcescanner- scanner to use for the SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String name, ResourceSQLSource.ResourceAccessor accessor)
Creates a new SQL source for a resource that will be obtained from the given resource accessor and which uses thedefault encoding.- Parameters:
name- name of the resourceaccessor- accessor that will be used to obtain a URL for the resource- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String name, ResourceSQLSource.ResourceAccessor accessor, String encoding)
Creates a new SQL source for a resource that will be obtained from the given resource accessor and which uses the specified encoding.- Parameters:
name- name of the resourceaccessor- accessor that will be used to obtain a URL for the resourceencoding- character set name- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String name, ResourceSQLSource.ResourceAccessor accessor, String encoding, Scanner scanner)
Creates a new SQL source for a resource that will be obtained from the given resource accessor and which uses the specified encoding.- Parameters:
name- name of the resourceaccessor- accessor that will be used to obtain a URL for the resourceencoding- character set namescanner- scanner to use for SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String location)
Creates a new SQL source for a resource relative to the root of the classpath, which uses thedefault encoding.The resource will be located using the thread context class loader.
- Parameters:
location- URL for the resource; may use theclasspath:scheme to specify a resource relative to the root of the classpath (which will be accessed using the thread context class loader)- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String location, Scanner scanner)
Creates a new SQL source for a resource relative to the root of the classpath, which uses thedefault encoding.The resource will be located using the thread context class loader.
- Parameters:
location- URL for the resource; may use theclasspath:scheme to specify a resource relative to the root of the classpath (which will be accessed using the thread context class loader)scanner- scanner to use for SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String location, String encoding)
Creates a new SQL source for a resource relative to the root of the classpath, which uses the specified encoding.The resource will be located using the thread context class loader.
- Parameters:
location- URL for the resource; may use theclasspath:scheme to specify a resource relative to the root of the classpath (which will be accessed using the thread context class loader)encoding- character set name- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(String location, String encoding, Scanner scanner)
Creates a new SQL source for a resource relative to the root of the classpath, which uses the specified encoding.The resource will be located using the thread context class loader.
- Parameters:
location- URL for the resource; may use theclasspath:scheme to specify a resource relative to the root of the classpath (which will be accessed using the thread context class loader)encoding- character set namescanner- scanner to use for SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(URI location)
Creates a new SQL source for a resource at the specified location, which uses the specified encoding.- Parameters:
location- location of the resource; this URL may use theclasspath:scheme to specify a resource relative to the root of the classpath (which will be accessed using the thread context class loader)- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(URI location, Scanner scanner)
Creates a new SQL source for a resource at the specified location, which uses the specified encoding.- Parameters:
location- location of the resource; this URL may use theclasspath:scheme to specify a resource relative to the root of the classpath (which will be accessed using the thread context class loader)scanner- scanner to use for SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(URI location, String encoding)
Creates a new SQL source for a resource at the specified location, which uses the specified encoding.- Parameters:
location- location of the resource; this URL may use theclasspath:scheme to specify a resource relative to the root of the classpath (which will be accessed using the thread context class loader)encoding- character set name- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(URI location, String encoding, Scanner scanner)
Creates a new SQL source for a resource at the specified location, which uses the specified encoding.- Parameters:
location- location of the resource; this URL may use theclasspath:scheme to specify a resource relative to the root of the classpath (which will be accessed using the thread context class loader)encoding- character set namescanner- scanner to use for SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(URL location)
Creates a new SQL source for a resource at the specified location, which uses the specified encoding.- Parameters:
location- location of the resource; this URL may use theclasspath:scheme to specify a resource relative to the root of the classpath which will be accessing using the thread context class loader- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(URL location, Scanner scanner)
Creates a new SQL source for a resource at the specified location, which uses the specified encoding.- Parameters:
location- location of the resource; this URL may use theclasspath:scheme to specify a resource relative to the root of the classpath which will be accessing using the thread context class loaderscanner- scanner to use for SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(URL location, String encoding)
Creates a new SQL source for a resource at the specified location, which uses the specified encoding.- Parameters:
location- location of the resource; this URL may use theclasspath:scheme to specify a resource relative to the root of the classpath which will be accessing using the thread context class loaderencoding- character set name- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
with
public static ResourceSQLSource with(URL location, String encoding, Scanner scanner)
Creates a new SQL source for a resource at the specified location, which uses the specified encoding.- Parameters:
location- location of the resource; this URL may use theclasspath:scheme to specify a resource relative to the root of the classpath which will be accessing using the thread context class loaderencoding- character set namescanner- scanner to use for SQL dialect- Returns:
- SQL source
- Throws:
SQLResourceNotFoundException- if the specified resource is not foundSQLInputException- if an I/O errors when accessing the resource
-
-