base.template.Resource Maven / Gradle / Ivy
package base.template;
import base.QueryResult;
import base.json.Json;
/**
* A resource associated with a template. Examples of resources include
* images, css files, javascript, HTML, email templates, etc...
*
* @see Template
* @see TemplateManager
*/
public class Resource implements Comparable, QueryResult {
private String name;
private byte[] data;
private boolean binary;
public Resource(String name, byte[] data, boolean binary) {
this.name = name;
this.data = data;
this.binary = binary;
}
public String getName() {
return name;
}
public byte[] getData() {
return data;
}
public boolean isBinary() {
return binary;
}
@Override
public int compareTo(Resource other) {
return name.compareTo(other.getName());
}
public String toString() {
return toJson();
}
@Override
public String toJson() {
return "{" +
"\"name\":\"" + Json.escape(name) + "\"," +
"\"data.length\":" + data.length + "," +
"\"binary\":" + binary + "" +
"}";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy