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

This code example shows how to use the following methods:
 
    public InMemoryResource(byte[] source) {
        this(source, null);
    } 
 
    public InMemoryResource(byte[] source, String description) {
        Assert.notNull(source);
        this.source = source;
        this.description = description;
    } 
 
    //~ Methods ======================================================================================================== 
 
    public String getDescription() {
        return description;
    } 
 
    public InputStream getInputStream() throws IOException {
        return new ByteArrayInputStream(source);
    } 
5
CodeRank
This code example shows how to use the following methods:
     */ 
    public GeneratedResource()  { 
        this(new byte[]{}, null); 
    } 
 
    public GeneratedResource(byte[] source, String description) {
        Assert.notNull(source);
        this.source = source;
        this.description = description;
        timeGenerated = System.currentTimeMillis();
    } 
     
    @Override 
    public String getFilename() {
        return getDescription(); 
    } 
     
    @Override 
	public long lastModified() throws IOException {
        return timeGenerated;
5
CodeRank
This code example shows how to use the following methods:
    public CachedResource(String source, String encoding) throws UnsupportedEncodingException
    { 
        this(source.trim().getBytes(encoding), DEFAULT_DESCRIPTION);
    } 
 
    public CachedResource(byte[] source, String description)
    { 
        this.buffer = source;
        this.description = description;
    } 
 
    public CachedResource(Reader reader, String encoding) throws IOException
    { 
        this(IOUtils.toByteArray(reader, encoding), DEFAULT_DESCRIPTION);
    } 
 
    public String getDescription()
    { 
        return (description == null) ? "" : description;
    } 
5
CodeRank
This code example shows how to use the following methods:
 
    public StringResource(String text) {
        this(text, DEFAULT_ENCODING);
    } 
 
    public StringResource(String text, String encoding) {
        this.text = text;
        this.encoding = encoding;
    } 
 
    public boolean exists() { 
        return true; 
    } 
 
    public String getFilename() throws IllegalStateException {
        return ""; 
    } 
 
    public String getDescription() {
        return text;
5
CodeRank
This code example shows how to use the following methods:
 
	private IProject project;
	 
	private ZipEntryStorage storage;
 
	public StorageResource(ZipEntryStorage storage, IProject project) {
		this.storage = storage;
	} 
 
	@Override 
	public boolean exists() { 
		return (storage != null);
	} 
 
	public InputStream getInputStream() throws IOException {
		if (storage == null) {
			throw new FileNotFoundException("Storage not available");
		} 
		try { 
			return storage.getContents();
5
CodeRank
This code example shows how to use the following methods:
     * @param representation 
     *            The description. 
     * @param description 
     *            The description. 
     */ 
    public SpringResource(Representation representation, String description) { 
        if (representation == null) { 
            throw new IllegalArgumentException( 
                    "Representation must not be null"); 
        } 
 
        this.representation = representation; 
        this.description = (description != null) ? description : ""; 
    } 
 
    /** 
     * This implementation compares the underlying InputStream. 
     */ 
    @Override 
    public boolean equals(Object obj) { 
5
CodeRank
This code example shows how to use the following methods:
 
    public ResourceAdapter(String location, com.alibaba.citrus.service.resource.Resource resource) {
        this(location, resource, null);
    } 
 
    public ResourceAdapter(String location, com.alibaba.citrus.service.resource.Resource resource,
                           ResourceLoadingSupport loader) {
        this.loader = loader;
        this.location = location;
        this.resource = resource;
        this.description = "Resource[" + location + ", loaded by ResourceLoadingService]";
    } 
 
    public com.alibaba.citrus.service.resource.Resource getResource() { 
        return resource;
    } 
 
    public String getDescription() {
        return description;
    } 
5
CodeRank
This code example shows how to use the following methods:
        catch (IllegalArgumentException ex) {
            // expected 
        } 
    } 
 
    private static class NonExistentResource extends AbstractResource {
 
        @Override 
        public Resource createRelative(String relativePath) throws IOException {
            throw new IOException();
        } 
 
        @Override 
        public boolean exists() { 
            return false; 
        } 
 
        @Override 
        public String getDescription() {
            return null; 
4
CodeRank
This code example shows how to use the following methods:
    private static class NonExistResource extends AbstractResource implements ContextResource {
        private final String      location;
        private final IOException ioe;
        private final String      description;
 
        public NonExistResource(String location, ResourceNotFoundException e) {
            this.location = location;
            this.ioe = new IOException("Resource Not Found [" + location + "]");
            this.ioe.initCause(e);
            this.description = "NonExistResource[" + location + "]";
        } 
 
        public String getPathWithinContext() {
            return location;
        } 
 
        public String getDescription() {
            return description;
        } 
 
4
CodeRank
This code example shows how to use the following methods:
     * @param resource 
     *            The wrapped resource. 
     * @throws IllegalArgumentException, 
     *             if the resource is invalid. 
     */ 
    public AwtImageResource(Resource resource) {
        Assert.notNull(resource);
        if (resource instanceof AwtImageResource) {
            throw new IllegalArgumentException("Wrapping another AwtImageResource instance is illegal.");
        } 
        this.wrappedResource = resource;
    } 
 
    public String getDescription() {
        return wrappedResource.getDescription();
    } 
 
    public Resource createRelative(String relativePath) throws IOException {
        return wrappedResource.createRelative(relativePath);
    } 
4
CodeRank