nl.uva.vlet.vrs
Class VNode

java.lang.Object
  extended by nl.uva.vlet.vrs.VNode
Direct Known Subclasses:
Cluster, HTTPNode, ResourceNode, VCompositeNode, VFSNode

public abstract class VNode
extends java.lang.Object

The VNode class, the super class of all resource Nodes in the VRS package. It can be seen as a handler object, for example a reference to a (remote) file or directory.

See Also:
VFSNode, VFile, VDir

Field Summary
static java.lang.String ATTR_CHARSET
           
static java.lang.String ATTR_HOSTNAME
           
static java.lang.String ATTR_ICON
           
static java.lang.String ATTR_ISVLINK
           
static java.lang.String ATTR_LOCATION
           
static java.lang.String ATTR_MIMETYPE
          VAttribute name for the MimeType
static java.lang.String ATTR_NAME
           
static java.lang.String ATTR_PATH
           
static java.lang.String ATTR_PORT
           
static java.lang.String ATTR_SCHEME
           
static java.lang.String ATTR_TYPE
           
protected  VRL location
          The URI Compatable VRL or which specified the resource location
protected  VRSContext vrsContext
          The *NEW* VRSContext to ensure shared environments ! Is FINAL, once set it may never be changed.
 
Constructor Summary
VNode(VRSContext context, VRL vrl)
          Universal contructor.
 
Method Summary
 int compareTo(VNode parent)
           
abstract  boolean exists()
          Whether this node (still) exists
 VAttribute getAttribute(java.lang.String name)
          This is the single method a Node has to implement so that attributes can be fetched.
 java.lang.String[] getAttributeNames()
          Get the names of the attributes this resource has
 VAttribute[] getAttributes()
          Get all attributes defined by attributeNames
 VAttribute[] getAttributes(java.lang.String[] names)
          Get all attributes defined by names.
Elements in the names array may be null! It means do not fetch the attribute.
 VAttributeSet getAttributeSet(java.lang.String[] names)
          Same as getAttributes(), but return the attributes in an Attribute set.
 java.lang.String getBasename()
          Returns basename part of the path of a node.
 java.lang.String getCharSet()
          Default charset for text resources
 VRL getHelp()
          Returns simple text file or complete HTML page.
 java.lang.String getHostname()
          Returns Hostname
 java.lang.String getIconURL()
          Returns optional icon url
 long getID()
          Get unique VNode id.
 VRL getLocation()
          See getVRL()
 java.lang.String getMimeType()
          Returns Mime Type based upon file filenam/extension.
 java.lang.String getName()
          Returns the short name of the resource.
The default is the basename of the resource or the last part of the path part in the URI.
 VNode getParent()
          Get Parent Node (if any).
In the case of a graph, this method might return null, if it has multiple parents and no parent (of the multiparents) can be considered as the 'master' or 'root' parent.
 VNode[] getParents()
          Get Parents if the Node is part of a Graph.
 java.lang.String getPath()
          Returns logical path of this resource
 int getPort()
          Returns Port.
 java.lang.String getScheme()
           
 VAttribute[] getServerAttributes()
          This method return certain server properties which are used/needed to connect to the remote resource.
abstract  java.lang.String getType()
          Returns resource type, if it has one
 java.net.URI getURI()
          Returns URI (java.net.URI) of this object.
 VRL getVRL()
          Returns Virtual Resource Locator (VRL) of this object.
 VRSContext getVRSContext()
          Returns VRSContext which whas used to create this node
 boolean isComposite()
          Highlevel method to check whether the node has the VComposite interface
 boolean isVirtual()
          New Generic Type for MyVLe and LinkNodes
 boolean isVLink()
          Returns true if the EXTENSION equals '.vlink', this node might not be of type LinkNode.
 VAttribute[] mergedGetAttributes(VAttributeSet attrSet, java.lang.String[] attrNames)
          Fetch atrributes which are not in the Attribute Set.
protected  void setLocation(VRL loc)
           
protected  void setVRL(VRL loc)
          Only subclasses may change the location.
 ResourceNode toLinkNode()
          If this VNode represents a ResourceNode implementation this method will load the ResourceNode and return a new ResourceNode
 java.lang.String toString()
          Return this node's location as String representation.
Note that special characters are not encoded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTR_TYPE

public static final java.lang.String ATTR_TYPE
See Also:
Constant Field Values

ATTR_NAME

public static final java.lang.String ATTR_NAME
See Also:
Constant Field Values

ATTR_HOSTNAME

public static final java.lang.String ATTR_HOSTNAME
See Also:
Constant Field Values

ATTR_PORT

public static final java.lang.String ATTR_PORT
See Also:
Constant Field Values

ATTR_LOCATION

public static final java.lang.String ATTR_LOCATION
See Also:
Constant Field Values

ATTR_PATH

public static final java.lang.String ATTR_PATH
See Also:
Constant Field Values

ATTR_ICON

public static final java.lang.String ATTR_ICON
See Also:
Constant Field Values

ATTR_ISVLINK

public static final java.lang.String ATTR_ISVLINK
See Also:
Constant Field Values

ATTR_MIMETYPE

public static final java.lang.String ATTR_MIMETYPE
VAttribute name for the MimeType

See Also:
Constant Field Values

ATTR_CHARSET

public static final java.lang.String ATTR_CHARSET
See Also:
Constant Field Values

ATTR_SCHEME

public static final java.lang.String ATTR_SCHEME
See Also:
Constant Field Values

location

protected VRL location
The URI Compatable VRL or which specified the resource location


vrsContext

protected final VRSContext vrsContext
The *NEW* VRSContext to ensure shared environments ! Is FINAL, once set it may never be changed.

Constructor Detail

VNode

public VNode(VRSContext context,
             VRL vrl)
Universal contructor. As of 1-sep-2007, VNodes need a VRSContext .

Method Detail

getLocation

public final VRL getLocation()
See getVRL()

See Also:
getVRL()

getVRSContext

public final VRSContext getVRSContext()
Returns VRSContext which whas used to create this node


getVRL

public final VRL getVRL()
Returns Virtual Resource Locator (VRL) of this object. This is an URI compatible class but with more (URL like) features.

See Also:
VRL, URI

getURI

public final java.net.URI getURI()
                          throws VlException
Returns URI (java.net.URI) of this object. This method is the same as getVRL().toURI();

Throws:
VlException
See Also:
VRL, URI

getID

public long getID()
Get unique VNode id. Currently used for debugging


getName

public java.lang.String getName()
Returns the short name of the resource.
The default is the basename of the resource or the last part of the path part in the URI. To use another name, subclassses must overide this method.


getPath

public java.lang.String getPath()
Returns logical path of this resource


getHostname

public java.lang.String getHostname()
Returns Hostname


getPort

public int getPort()
Returns Port. If the value <=0 then the default port must be used.


getBasename

public java.lang.String getBasename()
Returns basename part of the path of a node.


getMimeType

public java.lang.String getMimeType()
                             throws VlIOException
Returns Mime Type based upon file filenam/extension. For a more robuust method, use MimeTypes.getMagicMimeType().

Throws:
VlIOException
See Also:
MimeTypes.getMagicMimeType(byte[]), MimeTypes.getMimeType(String)

getCharSet

public java.lang.String getCharSet()
                            throws VlIOException
Default charset for text resources

Throws:
VlIOException

isComposite

public boolean isComposite()
Highlevel method to check whether the node has the VComposite interface


getAttributeNames

public java.lang.String[] getAttributeNames()
Get the names of the attributes this resource has


getAttributes

public VAttribute[] getAttributes()
                           throws VlException
Get all attributes defined by attributeNames

Throws:
VlException
VlException

getAttributes

public VAttribute[] getAttributes(java.lang.String[] names)
                           throws VlException
Get all attributes defined by names.
Elements in the names array may be null! It means do not fetch the attribute. This is to speed up fetching of indexed attributes.
Developpers note:
Subclasses are encouraged to overide this method to speed up fetching multiple attributes as this method does a getAttribute call per attribute.

Throws:
VlException

getAttributeSet

public VAttributeSet getAttributeSet(java.lang.String[] names)
                              throws VlException
Same as getAttributes(), but return the attributes in an Attribute set.

Parameters:
names -
Returns:
Throws:
VlException

mergedGetAttributes

public VAttribute[] mergedGetAttributes(VAttributeSet attrSet,
                                        java.lang.String[] attrNames)
                                 throws VlException
Fetch atrributes which are not in the Attribute Set. This makes it possible (for subclasses) to merge several getAttributes() calls into one AttributeSet without having to do the attribute checking themselves. The returned array matches the length and order of attrNames[].
Entry may be null if VAttribute couln't be fetched.

Parameters:
attrSet -
attrNames -
Returns:
Throws:
VlException

getAttribute

public VAttribute getAttribute(java.lang.String name)
                        throws VlException
This is the single method a Node has to implement so that attributes can be fetched. subclasses can override this method and do a super.getAttribute first to check whether the superclass provides an attribute name.

Throws:
VlException

toString

public java.lang.String toString()
Return this node's location as String representation.
Note that special characters are not encoded.

Overrides:
toString in class java.lang.Object

setLocation

protected void setLocation(VRL loc)
See Also:
setVRL(VRL loc)

setVRL

protected void setVRL(VRL loc)
Only subclasses may change the location. Note that the location should be immutable: It may not change during the liftime of the object!


isVLink

public boolean isVLink()
Returns true if the EXTENSION equals '.vlink', this node might not be of type LinkNode. Is this method returns true, the method toLinkNode will return a valid LinkNode.

Returns:
See Also:
LinkNode, toLinkNode()

compareTo

public int compareTo(VNode parent)

toLinkNode

public ResourceNode toLinkNode()
                        throws VlException
If this VNode represents a ResourceNode implementation this method will load the ResourceNode and return a new ResourceNode

Returns:
new LinkNode
Throws:
VlException

getServerAttributes

public VAttribute[] getServerAttributes()
This method return certain server properties which are used/needed to connect to the remote resource. This could be authentication information or additional server parameters which are not stored in the URI.


getIconURL

public java.lang.String getIconURL()
Returns optional icon url


getHelp

public VRL getHelp()
Returns simple text file or complete HTML page. Method should point to installed documentation. Default is to return help about this type.


getParent

public VNode getParent()
                throws VlException
Get Parent Node (if any).
In the case of a graph, this method might return null, if it has multiple parents and no parent (of the multiparents) can be considered as the 'master' or 'root' parent.

Returns:
Parent VNode or null.
Throws:
VlException
See Also:
getParents()

getParents

public VNode[] getParents()
                   throws VlException
Get Parents if the Node is part of a Graph.
Returns one parent if Node is part of a Tree or null if Node has no parents.

Throws:
VlException

getScheme

public java.lang.String getScheme()

isVirtual

public boolean isVirtual()
New Generic Type for MyVLe and LinkNodes


getType

public abstract java.lang.String getType()
Returns resource type, if it has one


exists

public abstract boolean exists()
                        throws VlException
Whether this node (still) exists

Throws:
VlException