| java.lang.Object websphinx.Region
All known Subclasses: websphinx.Page, websphinx.Element, websphinx.Text, websphinx.Tag, websphinx.searchengine.SearchEngineResult,
Region | public class Region (Code) | | Region of an HTML page.
|
Constructor Summary | |
public | Region(Page page, int start, int end) Makes a Region. | public | Region(Region region) Makes a Region by copying another region's parameters. |
Method Summary | |
public Enumeration | enumerateObjectLabels() Enumerate the labels of the region. | public static int | findEnd(Region[] regions, int p) Finds a region that ends at or after a given position. | public static int | findStart(Region[] regions, int p) Finds a region that starts at or after a given position. | public int | getEnd() Gets offset after end of region. | public Region | getField(String name) Get a named subregion. | public Region[] | getFields(String name) Get a set of named subregions. | public String | getLabel(String name) Get a label's value. | public String | getLabel(String name, String defaultValue) Get a label's value. | public int | getLength() Gets length of the region. | public Number | getNumericLabel(String name, Number defaultValue) Get a label's value as a number. | public Object | getObjectLabel(String name) Get an object-valued label. | public String | getObjectLabels() Get a String containing the labels of the region. | public Element | getRootElement() Get the root HTML element of the region. | public Page | getSource() Gets page containing the region. | public int | getStart() Gets starting offset of region in page content. | public boolean | hasAllLabels(String expr) Test if all of several labels are set. | public boolean | hasAllLabels(String[] labels) Test if all of several labels are set. | public boolean | hasAnyLabels(String expr) Test if one or more of several labels are set. | public boolean | hasAnyLabels(String[] labels) Test if one or more of several labels are set. | public boolean | hasLabel(String name) Test if a label is set. | public void | removeLabel(String name) Remove a label. | public void | setField(String name, Region region) Name a subregion (by setting a label to point to it). | public void | setFields(String name, Region[] regions) Name a set of subregions (by pointing a label to them). | public void | setLabel(String name, String value) Set a string-valued label.
Parameters: name - name of label (case-sensitive, whitespace permitted) Parameters: value - value set for label. | public void | setLabel(String name) Set a label on the region. | public void | setObjectLabel(String name, Object value) Set an object-valued label.
Parameters: name - name of label (case-sensitive, whitespace permitted) Parameters: value - value set for label. | public Region | span(Region r) Makes a new Region containing two regions.
Parameters: r - end of spanning region region from the beginning of this region to the end of r. | public String | toHTML() Converts the region to HTML, e.g. | public String | toString() Gets region as raw content. | public String | toTags() Converts the region to HTML tags with no text, e.g. | public String | toText() Converts the region to tagless text, e.g. |
INITIAL_SIZE | final static int INITIAL_SIZE(Code) | | |
TRUE | final public static String TRUE(Code) | | Default value for labels set with setLabel (name). Value of TRUE is
"true".
|
start | protected int start(Code) | | |
Region | public Region(Page page, int start, int end)(Code) | | Makes a Region.
Parameters: page - Page containing region Parameters: start - Starting offset of region in page content Parameters: end - Ending offset of region in page |
Region | public Region(Region region)(Code) | | Makes a Region by copying another region's parameters.
Parameters: region - Region to copy |
enumerateObjectLabels | public Enumeration enumerateObjectLabels()(Code) | | Enumerate the labels of the region.
enumeration producing label names |
findEnd | public static int findEnd(Region[] regions, int p)(Code) | | Finds a region that ends at or after a given position.
Parameters: regions - array of regions sorted by ending offset Parameters: p - Desired ending offset index k into regions such that:- forall j<k: regions[j].end < p
- regions[k].end >= p
|
findStart | public static int findStart(Region[] regions, int p)(Code) | | Finds a region that starts at or after a given position.
Parameters: regions - array of regions sorted by starting offset Parameters: p - Desired starting offset index k into regions such that:- forall j<k: regions[j].start < p
- regions[k].start >= p
|
getEnd | public int getEnd()(Code) | | Gets offset after end of region.
zero-based offset just after the end of the region. |
getField | public Region getField(String name)(Code) | | Get a named subregion.
Parameters: name - label name (case-sensitive, whitespace permitted) the named region, or null if label not set to a region |
getFields | public Region[] getFields(String name)(Code) | | 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) the named subregions, or null if label not set to a set of subregions |
getLabel | public String getLabel(String name)(Code) | | Get a label's value.
Parameters: name - name of label (case-sensitive, whitespace permitted) value of label, or null if label not set |
getLabel | public String getLabel(String name, String defaultValue)(Code) | | Get a label's value. If the label is not set, return defaultValue.
Parameters: name - name of label (case-sensitive, whitespace permitted) Parameters: defaultValue - default value that should be returned if label is not set value of label, or defaultValue if not set |
getLength | public int getLength()(Code) | | Gets length of the region. Equivalent to getEnd() - getStart().
length of the HTML region in bytes. |
getNumericLabel | public Number getNumericLabel(String name, Number defaultValue)(Code) | | 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) Parameters: defaultValue - default value that should be returned if label is not set numeric value of label, or defaultValue if not set or no number is found |
getObjectLabel | public Object getObjectLabel(String name)(Code) | | Get an object-valued label.
Parameters: name - name of label (case-sensitive, whitespace permitted) Object value set for label, or null if label not set |
getObjectLabels | public String getObjectLabels()(Code) | | Get a String containing the labels of the region.
string containing the label names, separated by spaces |
getRootElement | public Element getRootElement()(Code) | | Get the root HTML element of the region.
first HTML element whose start tag iscompletely in the region. |
getSource | public Page getSource()(Code) | | Gets page containing the region.
page containing the region |
getStart | public int getStart()(Code) | | Gets starting offset of region in page content.
zero-based offset where region begins in page content |
hasAllLabels | public boolean hasAllLabels(String expr)(Code) | | Test if all of several labels are set.
Parameters: expr - a list of label names separated by spaces true if region has at least one of the labels in expr |
hasAllLabels | public boolean hasAllLabels(String[] labels)(Code) | | Test if all of several labels are set.
Parameters: labels - an array of label names true if region has all of the labels |
hasAnyLabels | public boolean hasAnyLabels(String expr)(Code) | | Test if one or more of several labels are set.
Parameters: expr - a list of label names separated by spaces true if region has at least one of the labels in expr |
hasAnyLabels | public boolean hasAnyLabels(String[] labels)(Code) | | Test if one or more of several labels are set.
Parameters: labels - an array of label names true if region has at least one of the labels |
hasLabel | public boolean hasLabel(String name)(Code) | | Test if a label is set.
Parameters: name - name of label (case-sensitive, whitespace permitted) true if label is set, otherwise false |
removeLabel | public void removeLabel(String name)(Code) | | Remove a label.
Parameters: name - name of label (case-sensitive, whitespace permitted) |
setField | public void setField(String name, Region region)(Code) | | Name a subregion (by setting a label to point to it).
Parameters: name - label name (case-sensitive, whitespace permitted) Parameters: region - subregion to name |
setFields | public void setFields(String name, Region[] regions)(Code) | | Name a set of subregions (by pointing a label to them).
Parameters: name - label name (case-sensitive, whitespace permitted) Parameters: regions - list of subregions |
setLabel | public void setLabel(String name, String value)(Code) | | Set a string-valued label.
Parameters: name - name of label (case-sensitive, whitespace permitted) Parameters: value - value set for label. If null, the label is removed. |
setLabel | public void setLabel(String name)(Code) | | Set a label on the region. The value of the label defaults to TRUE.
Parameters: name - name of label (case-sensitive, whitespace permitted) |
setObjectLabel | public void setObjectLabel(String name, Object value)(Code) | | Set an object-valued label.
Parameters: name - name of label (case-sensitive, whitespace permitted) Parameters: value - value set for label. If null, the label is removed. |
span | public Region span(Region r)(Code) | | Makes a new Region containing two regions.
Parameters: r - end of spanning region region from the beginning of this region to the end of r. Both regions must havethe same source, and r must end after this region starts. |
toHTML | public String toHTML()(Code) | | 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 .
a string consisting of the HTML content contained by this region. |
toString | public String toString()(Code) | | Gets region as raw content.
string representation of the region |
toTags | public String toTags()(Code) | | Converts the region to HTML tags with no text, e.g. "<tag><tag></tag>".
a string consisting of the tags in the page contained by this region |
toText | public String toText()(Code) | | Converts the region to tagless text, e.g. "text text".
a string consisting of the text in the page contained by this region |
|
|