package de.dtele.data {
import mx.utils.ObjectProxy;
import mx.utils.URLUtil;
/**
* An implementation of the IResource interface, represents resource objects
*
* @author Mathias Brodala
*/
public class Resource implements IResource {
private var _source:ISource;
/**
* The source of this resource
*/
public function get source():ISource { return this._source; }
private var _url:String;
/**
* The URL of this resource
*/
public function get url():String { return this._url; }
private var _fullUrl:String;
/**
* The full URL of this resource, including source URL if necessary
*/
public function get fullUrl():String { return this._fullUrl; }
private var _properties:ObjectProxy = new ObjectProxy({
title: null,
thumbnail: null
});
/**
* Properties of this resource
*/
[Bindable]public function get properties():ObjectProxy { return this._properties; }
protected function set properties(properties:ObjectProxy):void { this._properties = properties; }
public function Resource(source:ISource, url:String, info:Object=null) {
this._source = source;
this._url = url;
this._fullUrl = URLUtil.getFullURL(source.url, url);
if (info) {
for (var property:String in info) {
this.properties[property] = info[property];
}
if (!this.properties.title) {
this.properties.title = this.url.split("/").pop(); }
}
}
}
}