public final class ClasspathSqlLocator extends Object
.sql files on the classpath. Given a class and
method name, for example com.foo.Bar#query, load a
classpath resource name like com/foo/Bar/query.sql.
The contents are then parsed, cached, and returned for use by a statement.| Modifier and Type | Method and Description |
|---|---|
static String |
findSqlOnClasspath(Class<?> type,
String name)
Locates SQL for the given type and name.
|
static String |
findSqlOnClasspath(String name)
Locates SQL for the given fully-qualified name.
|
static String |
getResourceOnClasspath(ClassLoader classLoader,
String path)
Returns resource's contents as a string at the specified path by the specified classloader.
|
static String |
getResourceOnClasspath(String path)
Returns resource's contents as a string at the specified path.
|
public static String findSqlOnClasspath(Class<?> type, String name)
com.foo.Bar and a name of
baz, looks for a resource named com/foo/Bar/baz.sql on the classpath and returns its
contents as a String.type - the type that "owns" the given SQL. Dictates the directory path to the SQL resource file on the
classpath.name - the SQL statement name (usually a method or field name from the type).public static String findSqlOnClasspath(String name)
com.foo.Bar.baz, looks for
a resource named com/foo/Bar/baz.sql on the classpath and returns its contents as a String.name - fully qualified name.public static String getResourceOnClasspath(ClassLoader classLoader, String path)
classLoader - the classloader which loads the resourcepath - the resource pathClassLoader.getResource(String)public static String getResourceOnClasspath(String path)
path - the resource pathClassLoader.getResource(String)Copyright © 2017. All rights reserved.