All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.jigsaw.pics.SampleLabel

java.lang.Object
   |
   +----w3c.jigsaw.pics.SampleLabel

public class SampleLabel
extends Object
implements LabelInterface
Label internal representation. The server has to know something about labels. In this implementation, I try to reduce this knowledge as fas as I could. Here, a label is a set of assignements to variables (options in PICS terms), and a rating. The syntax for writing label files is the following: =\n

Comments are allowed through the '#' at beginning of line. With the special variable 'ratings' being mandatory.


Constructor Index

 o SampleLabel(String[], String[])
Create a new label from a set of options.

Method Index

 o dump(StringBuffer, int)
Dump this label according to the given format.
 o getOptionIndex(String)
Get an option index.
 o getOptionValue(int)
Get an option value, by index.
 o getOptionValue(String)
Get an option value, by option name.
 o hasOption(String)
Does this label defines the given option ?
 o isGeneric()
Is this label generic ?
 o main(String[])
 o print(PrintStream)
Debugging: print the given options of this label.

Constructors

 o SampleLabel
 public SampleLabel(String optnames[],
                    String optvals[])
Create a new label from a set of options. This constructor takes two arrays, one of option names, and one of option values. It builds out of them the internal representation for this label.

The given arrays are used as is (no copy), and might side-effected by the new instance.

Parameters:
optnames - Names of option for this label.
optvalues - Values of option for this label.

Methods

 o print
 public void print(PrintStream out)
Debugging: print the given options of this label.

Parameters:
out - The PrintStream to print to.
 o hasOption
 public boolean hasOption(String option)
Does this label defines the given option ?

Parameters:
option - The option to look for.
Returns:
true if the label defines the given option.
 o getOptionIndex
 public int getOptionIndex(String option)
Get an option index. This allows for fast acces to label options. There is no guarantee that the same option will get the same index across labels.

Parameters:
option - The option to look for.
Returns:
An integer, which is the option index if the option was found or -1 if the option isn't defined for this label.
 o getOptionValue
 public String getOptionValue(int idx)
Get an option value, by index. This, along with the getOptionIndex method provides a fast access to option values.

Parameters:
idx - The index of the option, as gotten from getOptionIndex.
Returns:
A String instance, providing the option value.
 o getOptionValue
 public String getOptionValue(String option)
Get an option value, by option name.

Parameters:
option - The option that you want the value of.
Returns:
A String instance giving the option value, or null, if the option isn't defined for this label.
 o isGeneric
 public boolean isGeneric()
Is this label generic ?

Returns:
true if the label if generic.
 o dump
 public void dump(StringBuffer into,
                  int format)
Dump this label according to the given format. The dump should take place after the service has dump itself.

Parameters:
into - A StringBuffer to dump the labels to.
format - The format in which the dump should be done. This can be one of the four format described in the PICS specification.
 o main
 public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index