    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class org.w3c.jigsaw.pics.SampleLabel

    java.lang.Object
       |
       +----org.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.

##

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

##

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

##

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.

##

print

     public void print(PrintStream out)

  Debugging: print the given options of this label.

  Parameters:
    out - The PrintStream to print to.

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.

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.

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.

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.

isGeneric

     public boolean isGeneric()

  Is this label generic ?

  Returns:
    true if the label if generic.

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.

main

     public static void main(String args[])

    All Packages  Class Hierarchy  This Package  Previous  Next  Index