]>
git.argeo.org Git - gpl/argeo-slc.git/blob - ResourceSpecAttribute.java
572665dd52211b195200404518d9340988974346
1 package org
.argeo
.slc
.core
.execution
;
3 import java
.io
.IOException
;
5 import org
.argeo
.slc
.SlcException
;
6 import org
.springframework
.core
.io
.Resource
;
8 // TODO: offer the ability to read the resource
9 public class ResourceSpecAttribute
extends AbstractSpecAttribute
{
10 public final static String TYPE_PATH
= "path";
11 public final static String TYPE_URL
= "url";
12 public final static String TYPE_STREAM
= "stream";
14 private Resource resource
;
15 private String type
= TYPE_PATH
;
17 public Object
getValue() {
18 return convertResource(resource
);
21 public void setResource(Resource resource
) {
22 this.resource
= resource
;
25 public Object
convertResource(Resource resource
) {
27 if (TYPE_PATH
.equals(type
))
28 return resource
.getFile().getCanonicalPath();
29 else if (TYPE_URL
.equals(type
))
30 return resource
.getURL().toString();
31 else if (TYPE_STREAM
.equals(type
))
32 return resource
.getInputStream();
34 throw new SlcException("Unkown type " + type
);
35 } catch (IOException e
) {
36 throw new SlcException("Cannot convert resource " + resource
, e
);
40 public void setType(String type
) {
44 public String
getType() {