com.webrenderer.swing.dom
Interface IDocument


public interface IDocument

A class to store information about and provide access to the Document object.

A Document class can be retrieved by calling getDocument() on an IBrowserCanvas after the current page has loaded. The current page has finished loading when the NetworkEvent onDocumentComplete has fired.

This class allows access to the underlying Document Object Model of a Webpage

See Also:
NetworkListener

Method Summary
 void addScrollPositionListener(ScrollPositionListener listener)
          Add a ScrollPositionListener to this document.
 void close()
          Deprecated. This method is not implemented.
 IElement createElement(String name)
          Creates an instance of the element for the specified tag.
 IRange createRange()
          Returns an empty Range object that is tied to the current document.
 void deleteSelectedText()
          Deletes the current selected text.
 IElement elementFromPoint(long x, long y)
          Gets the element object located at coordinate (x, y) on the document.
 boolean equals(IDocument element)
          Compares with another IDocument.
 void execCommand(String cmd, boolean showUI, String value)
          Executes a command on the current document with specified value.
 IElement getActiveElement()
          Gets the object that has the focus when the parent document has focus.
 String getAlinkColour()
          Gets the colour of all active links in the document.
 IElementCollection getAll()
          Gets an interface pointer to a zero-based collection of all the elements in the HTML document.
 IElementCollection getAnchors()
          Gets an interface pointer to a zero-based collection of all the anchors in an HTML document.
 IElementCollection getApplets()
          Gets an interface pointer to a zero-based collection of all the applet objects in an HTML document.
 String getBgColour()
          Gets a value that indicates the background color behind the object.
 IElement getBody()
          Gets the document's body object.
 String getCharSet()
          Gets the character set used to encode the object.
 IDocument[] getChildFrames()
          Gets the child frames of a document.
 String getCookie()
          Gets the string value of a cookie.
 String getDocumentSource()
          Gets the unmodified source for the document.
 String getDomain()
          Gets the security domain of the document.
 IElement getElementById(String iD)
          Returns the IElement with specified ID or null if no element exists with that ID
 IElementCollection getEmbeds()
          Gets an interface pointer to a zero-based collection of all the embed objects in an HTML document.
 String getFgColour()
          Gets the foreground (text) colour of the document.
 String getFileModifiedDate()
          Deprecated. This method is not implemented.
 IElementCollection getForms()
          Gets an interface pointer to a zero-based collection of all the form objects in an HTML document.
 IElementCollection getImages()
          Gets a collection of images in a document.
 String getLinkColour()
          Gets the colour of the document links.
 IElementCollection getLinks()
          Gets an interface pointer to a zero-based collection of all the link and area objects in an HTML document.
 String getReferrer()
          Gets the referrer URL.
 String getSelectedText()
          Returns the active text selection in the document.
 IRange getSelectionAsRange()
          Returns a Range object that is constructed from the current selection.
 IStyleSheet[] getStyleSheets()
          Get the styleSheets on the document.
 String getTitle()
          Gets the title of the document.
 String getURL()
          Deprecated. This method is not implemented.
 String getVlinkColour()
          Gets the colour of the links that the user has visited.
 void open()
          Deprecated. This method is not implemented.
 void putAlinkColour(String col)
          Sets the colour of all active links in the document.
 void putBgColour(String col)
          Sets the value that indicates the background colour of the document.
 void putCookie(String cookie)
          Sets the String value of a cookie
 void putFgColour(String col)
          Sets the foreground (text) colour of the document.
 void putLinkColour(String col)
          Sets the colour of links in the document.
 void putTitle(String title)
          Sets the title of the document.
 void putVlinkColour(String col)
          Sets the colour in which visited links are displayed.
 void removeScrollPositionListener(ScrollPositionListener listener)
          Remove a scrollPositionListener from this Document.
 void scrollTo(long x, long y)
          Scroll this Document to given x,y position.
 String toString()
          Gets a string representation of the object.
 void write(String data)
          Deprecated. This method is not implemented.
 void writeln(String data)
          Deprecated. This method is not implemented.
 

Method Detail

getActiveElement

IElement getActiveElement()
Gets the object that has the focus when the parent document has focus. If this is called on an MozillaBrowserCanvas it will only get focusable elements, as Mozilla has no concept of an active element.

Returns:
the active element.

getAlinkColour

String getAlinkColour()
Gets the colour of all active links in the document.

Returns:
the colour of active links.

putAlinkColour

void putAlinkColour(String col)
Sets the colour of all active links in the document.

Parameters:
col - the colour of active links.

getAll

IElementCollection getAll()
Gets an interface pointer to a zero-based collection of all the elements in the HTML document.

Returns:
a collection of elements in the document.

getAnchors

IElementCollection getAnchors()
Gets an interface pointer to a zero-based collection of all the anchors in an HTML document. The elements are in the same order as they appear in the document.

Returns:
collection of objects representing anchors in document.

getApplets

IElementCollection getApplets()
Gets an interface pointer to a zero-based collection of all the applet objects in an HTML document. The objects are in the same order as they appear in the document.

Returns:
collection of objects representing applets in document.

getBgColour

String getBgColour()
Gets a value that indicates the background color behind the object.

Returns:
background color.

putBgColour

void putBgColour(String col)
Sets the value that indicates the background colour of the document.

Parameters:
col - background colour of the document.

getBody

IElement getBody()
Gets the document's body object.

Returns:
reference to the document body.

getCharSet

String getCharSet()
Gets the character set used to encode the object.

Returns:
character set used to encode the object.

close

void close()
Deprecated. This method is not implemented.

Closes an output stream and forces the sent data to display.


getCookie

String getCookie()
Gets the string value of a cookie.

Returns:
cookie

putCookie

void putCookie(String cookie)
Sets the String value of a cookie

Parameters:
cookie - value of cookie

createElement

IElement createElement(String name)
Creates an instance of the element for the specified tag.

Parameters:
name - tag

getDomain

String getDomain()
Gets the security domain of the document.

Returns:
Security domain.

elementFromPoint

IElement elementFromPoint(long x,
                          long y)
Gets the element object located at coordinate (x, y) on the document.

Parameters:
x - X-coordinate.
y - Y-coordinate.
Returns:
The element at the specified coordinate.

getEmbeds

IElementCollection getEmbeds()
Gets an interface pointer to a zero-based collection of all the embed objects in an HTML document. The objects are in the same order as they appear in the document.

Returns:
Collection of embed objects.

getFgColour

String getFgColour()
Gets the foreground (text) colour of the document.

Returns:
Foreground colour of the document.

putFgColour

void putFgColour(String col)
Sets the foreground (text) colour of the document.

Parameters:
col - Foreground colour of the document.

getFileModifiedDate

String getFileModifiedDate()
Deprecated. This method is not implemented.

Gets the date the file was last modified.

Returns:
File last-modification date.

getForms

IElementCollection getForms()
Gets an interface pointer to a zero-based collection of all the form objects in an HTML document. The objects are in the same order as they appear in the document.

Returns:
Collection of form objects in document.

getChildFrames

IDocument[] getChildFrames()
Gets the child frames of a document. If this is a frameset document returns the child frames in an array, otherwise returns null.

Returns:
An array of IDocuments for the child frames

getImages

IElementCollection getImages()
Gets a collection of images in a document. Gets a pointer to the HTMLElementCollection interface of the zero-based collection of all the images in an HTML document. The images are in the same order as they appear in the document.

Returns:
Collection of images.

getLinkColour

String getLinkColour()
Gets the colour of the document links.

Returns:
Colour of the document links.

putLinkColour

void putLinkColour(String col)
Sets the colour of links in the document.

Parameters:
col - Colour of the links.

getLinks

IElementCollection getLinks()
Gets an interface pointer to a zero-based collection of all the link and area objects in an HTML document. The objects are in the same order as they appear in the document.

Returns:
Collection of link and area objects in document.

getReferrer

String getReferrer()
Gets the referrer URL.

Returns:
the URL of the location that referred the user to the current page.

getStyleSheets

IStyleSheet[] getStyleSheets()
Get the styleSheets on the document.

Returns:
array of stylesheets on the document.

getTitle

String getTitle()
Gets the title of the document. The title identifies the contents of the document and is displayed in the header bar of the document window.

Returns:
Title of the document.

putTitle

void putTitle(String title)
Sets the title of the document.

Parameters:
title - The title of the document.

toString

String toString()
Gets a string representation of the object.

Overrides:
toString in class Object
Returns:
String representation.

getURL

String getURL()
Deprecated. This method is not implemented.

Gets the URL for the current document.

Returns:
URL of document.

getVlinkColour

String getVlinkColour()
Gets the colour of the links that the user has visited.

Returns:
Colour of the links.

putVlinkColour

void putVlinkColour(String col)
Sets the colour in which visited links are displayed.

Parameters:
col - Colour of the links.

open

void open()
Deprecated. This method is not implemented.

Opens a document to collect the output of the write and writeln methods.


write

void write(String data)
Deprecated. This method is not implemented.

Writes one or more HTML expressions to a document in the specified window.

Parameters:
data - HTML expression.

writeln

void writeln(String data)
Deprecated. This method is not implemented.

Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window.

Parameters:
data - HTML expression.

getSelectedText

String getSelectedText()
Returns the active text selection in the document.

Returns:
Selected text.

createRange

IRange createRange()
Returns an empty Range object that is tied to the current document.

Returns:
Empty Range Object

getSelectionAsRange

IRange getSelectionAsRange()
Returns a Range object that is constructed from the current selection.
If no selection is currently made on this document, null is returned.

Returns:
Range object made from current selection.

getElementById

IElement getElementById(String iD)
Returns the IElement with specified ID or null if no element exists with that ID

Parameters:
iD - ID of element.
Returns:
Element with given ID

equals

boolean equals(IDocument element)
Compares with another IDocument.

Parameters:
element - IDocument to compare
Returns:
true if IDocuments are the same.

addScrollPositionListener

void addScrollPositionListener(ScrollPositionListener listener)
Add a ScrollPositionListener to this document.

Parameters:
listener - The ScrollPositionListener to add.

removeScrollPositionListener

void removeScrollPositionListener(ScrollPositionListener listener)
Remove a scrollPositionListener from this Document.

Parameters:
listener - The ScrollPositionListener to remove.

scrollTo

void scrollTo(long x,
              long y)
Scroll this Document to given x,y position.

Parameters:
x - coordinate.
y - coordinate.

execCommand

void execCommand(String cmd,
                 boolean showUI,
                 String value)
Executes a command on the current document with specified value.
Some common commands include:
  • "Bold" - Toggles the current selection between bold and nonbold.
    E.g. doc.execCommand("Bold",false,"");
  • "FontName" - Sets the font for the current selection.
    E.g. doc.execCommand("Font",false,"Arial");
  • "FontSize" - Sets the font size for the current selection. (This value must be between 1 and 7, inclusive).
    E.g. doc.execCommand("FontSize",false,"3");
  • "ForeColor" - Sets the foreground(text) color of the current selection.
    E.g. doc.execCommand("ForeColor",false,"red");
  • "Italic" - Toggles the current selection between italic and nonitalic.
    E.g. doc.execCommand("Italic",false,"");
  • "Underline" - Toggles the current selection between underlined and not underlined.
    E.g. doc.execCommand("Underline",false,"");

See http://msdn.microsoft.com/workshop/author/dhtml/reference/commandids.asp for a complete list of commands.

Parameters:
cmd - The command to execute.
showUI - if set to true, display a user interface if the command supports one.
value - the value to assign.

getDocumentSource

String getDocumentSource()
Gets the unmodified source for the document. Use getChildFrames to get frames documents to get their source.

Returns:
Source of document.

deleteSelectedText

void deleteSelectedText()
Deletes the current selected text.