multivalent
public abstract class MediaAdaptor extends Behavior implements Runnable
New media adaptors can be linked in with the core system by associating
a MIME Content-Type header and/or file suffix with the class name in
Preferences
.
Media adaptors by default display a document accurately, with perfect fidelity sacrificed only if very expensive to do so. Applications not requiring this can speed execution by declaring hints. For example, HINT_NO_IMAGE which suggests to a media adaptor that images won't be needed and so it can operate faster by not creating them. Media adaptors are free to ignore hints.
Parsing
MediaAdaptor ma = (MediaAdaptor)Behavior
Formatting ...
Painting on screen or image (java.awt.Graphics2D) ...
Examples: tool.ExtractText Often String toHTML() method defined.
Version: $Revision: 1.8 $ $Date: 2003/06/02 05:08:46 $
Field Summary | |
---|---|
URI | docURI |
static int | HINT_DEFAULTS By default all hints are off: display complete document with perfect fidelity. |
static int | HINT_EXACT
Require exact display no matter the computation cost.
|
static int | HINT_FAST Favor fast display at possible expense of some accuracy. |
static int | HINT_NO_DISPLAY Document tree will not be displayed (formatted or painted). |
static int | HINT_NO_IMAGE Results should not include images, so there is no need to create them. |
static int | HINT_NO_SHAPE Results should not include drawn shapes (rectangles, ellipses, splines). |
static int | HINT_NO_TEXT Results should not include text. |
static int | HINT_NO_TRANSCLUSIONS Do not incorporate transclusions. |
Method Summary | |
---|---|
void | buildAfter(Document doc) |
void | buildBefore(Document doc)
parse concrete document format and put into tree.
|
void | closeInputStream() |
int | getHints() |
protected InputStream | getInputStream() |
boolean | isAuthorized() |
boolean | isStopped() |
abstract Object | parse(INode parent)
Translate from a document's data format into a document tree,
with structure represented in internal nodes and content (text, images, video, ...) at the leaves.
|
static Object | parseHelper(String txt, String adaptor, Layer layer, INode parent)
It is recommended that media adaptors construct document trees that directly and fully represent the document format.
|
void | run() |
boolean | semanticEventAfter(SemanticEvent se, String msg)
On MSG_STOP, set stop flag, which subclass has to check for periodically. |
void | setHints(int hints) Set document tree construction hints for media adaptor to bit-wise OR of hint flags . |
void | setInputStream(InputStream is) Close media adaptor, freeing any resources. => Behavior.destroy
public void close() {
} |
void | setInputStream(String txt) |
void | setPassword(String pw) |
void | stop() |
Before using, invoke setInputStream. The newly constructed document tree should attach to parent. The parent is usually but not necessarily a Document. Paginated documents should build the current page only, as indicated by the attribute ATTR_PAGE, and report their page count to ATTR_PAGECOUNT. Metadata, such as author and dates, should be stored in the closed containing Document. If encountering an unfixable/unrecoverable parsing error, usually due to an invalid data format, throw a ParseException. (This does not supercede java.io.IOException.)
Subclasses should not rely on being able to obtain a Root, Browser, or Multivalent; in such cases it is acceptable to reduce functionality.
Returns: whatever Object is appropriate to the media adaptor. For HTML it is the root of the HTML tree (which has name "html"), for documents with no single root it can be parent, for an image constuctor it could be an java.awt.Image. However, the primary job of a media adaptor is to add content to the document tree.
See Also: for a convenient way to attach spans
hint flags
.