org.htmlparser.lexer
Class PageAttribute
- Serializable
public class PageAttribute
An attribute within a tag on a page.
This attribute is similar to Attribute but 'lazy loaded' from the
Page
by providing the page and cursor offsets
into the page for the name and value. This is done for speed, since
if the name and value are not needed we can avoid the cost and memory
overhead of creating the strings.
Thus the property getters, defer to the base class unless the property
is null, in which case an attempt is made to read it from the underlying
page. Optimizations in the predicates and length calculation defer the
actual instantiation of strings until absolutely needed.
protected int | mNameEnd - The ending offset of the name within the page.
|
protected int | mNameStart - The starting offset of the name within the page.
|
protected Page | mPage - The page this attribute is extracted from.
|
protected int | mValueEnd - The ending offset of the name within the page.
|
protected int | mValueStart - The starting offset of the value within the page.
|
PageAttribute() - Create an empty attribute.
|
PageAttribute(String value) - Create a whitespace attribute with the value given.
|
PageAttribute(String name, String value) - Create an attribute with the name and value given.
|
PageAttribute(String name, String assignment, String value) - Create an attribute with the name, assignment string and value given.
|
PageAttribute(String name, String assignment, String value, char quote) - Create an attribute with the name, assignment string, value and quote given.
|
PageAttribute(String name, String value, char quote) - Create an attribute with the name, value and quote given.
|
PageAttribute(Page page, int name_start, int name_end, int value_start, int value_end, char quote) - Create an attribute.
|
String | getAssignment() - Get the assignment string of this attribute.
|
void | getAssignment(StringBuffer buffer) - Get the assignment string of this attribute.
|
int | getLength() - Get the length of the string value of this attribute.
|
String | getName() - Get the name of this attribute.
|
void | getName(StringBuffer buffer) - Get the name of this attribute.
|
int | getNameEndPosition() - Get the ending position of the attribute name.
|
int | getNameStartPosition() - Get the starting position of the attribute name.
|
Page | getPage() - Get the page this attribute is anchored to, if any.
|
String | getRawValue() - Get the raw value of the attribute.
|
void | getRawValue(StringBuffer buffer) - Get the raw value of the attribute.
|
String | getValue() - Get the value of the attribute.
|
void | getValue(StringBuffer buffer) - Get the value of the attribute.
|
int | getValueEndPosition() - Get the ending position of the attribute value.
|
int | getValueStartPosition() - Get the starting position of the attribute value.
|
boolean | isEmpty() - Predicate to determine if this attribute has an equals sign but no value.
|
boolean | isStandAlone() - Predicate to determine if this attribute has no equals sign (or value).
|
boolean | isValued() - Predicate to determine if this attribute has a value.
|
boolean | isWhitespace() - Predicate to determine if this attribute is whitespace.
|
void | setNameEndPosition(int end) - Set the ending position of the attribute name.
|
void | setNameStartPosition(int start) - Set the starting position of the attribute name.
|
void | setPage(Page page) - Set the page this attribute is anchored to.
|
void | setValueEndPosition(int end) - Set the ending position of the attribute value.
|
void | setValueStartPosition(int start) - Set the starting position of the attribute value.
|
getAssignment , getAssignment , getLength , getName , getName , getQuote , getQuote , getRawValue , getRawValue , getValue , getValue , isEmpty , isStandAlone , isValued , isWhitespace , setAssignment , setName , setQuote , setRawValue , setValue , toString , toString |
mNameEnd
protected int mNameEnd
The ending offset of the name within the page.
mNameStart
protected int mNameStart
The starting offset of the name within the page.
If negative, the name is considered null
.
mPage
protected Page mPage
The page this attribute is extracted from.
mValueEnd
protected int mValueEnd
The ending offset of the name within the page.
mValueStart
protected int mValueStart
The starting offset of the value within the page.
If negative, the value is considered null
.
PageAttribute
public PageAttribute()
PageAttribute
public PageAttribute(String value)
throws IllegalArgumentException
Create a whitespace attribute with the value given.
value
- The value of this attribute.
PageAttribute
public PageAttribute(String name,
String value)
Create an attribute with the name and value given.
Uses an equals sign as the assignment string if the value is not
null
, and calls PageAttribute
to get the
correct quoting.
name
- The name of this attribute.value
- The value of this attribute.
PageAttribute
public PageAttribute(String name,
String assignment,
String value)
Create an attribute with the name, assignment string and value given.
Calls PageAttribute
to get the correct quoting.
name
- The name of this attribute.assignment
- The assignment string of this attribute.value
- The value of this attribute.
PageAttribute
public PageAttribute(String name,
String assignment,
String value,
char quote)
Create an attribute with the name, assignment string, value and quote given.
If the quote value is zero, assigns the value using PageAttribute
which sets the quote character to a proper value if necessary.
name
- The name of this attribute.assignment
- The assignment string of this attribute.value
- The value of this attribute.quote
- The quote around the value of this attribute.
PageAttribute
public PageAttribute(String name,
String value,
char quote)
Create an attribute with the name, value and quote given.
Uses an equals sign as the assignment string if the value is not
null
, and calls PageAttribute
to get the
correct quoting if quote
is zero.
name
- The name of this attribute.value
- The value of this attribute.quote
- The quote around the value of this attribute.
PageAttribute
public PageAttribute(Page page,
int name_start,
int name_end,
int value_start,
int value_end,
char quote)
Create an attribute.
page
- The page containing the attribute.name_start
- The starting offset of the name within the page.
If this is negative, the name is considered null.name_end
- The ending offset of the name within the page.value_start
- he starting offset of the value within the page.
If this is negative, the value is considered null.value_end
- The ending offset of the value within the page.quote
- The quote, if any, surrounding the value of the attribute,
(i.e. ' or "), or zero if none.
getAssignment
public String getAssignment()
Get the assignment string of this attribute.
This is usually just an equals sign, but in poorly formed attributes it
can include whitespace on either or both sides of an equals sign.
- getAssignment in interface Attribute
getAssignment
public void getAssignment(StringBuffer buffer)
Get the assignment string of this attribute.
- getAssignment in interface Attribute
buffer
- The buffer to place the assignment string in.
getLength
public int getLength()
Get the length of the string value of this attribute.
- getLength in interface Attribute
- The number of characters required to express this attribute.
getName
public String getName()
Get the name of this attribute.
The part before the equals sign, or the contents of the
stand-alone attribute.
- getName in interface Attribute
- The name, or
null
if it's just a whitepace
'attribute'.
getName
public void getName(StringBuffer buffer)
Get the name of this attribute.
- getName in interface Attribute
buffer
- The buffer to place the name in.
getNameEndPosition
public int getNameEndPosition()
Get the ending position of the attribute name.
- The offset into the page at which the name ends.
getNameStartPosition
public int getNameStartPosition()
Get the starting position of the attribute name.
- The offset into the page at which the name begins.
getPage
public Page getPage()
Get the page this attribute is anchored to, if any.
- The page used to construct this attribute, or null if this
is just a regular attribute.
getRawValue
public String getRawValue()
Get the raw value of the attribute.
The part after the equals sign, or the text if it's just a whitepace
'attribute'. This includes the quotes around the value if any.
- getRawValue in interface Attribute
- The value, or
null
if it's a stand-alone attribute,
or the text if it's just a whitepace 'attribute'.
getRawValue
public void getRawValue(StringBuffer buffer)
Get the raw value of the attribute.
The part after the equals sign, or the text if it's just a whitepace
'attribute'. This includes the quotes around the value if any.
- getRawValue in interface Attribute
buffer
- The string buffer to append the attribute value to.
getValue
public String getValue()
Get the value of the attribute.
The part after the equals sign, or the text if it's just a whitepace
'attribute'.
NOTE: This does not include any quotes that may have enclosed
the value when it was read. To get the un-stripped value use
getRawValue
.
- getValue in interface Attribute
- The value, or
null
if it's a stand-alone or
empty attribute, or the text if it's just a whitepace 'attribute'.
getValue
public void getValue(StringBuffer buffer)
Get the value of the attribute.
- getValue in interface Attribute
buffer
- The buffer to place the value in.
getValueEndPosition
public int getValueEndPosition()
Get the ending position of the attribute value.
- The offset into the page at which the value ends.
getValueStartPosition
public int getValueStartPosition()
Get the starting position of the attribute value.
- The offset into the page at which the value begins.
isEmpty
public boolean isEmpty()
Predicate to determine if this attribute has an equals sign but no value.
- isEmpty in interface Attribute
true
if this attribute is an empty attribute.
false
if has an equals sign and a value.
isStandAlone
public boolean isStandAlone()
Predicate to determine if this attribute has no equals sign (or value).
- isStandAlone in interface Attribute
true
if this attribute is a standalone attribute.
false
if has an equals sign.
isValued
public boolean isValued()
Predicate to determine if this attribute has a value.
- isValued in interface Attribute
true
if this attribute has a value.
false
if it is empty or standalone.
isWhitespace
public boolean isWhitespace()
Predicate to determine if this attribute is whitespace.
- isWhitespace in interface Attribute
true
if this attribute is whitespace,
false
if it is a real attribute.
setNameEndPosition
public void setNameEndPosition(int end)
Set the ending position of the attribute name.
end
- The new offset into the page at which the name ends.
setNameStartPosition
public void setNameStartPosition(int start)
Set the starting position of the attribute name.
start
- The new offset into the page at which the name begins.
setPage
public void setPage(Page page)
Set the page this attribute is anchored to.
page
- The page to be used to construct this attribute.
Note: If you set this you probably also want to uncache the property
values by setting them to null.
setValueEndPosition
public void setValueEndPosition(int end)
Set the ending position of the attribute value.
end
- The new offset into the page at which the value ends.
setValueStartPosition
public void setValueStartPosition(int start)
Set the starting position of the attribute value.
start
- The new offset into the page at which the value begins.
| © 2005 Derrick Oswald Mai 08, 2008 |
HTML Parser is an open source library released under LGPL. |  |