org.w3c.jigsaw.pics
Class SampleLabelService

java.lang.Object
  extended by org.w3c.jigsaw.pics.SampleLabelService
All Implemented Interfaces:
LabelServiceInterface

public class SampleLabelService
extends java.lang.Object
implements LabelServiceInterface

The internal representation of a LabelService. A LabelService is an object which should be able to deliver labels for any URL. This implementation doesn't use any fancy database (it should), it uses the file system as a Database, in fact.

Each service is assigned a directory, and for each requested labels, this directory is looked up for the appropriate URL. So if you want to label http://www.w3.org/pub/WWW you have to create, under this service directory a file named http/www.w3.org/pub/WWW/label. To label its Overview.html document define the http/www.w3.org/pub/WWW/Overview.html-label file. The label itself is the content of the file.


Constructor Summary
SampleLabelService(SampleLabelBureau b, java.lang.String name)
           
 
Method Summary
 void dump(java.lang.StringBuffer into, int format)
          Dump this service description into the given buffer.
 java.io.File filify(java.net.URL u, boolean generic)
          Filify an URL.
 LabelInterface getGenericLabel(java.net.URL url)
          Get the most speicific generic label for an URL.
 LabelInterface[] getGenericTreeLabels(java.net.URL url)
          Get the generic tree labels for given URL.
 java.lang.String getName()
          Get this service name.
 LabelInterface getSpecificLabel(java.net.URL url)
          Get the specific label for the given URL.
 LabelInterface[] getTreeLabels(java.net.URL url)
          Get the tree labels for the given URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SampleLabelService

public SampleLabelService(SampleLabelBureau b,
                          java.lang.String name)
                   throws org.w3c.jigsaw.pics.UnknownServiceException
Throws:
org.w3c.jigsaw.pics.UnknownServiceException
Method Detail

filify

public java.io.File filify(java.net.URL u,
                           boolean generic)
Filify an URL. This methods takes an URL as input, and returns an uniq File object relative to the given SampleLabelService directory.

Parameters:
u - The URL to filify.
generic - Filify for generic labels if true.

getName

public java.lang.String getName()
Get this service name.

Returns:
A String instance, being the service name.

dump

public void dump(java.lang.StringBuffer into,
                 int format)
Dump this service description into the given buffer.

Specified by:
dump in interface LabelServiceInterface
Parameters:
into - The StringBuffer to dump the service to.
format - The format in which this service is to be dumped (which can be any of ... FIXME)

getSpecificLabel

public LabelInterface getSpecificLabel(java.net.URL url)
Get the specific label for the given URL.

Specified by:
getSpecificLabel in interface LabelServiceInterface
Parameters:
url - The URL whose label is searched.
Returns:
An object conorminig to the LabelInterface, or null if none was found.

getGenericLabel

public LabelInterface getGenericLabel(java.net.URL url)
Get the most speicific generic label for an URL.

Specified by:
getGenericLabel in interface LabelServiceInterface
Parameters:
url - The URL whose generic label is to be retreived.
Returns:
An object conforming to the LabelInterface, or null if none was found.

getTreeLabels

public LabelInterface[] getTreeLabels(java.net.URL url)
Get the tree labels for the given URL.

Specified by:
getTreeLabels in interface LabelServiceInterface
Parameters:
url - The URL whose tree labels are to be retreived.
Returns:
An array of SampleLabel, each comforming to the LabelInterface.

getGenericTreeLabels

public LabelInterface[] getGenericTreeLabels(java.net.URL url)
Get the generic tree labels for given URL.

Specified by:
getGenericTreeLabels in interface LabelServiceInterface
Parameters:
url - The URL whose tree labels are to be retreived.
Returns:
An array of SampleLabel, each of which conforms to the LabelInterface.