|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.utexas.its.eis.tools.qwicap.template.xml.Markup edu.utexas.its.eis.tools.qwicap.template.xml.mutable.MutableMarkup
public final class MutableMarkup
MutableMarkup
represents a body of XML markup that can be altered. The markup represented may be an
entire XML document, or merely a self-contained fragment of XML. In either case, well-formedness is required to the
extent that all "start" tags must have matching "end" tags, and the "end" tags must be correctly ordered.
Constructor Summary | |
---|---|
MutableMarkup()
|
|
MutableMarkup(RangeList RangeList,
String CharacterSet)
|
Method Summary | |
---|---|
Match |
add(Match Source)
Add material at the end of this markup object. |
Match |
addAttribute(Match Target,
String AttrName,
Object AttrValue)
Adds an attribute to any markup element that is allowed to have attributes. |
Match |
addClass(Match Target,
String ClassList)
Adds one or more classes to the specified tag, converting the tag from immutable to mutable, if necessary. |
Match |
addContent(Match Target,
boolean InsertBeforeExistingContent,
Object NewContent)
Inserts the supplied material into the content of the specified markup element, provided that the element is a start-tag, or comment. |
void |
clear()
Remove all material from this markup object. |
MutableMarkup |
clone()
|
int |
convertSubmitButtonsToInputs()
Converts all "button" controls of type "submit" to "input" controls of type "submit", in order to work around a hideous bug in Internet Explorer (Windows and Mac OS). |
int |
convertSubmitInputsToButtons()
Converts all "input" controls of type "submit" that were "button" controls before convertSubmitButtonsToInputs() was invoked back into "button" controls of type "submit". |
Match |
createMatch(Range Element,
int ElemIndex)
|
void |
delete(Match Target)
Deletes the specified material from this markup. |
Match |
deleteAttribute(Match Target,
String AttrName)
Removes an attribute from this markup element. |
Match |
deleteClass(Match Target,
String ClassList)
Delete from this markup element all of the specified classes. |
Match |
deleteContent(Match Target)
Deletes the content of the specified markup element, provided that the element is a start-tag or comment. |
Match |
duplicate(Match Target,
boolean InsertDuplicateBeforeTarget)
Creates a duplicate of the specified material within this markup object and inserts it either immediately before, or after, the duplicated material. |
MutableMarkup |
embedFormDataSet(FormDataSet DataSet)
Searches the document for a form that could have supplied a specified form data set, and, if found, embeds the values from the data set into the form. |
MutableMarkup |
embedFormDataSetIfPossible(FormDataSet DataSet)
Searches the document for a form that could have supplied a specified form data set, and, if found, embeds the values from the data set into the form. |
int |
getChangeCount()
Returns a monotonically increasing integer which is incremented every time a modification is made to the markup list. |
String |
getCharacterSet()
Returns the name of the character set in which this markup was encoded when it was read. |
CSSPatterns |
getCSSPatterns(String PatsStr)
Retrieves a compiled version of the specified CSS pattern. |
Form |
getForm(FormDataSet DataSet)
Searches the document for a form that could have supplied a specified form data set, and returns a Form object for manipulating it. |
ImmutableMarkup |
getImmutable()
If this markup is already immutable, this method does nothing, and returns a reference to this object. |
RangeList |
getList()
This method is not part of the public API, but could not be hidden due to limitations in Java's access control system. |
MutableMarkup |
getMutable()
If this markup is already mutable, this method does nothing, and returns a reference to this object. |
static Characters |
htmlDecode(Characters PotentiallyEncodedStr)
Decodes a string such any HTML character entities in it are translated into corresponding Unicode characters. |
static boolean |
htmlDecode(Characters PotentiallyEncodedStr,
StringBuffer Buff)
Decodes a string such any HTML character entities in it are translated into corresponding Unicode characters. |
static boolean |
htmlDecode(Characters PotentiallyEncodedStr,
StringBuilder Buff)
Decodes a string such any HTML character entities in it are translated into corresponding Unicode characters. |
static String |
htmlDecode(String PotentiallyEncodedStr)
Decodes a string such any HTML character entities in it are translated into corresponding Unicode characters. |
static Characters |
htmlEncode(Characters RawStr)
Encodes a string such that it can be safely embedded in an XHTML document without risk of the document's syntax being corrupted, or the contents of the string being interpreted as XHTML markup (a potential security hole). |
static boolean |
htmlEncode(Characters RawStr,
StringBuffer Buff)
Encodes a string such that it can be safely embedded in an XHTML document without risk of the document's syntax being corrupted, or the contents of the string being interpreted as XHTML markup (a potential security hole). |
static boolean |
htmlEncode(Characters RawStr,
StringBuilder Buff)
Encodes a string such that it can be safely embedded in an XHTML document without risk of the document's syntax being corrupted, or the contents of the string being interpreted as XHTML markup (a potential security hole). |
static String |
htmlEncode(String RawStr)
Encodes a string such that it can be safely embedded in an XHTML document without risk of the document's syntax being corrupted, or the contents of the string being interpreted as XHTML markup (a potential security hole). |
Match |
insert(Match Target,
boolean InsertBefore,
Object NewStuff)
Inserts material into this markup before or after the element identified by the specified Match . |
Match |
replace(Match Target,
Object Replacement)
Replaces the specified material with other material. |
Match |
setAttribute(Match Target,
String AttrName,
Object AttrValue)
Replaces the value of an existing attribute, or creates a new attribute, in any markup element that is allowed to have attributes. |
MutableMarkup |
setCharacterSet(String CharSetName)
|
Match |
setClass(Match Target,
String ClassList)
|
Match |
setContent(Match Target,
Object NewContent)
Replaces any existing contents of the specified markup element with the supplied material. |
Match |
updateAttribute(Match Target,
String AttrName,
Object AttrValue)
Replaces the value of an existing attribute, but never creates a new attribute, in any markup element that is allowed to have attributes. |
Methods inherited from class edu.utexas.its.eis.tools.qwicap.template.xml.Markup |
---|
checkHierarchy, enumerate, first, get, get, get, getCDATA, getComments, getDeclarations, getMarkupName, isEmpty, iterator, print, setMarkupName, size, toString, write |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MutableMarkup()
public MutableMarkup(RangeList RangeList, String CharacterSet)
Method Detail |
---|
public MutableMarkup getMutable()
Markup
MutableMarkup
object are references to the immutable markup elements of the original
ImmutableMarkup
object, which makes the creation of the mutable copy of this markup extremely fast
and memory efficient. Only the elements that are eventually modified are converted into mutable forms, and that
conversion is performed both automatically, and transparently.
getMutable
in class Markup
public ImmutableMarkup getImmutable() throws TagException
Markup
getImmutable
in class Markup
TagException
- If an immutable form of this markup could not be made available.public MutableMarkup clone()
clone
in class Object
public String getCharacterSet()
Markup
getCharacterSet
in class Markup
public MutableMarkup setCharacterSet(String CharSetName) throws TagException
TagException
public CSSPatterns getCSSPatterns(String PatsStr)
Markup
getCSSPatterns
in class Markup
PatsStr
- A CSS2 selector pattern string. See
section 5.1 of the CSS2 specification for basic examples.
CSSPatterns
object that implements the request search pattern.public MutableMarkup embedFormDataSet(FormDataSet DataSet) throws QwicapException
DataSet
- A form data set produced by a form in this document. If null
, nothing
happens.
MutableMarkup
document (for convenience).
QwicapException
- If no form could be found in the document that could have supplied the specified form
data set.public MutableMarkup embedFormDataSetIfPossible(FormDataSet DataSet)
DataSet
- A form data set produced by a form in this document. If null
, nothing
happens.
MutableMarkup
document (for convenience).public Form getForm(FormDataSet DataSet) throws QwicapException
Form
object for manipulating it.
DataSet
- A form data set supplied by a form in this document.
Form
object that can be used to manipulate the relevant form.
FormNotFoundException
- If no form could be found in the document that could have supplied the specified
set of parameters.
QwicapException
Results.toForm()
public int convertSubmitButtonsToInputs() throws QwicapException
TagException
- If there was a problem with the markup manipulation.
QwicapException
public int convertSubmitInputsToButtons() throws QwicapException
convertSubmitButtonsToInputs()
was invoked back into "button" controls of type "submit". In other words,
this method undoes what convertSubmitButtonsToInputs()
does.
TagException
- If there was a problem with the markup manipulation.
QwicapException
public int getChangeCount()
Markup
MutableMatch
to detect changes
to the markup list that require them to re-verify the presence and location of the markup
elements they reference. Users of this method should detect changes by testing a cached
change count value for equality with the current change count value. Inequality means there's
been a change. No further assumptions about the values should be made.
getChangeCount
in class Markup
public RangeList getList()
Markup
List
object that stores all of the elements of this markup.
getList
in class Markup
List
object that stores all the elements in this markup. Do not
modify this List
.Markup.get(int Index)
public Match createMatch(Range Element, int ElemIndex)
createMatch
in class Markup
public void clear()
public Match add(Match Source)
Source
- The material to be added to this markup object.
public Match duplicate(Match Target, boolean InsertDuplicateBeforeTarget)
Target
- The materail within this markup object to be duplicated.InsertDuplicateBeforeTarget
- true
if the duplicate should be inserted before the original
material, or false
if it should be inserted after.
public Match replace(Match Target, Object Replacement)
Target
- The material to be replaced.Replacement
- The material to be added. See the insert
description for details on how
this object is handled.
public void delete(Match Target)
Target
- The material to be deleted.public Match addClass(Match Target, String ClassList) throws TagException
Target
- The tag to which the class is to be added.ClassList
- A space-separated list of classes to be added to the target tag.
TagException
- If there was a problem with the markup manipulation.public Match setClass(Match Target, String ClassList) throws TagException
TagException
public Match deleteClass(Match Target, String ClassList) throws TagException
Target
- The markup element.ClassList
- A space-separated list of class names.
TagException
- If there was a problem with the markup manipulation.public Match addAttribute(Match Target, String AttrName, Object AttrValue) throws TagException
setAttribute
method instead.
If the attribute name is "class", this method performs the same function as the addClass
method, but somewhat less efficiently.
Target
- The Match
object identifying the markup element on which this
method will operate.AttrName
- Name of the attribute.AttrValue
- Value of a new attribute, or the string to be appended to the value of an
existing attribute.
Match
object identifying this markup element. If this element was
immutable, a mutable version of it will have been created, substitued into this
markup (assuming the markup itself is mutable), and the Match
returned will refer to the new mutable form of this element.
TagException
- If there was a problem with the markup manipulation.public Match setAttribute(Match Target, String AttrName, Object AttrValue) throws TagException
setClass
method, but somewhat less efficiently.
Target
- The Match
object identifying the markup element on which this
method will operate.AttrName
- Name of the attribute.AttrValue
- Value of the attribute.
Match
object identifying this markup element. If this element was
immutable, a mutable version of it will have been created, substitued into this
markup (assuming the markup itself is mutable), and the Match
returned will refer to the new mutable form of this element.
TagException
- If there was a problem with the markup manipulation.public Match updateAttribute(Match Target, String AttrName, Object AttrValue) throws TagException
setClass
method, but somewhat less efficiently.
Target
- The Match
object identifying the markup element on which this
method will operate.AttrName
- Name of the attribute.AttrValue
- Value of the attribute.
Match
object identifying this markup element. If this element was
immutable, a mutable version of it will have been created, substitued into this
markup (assuming the markup itself is mutable), and the Match
returned will refer to the new mutable form of this element.
TagException
- If there was a problem with the markup manipulation.public Match deleteAttribute(Match Target, String AttrName) throws TagException
Target
- The Match
object identifying the markup element on which this
method will operate.AttrName
- Name of the attribute.
Match
object identifying this markup element. If this element was
immutable, a mutable version of it will have been created, substitued into this
markup (assuming the markup itself is mutable), and the Match
returned will refer to the new mutable form of this element.
TagException
- If there was a problem with the markup manipulation.public Match deleteContent(Match Target) throws TagException
Target
- The Match
object whose contents should be deleted.
Match
object identifying the markup element whose content should be deleted.
(Not the deleted material.)
TagException
- If there was a problem with the markup manipulation.public Match setContent(Match Target, Object NewContent) throws TagException
Target
- The Match
object identifying the markup element on which this
method will operate.NewContent
- The material that will replace this element's content. See
MutableMarkup.insert
for details.
Match
object identifying this markup element. (Not the inserted
material.)
TagException
- If there was a problem with the markup manipulation.public Match addContent(Match Target, boolean InsertBeforeExistingContent, Object NewContent) throws TagException
Target
- The Match
object identifying the markup element on which this
method will operate.InsertBeforeExistingContent
- true
if the new material should be inserted before the existing
content of this element, or false
if it should be inserted after
the existing content.NewContent
- The material that will be inserted before/after this element's content. See
MutableMarkup.insert
for details.
Match
object identifying the inserted material.
TagException
- If there was a problem with the markup manipulation.public Match insert(Match Target, boolean InsertBefore, Object NewStuff)
Inserts material into this markup before or after the element identified by the specified Match
. If the
element has children, and the insert is specified to take place after the element, the insertion is performed
immediately after the element's end tag. The material to be inserted may be represented by any type of object.
That object is handled according to the following rules:
String
, a new mutable content object is created to
represent the String
, and that object is inserted into this markup.
Match
, the markup element it represents, and any children of that element,
are inserted into this markup. The "Cloning Rule" applies here.
Results
, it is handled as if it were a sequence of Match
objects being inserted (see above).
Range
)
it is inserted into this markup. The "Cloning Rule" applies here.
Markup
, or any subclass thereof, every element in that Markup
is
inserted into this markup. The "Cloning Rule" applies here. Note, however, that because a
Match
object can reference only one markup element (and all of its children, by implication) the
Match
object returned by this method will reference only the first
element in the inserted material. So, if the inserted material includes more than one parent tag, only the first
parent and its children will be referenced by the Match
object that is returned. (If this limitation
ever becomes important, it can be fixed by having the high-level insert-related methods in the Results
class test for instances of Markup
, whereupon they would submit the top-level elements of the
Markup
as individual Match
objects.)
Throwable
, like the ever-popular class Exception
,
its message is inserted. If it does not have a message, the fully-qualified name of the Throwable
object's class is inserted. In either case, the Throwable
object's stack trace is then marked-up as an
XHTML comment block and inserted, so the end-user will not see it, but the developer can view the page source to
retrieve the stack trace.
Collection
or an array, the contents will be interated through, with each
element converted to a string, and commas inserted between elements. Whenever an element is found to be an array, or
a Collection
, the conversion process proceeds recursively, with the new material enclosed by brackets.
(The elements of byte
or Byte
arrays, will be displayed as unsigned decimal quantities. This
seemed like it would be more useful to most developers than displaying signed quantities.)
String
by
invoking its toString
method, and the rule for inserting String
objects is applied.
The Cloning Rule: No mutable element may exist more than once within a particular Markup
object. If an attempt is made to add a mutable element to markup in which it is already present, the element is
cloned, and the clone is added. (Note, by way of contrast, that the same mutable element is permitted to exist in
any number of Markup
objects, which is very efficient and convenient, but could lead to surprising
results if the element is modified.)
Target
- The location of the insert is relative to this element in this markup.InsertBefore
- If true
, the new material is inserted before the Target
element.
If false
, is inserted after Target
. If Target
has
children, the insert is performed after its end tag.NewStuff
- The new material to be inserted. Any type of object is potentially valid.
Match
object identifying the newly inserted material.public static String htmlEncode(String RawStr)
RawStr
- The string to be encoded.
public static String htmlDecode(String PotentiallyEncodedStr)
PotentiallyEncodedStr
- The string to be decoded.
public static Characters htmlEncode(Characters RawStr)
RawStr
- The string to be encoded.
public static Characters htmlDecode(Characters PotentiallyEncodedStr)
PotentiallyEncodedStr
- The string to be decoded.
public static boolean htmlEncode(Characters RawStr, StringBuffer Buff)
RawStr
- The string to be encoded.Buff
- The StringBuffer
to which the encoded string should be appended.
public static boolean htmlDecode(Characters PotentiallyEncodedStr, StringBuffer Buff)
PotentiallyEncodedStr
- The string to be decoded.Buff
- The StringBuffer
to which the decoded string should be appended.
public static boolean htmlEncode(Characters RawStr, StringBuilder Buff)
RawStr
- The string to be encoded.Buff
- The StringBuffer
to which the encoded string should be appended.
public static boolean htmlDecode(Characters PotentiallyEncodedStr, StringBuilder Buff)
PotentiallyEncodedStr
- The string to be decoded.Buff
- The StringBuffer
to which the decoded string should be appended.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |