Spring Framework ResourceEditor - 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 ResourceEditor class.

This code example shows how to use the following methods:getValue, setAsText
	} 
 
 
	@Override 
	public void setAsText(String text) throws IllegalArgumentException {
		this.resourceEditor.setAsText(text);
		Resource resource = (Resource) this.resourceEditor.getValue();
		try { 
			setValue(resource != null ? new InputSource(resource.getURL().toString()) : null);
		} 
		catch (IOException ex) {
			throw new IllegalArgumentException(
					"Could not retrieve URL for " + resource + ": " + ex.getMessage());
		} 
	} 
 
	@Override 
	public String getAsText() {
		InputSource value = (InputSource) getValue();
		return (value != null ? value.getSystemId() : "");
7
CodeRank
This code example shows how to use the following methods:getValue, setAsText
	} 
 
 
	@Override 
	public void setAsText(String text) throws IllegalArgumentException {
		this.resourceEditor.setAsText(text);
		Resource resource = (Resource) this.resourceEditor.getValue();
		try { 
			setValue(resource != null ? resource.getURL() : null);
		} 
		catch (IOException ex) {
			throw new IllegalArgumentException("Could not retrieve URL for " + resource + ": " + ex.getMessage());
		} 
	} 
 
	@Override 
	public String getAsText() {
		URL value = (URL) getValue();
		return (value != null ? value.toExternalForm() : "");
	} 
7
CodeRank
This code example shows how to use the following methods:getValue, setAsText
	} 
 
 
	@Override 
	public void setAsText(String text) throws IllegalArgumentException {
		this.resourceEditor.setAsText(text);
		Resource resource = (Resource) this.resourceEditor.getValue();
		try { 
			setValue(resource != null ? resource.getInputStream() : null);
		} 
		catch (IOException ex) {
			throw new IllegalArgumentException(
					"Could not retrieve InputStream for " + resource + ": " + ex.getMessage());
		} 
	} 
 
	/** 
	 * This implementation returns {@code null} to indicate that 
	 * there is no appropriate text representation. 
	 */ 
7
CodeRank
This code example shows how to use the following methods:
	 * @see org.springframework.beans.propertyeditors.ClassArrayEditor 
	 * @see org.springframework.core.io.support.ResourceArrayPropertyEditor 
	 */ 
	@Override 
	public void registerCustomEditors(PropertyEditorRegistry registry) {
		ResourceEditor baseEditor = new ResourceEditor(this.resourceLoader, this.propertyResolver);
		doRegisterEditor(registry, Resource.class, baseEditor);
		doRegisterEditor(registry, ContextResource.class, baseEditor);
		doRegisterEditor(registry, InputStream.class, new InputStreamEditor(baseEditor));
		doRegisterEditor(registry, InputSource.class, new InputSourceEditor(baseEditor));
		doRegisterEditor(registry, File.class, new FileEditor(baseEditor));
		doRegisterEditor(registry, URL.class, new URLEditor(baseEditor));
 
		ClassLoader classLoader = this.resourceLoader.getClassLoader();
		doRegisterEditor(registry, URI.class, new URIEditor(classLoader));
		doRegisterEditor(registry, Class.class, new ClassEditor(classLoader));
		doRegisterEditor(registry, Class[].class, new ClassArrayEditor(classLoader));
 
		if (this.resourceLoader instanceof ResourcePatternResolver) {
			doRegisterEditor(registry, Resource[].class,
5
CodeRank
This code example shows how to use the following methods:
	/** 
	 * Create a new FileEditor, 
	 * using the default ResourceEditor underneath. 
	 */ 
	public FileEditor() { 
		this.resourceEditor = new ResourceEditor();
	} 
 
	/** 
	 * Create a new FileEditor, 
	 * using the given ResourceEditor underneath. 
	 * @param resourceEditor the ResourceEditor to use 
	 */ 
	public FileEditor(ResourceEditor resourceEditor) {
		Assert.notNull(resourceEditor, "ResourceEditor must not be null");
		this.resourceEditor = resourceEditor;
	} 
 
 
	@Override 
6
CodeRank