net.refractions.udig.catalog
Class IGeoResource

java.lang.Object
  extended by net.refractions.udig.catalog.IGeoResource
All Implemented Interfaces:
IResolve

public abstract class IGeoResource
extends java.lang.Object
implements IResolve

Represents a handle to a spatial resource.

The resource is not guaranteed to exist, nor do we guarantee that we can connect with the resource. Some/All potions of this handle may be loaded as required. This resource handle may also be the result a metadata service query.

Implementing an IService

Implement the abstract methods and you are good to go.

Please consider implementing support for resolve( ImageDescriptor.class, null ) as it will allow your IGeoResource to show up with a unqiue representation in the catalog.

Since:
0.6
Author:
David Zwiers, Refractions Research

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.refractions.udig.catalog.IResolve
IResolve.Status
 
Constructor Summary
IGeoResource()
           
 
Method Summary
<T> boolean
canResolve(java.lang.Class<T> adaptee)
          Harded coded to capture the IGeoResource contract.
 void dispose(IProgressMonitor monitor)
          Disposes of any resources or listeners required.
 boolean equals(java.lang.Object arg0)
          This should represent the identifier
abstract  java.net.URL getIdentifier()
          The identifier of a IGeoResource is identified by parent().getIdentifer()#ResourceID
abstract  IGeoResourceInfo getInfo(IProgressMonitor monitor)
          Blocking operation to describe this service.
 int hashCode()
          This should represent the identified
 java.util.List<IResolve> members(IProgressMonitor monitor)
          List of children, or EMPTY_LIST for a leaf.
 IResolve parent(IProgressMonitor monitor)
          Returns parent for this GeoResource.
<T> T
resolve(java.lang.Class<T> adaptee, IProgressMonitor monitor)
          Blocking operation to resolve into the adaptee, if available.
abstract  IService service(IProgressMonitor monitor)
          Returns the IService for this GeoResource.
 java.lang.String toString()
          Indicate class and id.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.refractions.udig.catalog.IResolve
getMessage, getStatus
 

Constructor Detail

IGeoResource

public IGeoResource()
Method Detail

resolve

public <T> T resolve(java.lang.Class<T> adaptee,
                     IProgressMonitor monitor)
          throws java.io.IOException
Blocking operation to resolve into the adaptee, if available.

Required adaptions:

Example Use (no casting required!):


 IGeoResourceInfo info = resolve(IGeoResourceInfo.class);
 

Recommendated adaptions:

Specified by:
resolve in interface IResolve
Parameters:
adaptee -
monitor -
Returns:
instance of adaptee, or null if unavailable (IGeoResourceInfo and IService must be supported)
Throws:
java.io.IOException - if result was unavailable due to a technical problem
See Also:
IGeoResourceInfo, IService, IResolve.resolve(Class, IProgressMonitor)

canResolve

public <T> boolean canResolve(java.lang.Class<T> adaptee)
Harded coded to capture the IGeoResource contract.

That is we *must* resolve the following:

Required adaptions:

Recommendated adaptions:

Here is an implementation example (for something that can adapt to ImageDescriptor and FeatureSource):


 public <T> boolean canResolve( Class<T> adaptee ) {
     return adaptee != null
             && (adaptee.isAssignableFrom(ImageDescriptor.class)
                     || adaptee.isAssignableFrom(FeatureSource.class) || super.canResolve(adaptee));
 }
 

Specified by:
canResolve in interface IResolve
Returns:
true if a resolution for adaptee is avaialble
See Also:
IResolve.resolve(Class, IProgressMonitor);

getInfo

public abstract IGeoResourceInfo getInfo(IProgressMonitor monitor)
                                  throws java.io.IOException
Blocking operation to describe this service.

As an example this method is used by LabelDecorators to acquire title, and icon.

Returns:
IGeoResourceInfo resolve(IGeoResourceInfo.class,IProgressMonitor monitor);
Throws:
java.io.IOException
See Also:
resolve(Class, IProgressMonitor)

service

public abstract IService service(IProgressMonitor monitor)
                          throws java.io.IOException
Returns the IService for this GeoResource.

Method is useful in dealing with deeply nested GeoResource children (where parent may not always be an IService).

Returns:
IService for this GeoResource
Throws:
java.io.IOException
See Also:
resolve(Class, IProgressMonitor)

parent

public IResolve parent(IProgressMonitor monitor)
                throws java.io.IOException
Returns parent for this GeoResource.

Most implementations will use the following code example:


 public IService parent( IProgressMonitor monitor ) throws IOException {
     return service(monitor);
 }
 
This code example preserves backwords compatibility with uDig 1.0 via type narrowing IResolve to IService.

You will need to provide a different implementation when working with nested content (like database schema or wms layers).

Specified by:
parent in interface IResolve
Parameters:
monitor - used to provide feedback during parent lookup
Returns:
parent IResolve for this GeoResource
Throws:
java.io.IOException - in the event of a technical problem
See Also:
resolve(Class, IProgressMonitor)

members

public java.util.List<IResolve> members(IProgressMonitor monitor)
List of children, or EMPTY_LIST for a leaf.

The provided implementation indicates that this IGeoResource is a leaf.

Specified by:
members in interface IResolve
Parameters:
monitor - Monitor used to provide feedback during member lookup
Returns:
Collections.emptyList();
See Also:
net.refractions.udig.catalog.IResolve#members(org.eclipse.core.runtime.IProgressMonitor)

equals

public boolean equals(java.lang.Object arg0)
This should represent the identifier

Overrides:
equals in class java.lang.Object
Parameters:
arg0 -
Returns:
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
This should represent the identified

Overrides:
hashCode in class java.lang.Object
Returns:
See Also:
Object.hashCode()

toString

public java.lang.String toString()
Indicate class and id.

Overrides:
toString in class java.lang.Object
Returns:
string representing this IResolve

getIdentifier

public abstract java.net.URL getIdentifier()
The identifier of a IGeoResource is identified by parent().getIdentifer()#ResourceID

For example: A WMS (IService) with an id of http://www.something.com/wms?Service=WMS would have georesources with ids similar to: http://www.something.com/wms?Service=WMS#layer1

Specified by:
getIdentifier in interface IResolve
Returns:
ID for this IResolve, should not be null.
See Also:
IResolve.getIdentifier()

dispose

public void dispose(IProgressMonitor monitor)
Disposes of any resources or listeners required. Default implementation does nothing.

Specified by:
dispose in interface IResolve
Parameters:
monitor - monitor to show progress