Spring Framework EncodedResource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework EncodedResource class.

This code example shows how to use the following methods:getEncoding, getResource
	 * or {@link org.springframework.jdbc.datasource.init.ResourceDatabasePopulator}. 
	 */ 
	@Deprecated 
	public static void executeSqlScript(JdbcTemplate jdbcTemplate, Resource resource, boolean continueOnError) 
			throws DataAccessException { 
		executeSqlScript(jdbcTemplate, new EncodedResource(resource), continueOnError); 
	} 
 
	/** 
	 * Execute the given SQL script. 
	 * <p>The script will typically be loaded from the classpath. There should 
	 * be one statement per line. Any semicolons and line comments will be removed. 
	 * <p><b>Do not use this method to execute DDL if you expect rollback.</b> 
	 * @param jdbcTemplate the JdbcTemplate with which to perform JDBC operations 
	 * @param resource the resource (potentially associated with a specific encoding) 
	 * to load the SQL script from 
	 * @param continueOnError whether or not to continue without throwing an 
	 * exception in the event of an error 
	 * @throws DataAccessException if there is an error executing a statement 
	 * and {@code continueOnError} is {@code false} 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
		assertTrue("test with '\\n' is wrong", !containsSqlScriptDelimiters("select 1; select '\\n\n';", "\n"));
		assertTrue("test with delimiter \\n is wrong", containsSqlScriptDelimiters("select 1\n select 2", "\n"));
	} 
 
	private String readScript(String path) throws Exception {
		EncodedResource resource = new EncodedResource(new ClassPathResource(path, getClass()));
		return ScriptUtils.readScript(resource);
	} 
 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getResource
	/** 
	 * Return the {@link org.springframework.core.io.Resource} to load the 
	 * script from. 
	 */ 
	public final Resource getResource() {
		return this.resource.getResource();
	} 
 
	/** 
	 * Set the encoding used for reading the script resource. 
	 * <p>The default value for regular Resources is "UTF-8". 
	 * A {@code null} value implies the platform default. 
	 */ 
	public void setEncoding(String encoding) {
		this.resource = new EncodedResource(this.resource.getResource(), encoding);
	} 
 
 
	@Override 
	public String getScriptAsString() throws IOException {
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	 
	private Reader getResourceReader(Resource resource) throws IOException {
		if (resource instanceof EncodedResource) {
			return ((EncodedResource) resource).getReader();
		} else { 
			return new EncodedResource(resource).getReader();
		} 
	} 
	 
	private String getTemplateName(Resource resource) {
		return resource.getFilename();
	} 
	 
	private org.antlr.stringtemplate.StringTemplate loadTemplate(String name, BufferedReader reader) throws IOException {
		String line;
		String nl = System.getProperty("line.separator");
		StringBuffer buf = new StringBuffer(300);
		while ((line = reader.readLine()) != null) {
			buf.append(line);
			buf.append(nl);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getResource
     
    private int fastInfosetLoadBeanDefinitions(EncodedResource encodedResource)
        throws IOException, StaleFastinfosetException, 
        ParserConfigurationException, XMLStreamException {
         
        URL resUrl = encodedResource.getResource().getURL();
        // There are XML files scampering around that don't end in .xml. 
        // We don't apply the optimization to them. 
        if (!resUrl.getPath().endsWith(".xml")) {
            throw new StaleFastinfosetException(); 
        } 
        String fixmlPath = resUrl.getPath().replaceFirst("\\.xml$", ".fixml");
        String protocol = resUrl.getProtocol();
        // beware of the relative URL rules for jar:, which are surprising. 
        if ("jar".equals(protocol)) {
            fixmlPath = fixmlPath.replaceFirst("^.*!", "");
        } 
         
        URL fixmlUrl = new URL(resUrl, fixmlPath);
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Spring Framework EncodedResource Methods: