public class MutableContent extends Object
| Constructor and Description |
|---|
MutableContent(GadgetHtmlParser contentParser,
HttpResponse contentSource)
Construct with HttpResponse so we can defer string decoding until we actually need
the content.
|
MutableContent(GadgetHtmlParser contentParser,
String content)
Construct with decoded string content
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPipelinedData(String key,
Object value) |
void |
documentChanged()
Notification that the content of the document has changed.
|
String |
getContent()
Retrieves the current content for this object in String form.
|
InputStream |
getContentBytes()
Retrieves the current content for this object as an InputStream.
|
Document |
getDocument()
Retrieves the object contents in parsed form, if a
GadgetHtmlParser is configured and is able to parse the string
contents appropriately. |
int |
getNumChanges() |
Map<String,Object> |
getPipelinedData() |
protected byte[] |
getRawContentBytes() |
boolean |
hasDocument()
True if current state has a parsed document.
|
protected void |
incrementNumChanges() |
static void |
notifyEdit(Document doc) |
void |
setContent(String newContent)
Sets the object's content as a raw String.
|
void |
setContentBytes(byte[] newBytes)
Sets content to new byte array, with unspecified charset.
|
void |
setContentBytes(byte[] newBytes,
Charset newEncoding)
Sets the object's contentBytes as the given raw input.
|
protected void |
setContentBytesState(byte[] newBytes,
Charset newEncoding)
Sets internal state having to do with content bytes, from the provided
byte array and charset.
|
public MutableContent(GadgetHtmlParser contentParser, String content)
public MutableContent(GadgetHtmlParser contentParser, HttpResponse contentSource)
public static void notifyEdit(Document doc)
public String getContent()
getParseTree),
with subsequent edits and retrieval of String contents to avoid
repeated serialization and deserialization.
As a final fallback, if content has been set as bytes, interprets
them as a UTF8 String.public void setContent(String newContent)
newContent - New content.public InputStream getContentBytes()
protected byte[] getRawContentBytes()
public void setContentBytes(byte[] newBytes,
Charset newEncoding)
newBytes - New content.public final void setContentBytes(byte[] newBytes)
setContentBytes(byte[], Charset) API instead,
where possible.newBytes - New content.protected void setContentBytesState(byte[] newBytes,
Charset newEncoding)
newBytes - New content.newEncoding - Encoding for the bytes, or null for unspecified.public void documentChanged()
public Document getDocument()
GadgetHtmlParser is configured and is able to parse the string
contents appropriately. To modify the object's
contents by parse tree after setting new String contents,
this method must be called again. However, this practice is highly
discouraged, as parsing a tree from String is a costly operation and should
be done at most once per rewrite.public int getNumChanges()
protected void incrementNumChanges()
public boolean hasDocument()
Copyright © 2007-2012. All Rights Reserved.