public static Resource getResource(URI uri) throws IOException { return new VfsResource(VfsUtils.getRoot(uri)); } }
/** * Convert the given URL as returned from the ClassLoader into a {@link Resource}. * <p>The default implementation simply creates a {@link UrlResource} instance. * @param url a URL as returned from the ClassLoader * @return the corresponding Resource object * @see java.lang.ClassLoader#getResources * @see org.springframework.core.io.Resource */ protected Resource convertClassLoaderURL(URL url) { return new UrlResource(url); }
/** * Create a new InputSourceEditor, * using the default ResourceEditor underneath. */ public InputSourceEditor() { this.resourceEditor = new ResourceEditor(); }
/** * Open an {@code InputStream} for the specified resource, ignoring any specified * {@link #getCharset() Charset} or {@linkplain #getEncoding() encoding}. * @throws IOException if opening the InputStream failed * @see #requiresReader() * @see #getReader() */ @Override public InputStream getInputStream() throws IOException { return this.resource.getInputStream(); }
EncodedResource(Resource original, String coding, String extension) throws IOException { this.original = original; this.coding = coding; this.encoded = original.createRelative(original.getFilename() + extension); }
/** * Create a PropertySource based on Properties loaded from the given resource * location and use the given class loader to load the resource, assuming it is * prefixed with {@code classpath:}. The name of the PropertySource will be * generated based on the {@link Resource#getDescription() description} of the * resource. */ public ResourcePropertySource(String location, ClassLoader classLoader) throws IOException { this(new DefaultResourceLoader(classLoader).getResource(location)); }
/** * Create a new SimpleMetadataReaderFactory for the default class loader. */ public SimpleMetadataReaderFactory() { this.resourceLoader = new DefaultResourceLoader(); }
@Override public InputStream getInputStream() throws IOException { return inputStreamSource.getInputStream(); } @Override
/** * Return a Resource handle for the resource at the given path. * <p>The default implementation supports class path locations. This should * be appropriate for standalone implementations but can be overridden, * e.g. for implementations targeted at a Servlet container. * @param path the path to the resource * @return the corresponding Resource handle * @see ClassPathResource * @see org.springframework.context.support.FileSystemXmlApplicationContext#getResourceByPath * @see org.springframework.web.context.support.XmlWebApplicationContext#getResourceByPath */ protected Resource getResourceByPath(String path) { return new ClassPathContextResource(path, getClassLoader()); }
/** * Determine the File to use for timestamp checking. * <p>The default implementation delegates to {@link #getFile()}. * @return the File to use for timestamp checking (never {@code null}) * @throws FileNotFoundException if the resource cannot be resolved as * an absolute file path, i.e. is not available in a file system * @throws IOException in case of general resolution/reading failures */ protected File getFileForLastModifiedCheck() throws IOException { return getFile(); }
@Override public File getFile() throws IOException { File file = this.file; if (file != null) { return file; } file = super.getFile(); this.file = file; return file; }
/** * This implementation always returns {@code true} for a resource * that {@link #exists() exists} (revised as of 5.1). */ @Override public boolean isReadable() { return exists(); }
static boolean isReadable(Object vfsResource) { try { return (Long) invokeVfsMethod(VIRTUAL_FILE_METHOD_GET_SIZE, vfsResource) > 0; } catch (IOException ex) { return false; } }
/** * This implementation checks for the resolution of a resource URL. * @see java.lang.ClassLoader#getResource(String) * @see java.lang.Class#getResource(String) */ @Override public boolean exists() { return (resolveURL() != null); }
/** * Create a new embedded database builder with a {@link DefaultResourceLoader}. */ public EmbeddedDatabaseBuilder() { this(new DefaultResourceLoader()); }
/** * Create a new ReaderEditor, using the default ResourceEditor underneath. */ public ReaderEditor() { this.resourceEditor = new ResourceEditor(); }
public static Resource getResource(URL url) throws IOException { return new VfsResource(VfsUtils.getRoot(url)); }
/** * Create a new PathEditor, using the default ResourceEditor underneath. */ public PathEditor() { this.resourceEditor = new ResourceEditor(); }
/** * Create a new InputStreamEditor, using the default ResourceEditor underneath. */ public InputStreamEditor() { this.resourceEditor = new ResourceEditor(); }
/** * Create a new FileEditor, using a default ResourceEditor underneath. */ public FileEditor() { this.resourceEditor = new ResourceEditor(); }