All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class websphinx.Region

java.lang.Object
   |
   +----websphinx.Region

public class Region
extends Object
Region of an HTML page.


Variable Index

 o end
 o names
 o source
 o start
 o TRUE
Default value for labels set with setLabel (name).

Constructor Index

 o Region(Page, int, int)
Makes a Region.
 o Region(Region)
Makes a Region by copying another region's parameters.

Method Index

 o enumerateObjectLabels()
Enumerate the labels of the region.
 o findEnd(Region[], int)
Finds a region that ends at or after a given position.
 o findStart(Region[], int)
Finds a region that starts at or after a given position.
 o getEnd()
Gets offset after end of region.
 o getField(String)
Get a named subregion.
 o getFields(String)
Get a set of named subregions.
 o getLabel(String)
Get a label's value.
 o getLabel(String, String)
Get a label's value.
 o getLength()
Gets length of the region.
 o getNumericLabel(String, Number)
Get a label's value as a number.
 o getObjectLabel(String)
Get an object-valued label.
 o getObjectLabels()
Get a String containing the labels of the region.
 o getRootElement()
Get the root HTML element of the region.
 o getSource()
Gets page containing the region.
 o getStart()
Gets starting offset of region in page content.
 o hasAllLabels(String)
Test if all of several labels are set.
 o hasAllLabels(String[])
Test if all of several labels are set.
 o hasAnyLabels(String)
Test if one or more of several labels are set.
 o hasAnyLabels(String[])
Test if one or more of several labels are set.
 o hasLabel(String)
Test if a label is set.
 o removeLabel(String)
Remove a label.
 o setField(String, Region)
Name a subregion (by setting a label to point to it).
 o setFields(String, Region[])
Name a set of subregions (by pointing a label to them).
 o setLabel(String)
Set a label on the region.
 o setLabel(String, String)
Set a string-valued label.
 o setObjectLabel(String, Object)
Set an object-valued label.
 o span(Region)
Makes a new Region containing two regions.
 o toHTML()
Converts the region to HTML, e.g.
 o toString()
Gets region as raw content.
 o toTags()
Converts the region to HTML tags with no text, e.g.
 o toText()
Converts the region to tagless text, e.g.

Variables

 o source
 protected Page source
 o start
 protected int start
 o end
 protected int end
 o names
 protected Hashtable names
 o TRUE
 public static final String TRUE
Default value for labels set with setLabel (name). Value of TRUE is "true".

Constructors

 o Region
 public Region(Page page,
               int start,
               int end)
Makes a Region.

Parameters:
page - Page containing region
start - Starting offset of region in page content
end - Ending offset of region in page
 o Region
 public Region(Region region)
Makes a Region by copying another region's parameters.

Parameters:
region - Region to copy

Methods

 o getSource
 public Page getSource()
Gets page containing the region.

Returns:
page containing the region
 o getStart
 public int getStart()
Gets starting offset of region in page content.

Returns:
zero-based offset where region begins in page content
 o getEnd
 public int getEnd()
Gets offset after end of region.

Returns:
zero-based offset just after the end of the region.
 o getLength
 public int getLength()
Gets length of the region. Equivalent to getEnd() - getStart().

Returns:
length of the HTML region in bytes.
 o toHTML
 public String toHTML()
Converts the region to HTML, e.g. "<tag><tag><tag>text text</tag>" If the region does not contain HTML, then this function quotes all the <, >, & characters found in the page content, and wraps the result in
 and 
.

Returns:
a string consisting of the HTML content contained by this region.
 o toText
 public String toText()
Converts the region to tagless text, e.g. "text text".

Returns:
a string consisting of the text in the page contained by this region
 o toTags
 public String toTags()
Converts the region to HTML tags with no text, e.g. "<tag><tag></tag>".

Returns:
a string consisting of the tags in the page contained by this region
 o toString
 public String toString()
Gets region as raw content.

Returns:
string representation of the region
Overrides:
toString in class Object
 o getRootElement
 public Element getRootElement()
Get the root HTML element of the region.

Returns:
first HTML element whose start tag is completely in the region.
 o findStart
 public static int findStart(Region regions[],
                             int p)
Finds a region that starts at or after a given position.

Parameters:
regions - array of regions sorted by starting offset
p - Desired starting offset
Returns:
index k into regions such that:
  1. forall j<k: regions[j].start < p
  2. regions[k].start >= p
 o findEnd
 public static int findEnd(Region regions[],
                           int p)
Finds a region that ends at or after a given position.

Parameters:
regions - array of regions sorted by ending offset
p - Desired ending offset
Returns:
index k into regions such that:
  1. forall j<k: regions[j].end < p
  2. regions[k].end >= p
 o span
 public Region span(Region r)
Makes a new Region containing two regions.

Parameters:
r - end of spanning region
Returns:
region from the beginning of this region to the end of r. Both regions must have the same source, and r must end after this region starts.
 o setObjectLabel
 public void setObjectLabel(String name,
                            Object value)
Set an object-valued label.

Parameters:
name - name of label (case-sensitive, whitespace permitted)
value - value set for label. If null, the label is removed.
 o getObjectLabel
 public Object getObjectLabel(String name)
Get an object-valued label.

Parameters:
name - name of label (case-sensitive, whitespace permitted)
Returns:
Object value set for label, or null if label not set
 o enumerateObjectLabels
 public Enumeration enumerateObjectLabels()
Enumerate the labels of the region.

Returns:
enumeration producing label names
 o getObjectLabels
 public String getObjectLabels()
Get a String containing the labels of the region.

Returns:
string containing the label names, separated by spaces
 o setLabel
 public void setLabel(String name,
                      String value)
Set a string-valued label.

Parameters:
name - name of label (case-sensitive, whitespace permitted)
value - value set for label. If null, the label is removed.
 o setLabel
 public void setLabel(String name)
Set a label on the region. The value of the label defaults to TRUE.

Parameters:
name - name of label (case-sensitive, whitespace permitted)
 o getLabel
 public String getLabel(String name)
Get a label's value.

Parameters:
name - name of label (case-sensitive, whitespace permitted)
Returns:
value of label, or null if label not set
 o getLabel
 public String getLabel(String name,
                        String defaultValue)
Get a label's value. If the label is not set, return defaultValue.

Parameters:
name - name of label (case-sensitive, whitespace permitted)
defaultValue - default value that should be returned if label is not set
Returns:
value of label, or defaultValue if not set
 o getNumericLabel
 public Number getNumericLabel(String name,
                               Number defaultValue)
Get a label's value as a number. Returns the first number (integral or floating point) that can be parsed from the label's value, skipping an arbitrary amount of junk.

Parameters:
name - name of label (case-sensitive, whitespace permitted)
defaultValue - default value that should be returned if label is not set
Returns:
numeric value of label, or defaultValue if not set or no number is found
 o hasLabel
 public boolean hasLabel(String name)
Test if a label is set.

Parameters:
name - name of label (case-sensitive, whitespace permitted)
Returns:
true if label is set, otherwise false
 o hasAnyLabels
 public boolean hasAnyLabels(String expr)
Test if one or more of several labels are set.

Parameters:
expr - a list of label names separated by spaces
Returns:
true if region has at least one of the labels in expr
 o hasAnyLabels
 public boolean hasAnyLabels(String labels[])
Test if one or more of several labels are set.

Parameters:
labels - an array of label names
Returns:
true if region has at least one of the labels
 o hasAllLabels
 public boolean hasAllLabels(String expr)
Test if all of several labels are set.

Parameters:
expr - a list of label names separated by spaces
Returns:
true if region has at least one of the labels in expr
 o hasAllLabels
 public boolean hasAllLabels(String labels[])
Test if all of several labels are set.

Parameters:
labels - an array of label names
Returns:
true if region has all of the labels
 o removeLabel
 public void removeLabel(String name)
Remove a label.

Parameters:
name - name of label (case-sensitive, whitespace permitted)
 o setField
 public void setField(String name,
                      Region region)
Name a subregion (by setting a label to point to it).

Parameters:
name - label name (case-sensitive, whitespace permitted)
region - subregion to name
 o getField
 public Region getField(String name)
Get a named subregion.

Parameters:
name - label name (case-sensitive, whitespace permitted)
Returns:
the named region, or null if label not set to a region
 o setFields
 public void setFields(String name,
                       Region regions[])
Name a set of subregions (by pointing a label to them).

Parameters:
name - label name (case-sensitive, whitespace permitted)
regions - list of subregions
 o getFields
 public Region[] getFields(String name)
Get a set of named subregions. Note that subregions named with setField() cannot be retrieved with getFields(); use getField() instead.

Parameters:
name - label name (case-sensitive, whitespace permitted)
Returns:
the named subregions, or null if label not set to a set of subregions

All Packages  Class Hierarchy  This Package  Previous  Next  Index