net.dpml.transit.link
Class Link

java.lang.Object
  extended by net.dpml.transit.link.Link

public class Link
extends Object

The Link class is a data structure that holds the target uri of a link. It is not intended that the applications instantiates this class directly, but obtains it as a object from the URL.getContent() method. Example;


      URL url = new URL( "link:jar:some/opague/pointer" );
      Class[] type = new Class[] { Link.class };

      // Get the Link object from the URL
      Link link = (Link) url.getContent( type );

      // Get the URI that this link is pointing to at the moment
      URI uri = link.getTargetURI();

      // Change the link to point somewhere else.
      URI newUri = new URI( "artifact:jar:abc/def/hoopla#3.1.2" );
      link.setTargetURI( newUri );
  

Version:
1.1.0
Author:
Digital Product Meta Library

Constructor Summary
Link(URI uri, LinkManager manager)
          Constructor for the Link.
 
Method Summary
 URI getLinkURI()
          Return the link uri.
 URI getTargetURI(URI defaultUri)
          Return the URI that is currently bound to the Link.
 void setTargetURI(URI uri)
          Sets (and permanently remembers) the Link to point to a new URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Link

public Link(URI uri,
            LinkManager manager)
     throws NullArgumentException
Constructor for the Link.

Parameters:
uri - the link physical uri
manager - the link manager
Throws:
NullArgumentException - if the link uri or manager is null
Method Detail

getLinkURI

public URI getLinkURI()
Return the link uri.

Returns:
the link uri value

getTargetURI

public URI getTargetURI(URI defaultUri)
                 throws IOException
Return the URI that is currently bound to the Link.

Parameters:
defaultUri - the default value
Returns:
the current URI the link: is pointing to.
Throws:
IOException - if an IO error occurs

setTargetURI

public void setTargetURI(URI uri)
                  throws IOException
Sets (and permanently remembers) the Link to point to a new URI.

Parameters:
uri - the URI that this link: should be pointing to.
Throws:
IOException - if an IO error occurs