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.
-
end
-
-
names
-
-
source
-
-
start
-
-
TRUE
- Default value for labels set with setLabel (name).
-
Region(Page, int, int)
- Makes a Region.
-
Region(Region)
- Makes a Region by copying another region's parameters.
-
enumerateObjectLabels()
- Enumerate the labels of the region.
-
findEnd(Region[], int)
- Finds a region that ends at or after a given position.
-
findStart(Region[], int)
- Finds a region that starts at or after a given position.
-
getEnd()
- Gets offset after end of region.
-
getField(String)
- Get a named subregion.
-
getFields(String)
- Get a set of named subregions.
-
getLabel(String)
- Get a label's value.
-
getLabel(String, String)
- Get a label's value.
-
getLength()
- Gets length of the region.
-
getNumericLabel(String, Number)
- Get a label's value as a number.
-
getObjectLabel(String)
- Get an object-valued label.
-
getObjectLabels()
- Get a String containing the labels of the region.
-
getRootElement()
- Get the root HTML element of the region.
-
getSource()
- Gets page containing the region.
-
getStart()
- Gets starting offset of region in page content.
-
hasAllLabels(String)
-
Test if all of several labels are set.
-
hasAllLabels(String[])
-
Test if all of several labels are set.
-
hasAnyLabels(String)
-
Test if one or more of several labels are set.
-
hasAnyLabels(String[])
-
Test if one or more of several labels are set.
-
hasLabel(String)
- Test if a label is set.
-
removeLabel(String)
- Remove a label.
-
setField(String, Region)
- Name a subregion (by setting a label to point to it).
-
setFields(String, Region[])
- Name a set of subregions (by pointing a label to them).
-
setLabel(String)
- Set a label on the region.
-
setLabel(String, String)
- Set a string-valued label.
-
setObjectLabel(String, Object)
- Set an object-valued label.
-
span(Region)
- Makes a new Region containing two regions.
-
toHTML()
- Converts the region to HTML, e.g.
-
toString()
- Gets region as raw content.
-
toTags()
- Converts the region to HTML tags with no text, e.g.
-
toText()
- Converts the region to tagless text, e.g.
source
protected Page source
start
protected int start
end
protected int end
names
protected Hashtable names
TRUE
public static final String TRUE
- Default value for labels set with setLabel (name). Value of TRUE is
"true".
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
Region
public Region(Region region)
- Makes a Region by copying another region's parameters.
- Parameters:
- region - Region to copy
getSource
public Page getSource()
- Gets page containing the region.
- Returns:
- page containing the region
getStart
public int getStart()
- Gets starting offset of region in page content.
- Returns:
- zero-based offset where region begins in page content
getEnd
public int getEnd()
- Gets offset after end of region.
- Returns:
- zero-based offset just after the end of the region.
getLength
public int getLength()
- Gets length of the region. Equivalent to getEnd() - getStart().
- Returns:
- length of the HTML region in bytes.
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.
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
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
toString
public String toString()
- Gets region as raw content.
- Returns:
- string representation of the region
- Overrides:
- toString in class Object
getRootElement
public Element getRootElement()
- Get the root HTML element of the region.
- Returns:
- first HTML element whose start tag is
completely in the region.
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:
- forall j<k: regions[j].start < p
- regions[k].start >= p
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:
- forall j<k: regions[j].end < p
- regions[k].end >= p
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.
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.
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
enumerateObjectLabels
public Enumeration enumerateObjectLabels()
- Enumerate the labels of the region.
- Returns:
- enumeration producing label names
getObjectLabels
public String getObjectLabels()
- Get a String containing the labels of the region.
- Returns:
- string containing the label names, separated by spaces
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.
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)
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
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
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
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
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
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
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
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
removeLabel
public void removeLabel(String name)
- Remove a label.
- Parameters:
- name - name of label (case-sensitive, whitespace permitted)
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
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
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
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