public class Attribute
extends java.lang.Object
implements java.io.Serializable
构造器和说明 |
---|
Attribute()
Create an empty attribute.
|
Attribute(java.lang.String value)
Create a whitespace attribute with the value given.
|
Attribute(java.lang.String name,
java.lang.String value)
Create an attribute with the name and value given.
|
Attribute(java.lang.String name,
java.lang.String value,
char quote)
Create an attribute with the name, value and quote given.
|
Attribute(java.lang.String name,
java.lang.String assignment,
java.lang.String value)
Create an attribute with the name, assignment string and value given.
|
Attribute(java.lang.String name,
java.lang.String assignment,
java.lang.String value,
char quote)
Create an attribute with the name, assignment, value and quote given.
|
限定符和类型 | 方法和说明 |
---|---|
java.lang.String |
getAssignment()
Get the assignment string of this attribute.
|
void |
getAssignment(java.lang.StringBuffer buffer)
Get the assignment string of this attribute.
|
int |
getLength()
Get the length of the string value of this attribute.
|
java.lang.String |
getName()
Get the name of this attribute.
|
void |
getName(java.lang.StringBuffer buffer)
Get the name of this attribute.
|
char |
getQuote()
Get the quote, if any, surrounding the value of the attribute, if any.
|
void |
getQuote(java.lang.StringBuffer buffer)
Get the quote, if any, surrounding the value of the attribute, if any.
|
java.lang.String |
getRawValue()
Get the raw value of the attribute.
|
void |
getRawValue(java.lang.StringBuffer buffer)
Get the raw value of the attribute.
|
java.lang.String |
getValue()
Get the value of the attribute.
|
void |
getValue(java.lang.StringBuffer buffer)
Get the value of the attribute.
|
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 |
setAssignment(java.lang.String assignment)
Set the assignment string of this attribute.
|
void |
setName(java.lang.String name)
Set the name of this attribute.
|
void |
setQuote(char quote)
Set the quote surrounding the value of the attribute.
|
void |
setRawValue(java.lang.String value)
Set the value of the attribute and the quote character.
|
void |
setValue(java.lang.String value)
Set the value of the attribute.
|
java.lang.String |
toString()
Get a text representation of this attribute.
|
void |
toString(java.lang.StringBuffer buffer)
Get a text representation of this attribute.
|
public Attribute(java.lang.String name, java.lang.String assignment, java.lang.String value, char quote)
setRawValue(java.lang.String)
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.public Attribute(java.lang.String name, java.lang.String value, char quote)
null
, and calls setRawValue(java.lang.String)
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.public Attribute(java.lang.String value) throws java.lang.IllegalArgumentException
value
- The value of this attribute.java.lang.IllegalArgumentException
- if the value contains other than
whitespace. To set a real value use Attribute(String,String)
.public Attribute(java.lang.String name, java.lang.String value)
null
, and calls setRawValue(java.lang.String)
to get the
correct quoting.name
- The name of this attribute.value
- The value of this attribute.public Attribute(java.lang.String name, java.lang.String assignment, java.lang.String value)
setRawValue(java.lang.String)
to get the correct quoting.name
- The name of this attribute.assignment
- The assignment string of this attribute.value
- The value of this attribute.public Attribute()
toString()
and
toString(StringBuffer)
methods.public java.lang.String getName()
null
if it's just a whitepace
'attribute'.setName(java.lang.String)
public void getName(java.lang.StringBuffer buffer)
buffer
- The buffer to place the name in.getName()
,
setName(java.lang.String)
public void setName(java.lang.String name)
null
can result in
malformed HTML if the assignment string is not null
.name
- The new name.getName()
,
getName(StringBuffer)
public java.lang.String getAssignment()
setAssignment(java.lang.String)
public void getAssignment(java.lang.StringBuffer buffer)
buffer
- The buffer to place the assignment string in.getAssignment()
,
setAssignment(java.lang.String)
public void setAssignment(java.lang.String assignment)
null
will result in malformed HTML. In the case of a
null
, the value
should also be set to
null
.assignment
- The new assignment string.getAssignment()
,
getAssignment(StringBuffer)
public java.lang.String getValue()
getRawValue()
.null
if it's a stand-alone or
empty attribute, or the text if it's just a whitepace 'attribute'.setValue(java.lang.String)
public void getValue(java.lang.StringBuffer buffer)
buffer
- The buffer to place the value in.getValue()
,
setValue(java.lang.String)
public void setValue(java.lang.String value)
value
- The new value.getValue()
,
getValue(StringBuffer)
public char getQuote()
setQuote(char)
public void getQuote(java.lang.StringBuffer buffer)
buffer
- The buffer to place the quote in.getQuote()
,
setQuote(char)
public void setQuote(char quote)
value
needs to be quoted (i.e. contains
whitespace).quote
- The new quote value.getQuote()
,
getQuote(StringBuffer)
public java.lang.String getRawValue()
null
if it's a stand-alone attribute,
or the text if it's just a whitepace 'attribute'.setRawValue(java.lang.String)
public void getRawValue(java.lang.StringBuffer buffer)
buffer
- The string buffer to append the attribute value to.getRawValue()
,
setRawValue(java.lang.String)
public void setRawValue(java.lang.String value)
value
as the real value.
Otherwise, examine the string to determine if quotes are needed
and an appropriate quote character if so. This may involve changing
double quotes within the string to character references.value
- The new value.getRawValue()
,
getRawValue(StringBuffer)
public boolean isWhitespace()
true
if this attribute is whitespace,
false
if it is a real attribute.public boolean isStandAlone()
true
if this attribute is a standalone attribute.
false
if has an equals sign.public boolean isEmpty()
true
if this attribute is an empty attribute.
false
if has an equals sign and a value.public boolean isValued()
true
if this attribute has a value.
false
if it is empty or standalone.public int getLength()
public java.lang.String toString()
value name name= name=value name='value' name="value"
toString
在类中 java.lang.Object
public void toString(java.lang.StringBuffer buffer)
buffer
- The accumulator for placing the text into.toString()