logo

abstract class

sys::Resource

sys::Obj
  sys::Resource

Resource models an object in the Uri namespace. Resources can be both containers for other resources and a container for a Fan object.

Slots

add

virtual Resource add(Obj obj)

Create a child resource under this parent resource which wraps the specified object. Return the newly created resource.

basename

Str basename()

Convenience for uri.basename.

create

virtual Resource create()

Create this resource under the namespace. If there is a uri conflict, type conflict, or the resource is already mounted then throw an Err. Return this. The default implementation throws UnsupportedErr.

delete

virtual Void delete()

Delete this resource from the namespace. If this resource contains a child tree of resources, then recursively delete the entire tree. The default implementation throws UnsupportedErr.

exists

Bool exists()

Return if this resource exists in the namespace.

ext

Str ext()

Convenience for uri.ext.

isDir

Bool isDir()

Convenience for uri.isDir

list

virtual Resource[] list()

List the children resources contained by this resource. If this resource doesn't contain children, then return an empty list. Note this can potentially be an expensive operation. The default implementation returns an empty list.

make

new make(Uri uri)

Constructor for the specified Uri. Throw ArgErr if uri is null.

name

Str name()

Convenience for uri.name.

obj

virtual Obj obj

Get or set this resource's contents as a Fan object. This object is always a thread-safe copy of the object. Use the save method to save this object as the actual resource.

path

Str[] path()

Convenience for uri.path.

pathStr

Str pathStr()

Convenience for uri.pathStr.

refresh

virtual Void refresh()

Refresh this resource to reflect the current state of the contents. This method will typically overwrite the value of the obj field. The default implementation throws UnsupportedErr.

resolve

virtual Resource resolve(Uri uri, Int startDepth)

Resolve the Uri to its target as a thread safe working instance of the resource. Return null if it can't be resolved. The depth indicates the current path depth to be resolved. The default implementation returns null.

save

virtual Void save()

Save the thread-safe copy of obj back to the namespace. If between the last read and the update, another thread or application has modified the object then throw an Err. The default implementation throws UnsupportedErr.

TODO: throw VersionErr, might be a type likely to be caught

uri

Uri uri()

Return the Uri of this resource which identifies its within the local VM namespace.