SelectedHTMLReader


Represents a filter that filters the unselected text from an HTML stream.

Class of

netscape.plugin.composer.io package

Superclass

java.io.Reader

Description

Use this stream to speed up applications that only operate on selected text.

This table summarizes SelectedHTMLReader class methods:

Constructor Description
SelectedHTMLReader(
Reader)
Creates an instance of the SelectedHTMLReader class that is used for read-only operations
SelectedHTMLReader
(Reader, Writer)
Creates an instance of the SelectedHTMLReader class that is used for read-write operations
Method Description
close() Closes the input stream
read() Reads the input stream
read(char[]) Reads the input stream from a string buffer
read(char[],
int, int)
Reads input stream of specified length from specified place in the string buffer
skip(long) Skips specified number of bytes


See Also

Comment, Entity, JavaScriptEntity, LexicalStream, Tag, Text, Token, Reader

[Top] [IO Package Classes] [Composer Plug-in API Reference


Constructors


SelectedHTMLReader

Creates an instance of the SelectedHTMLReader class that is used for read-only operations.

Method of

SelectedHTMLReader class

Syntax

public SelectedHTMLReader(Reader in) throws IOException

Parameters

in
Stream to read from

Description

This method creates a stream that is used for read-only operations. It calls the two-argument constructor with a null output stream.

The SelectedHTMLReader method filters the input Reader object. It copies all the unselected text of the document from the input Reader object to the output stream. Only the selected text is passed along to the consumer of the SelectedHTMLReader object.

Throws

IOException

The Composer Plug-in API uses standard Java exceptions and exception handling. For more information, see your Java documentation.

[Top] [IO Package Classes] [Composer Plug-in API Reference


SelectedHTMLReader

Creates an instance of the SelectedHTMLReader class that is used for read-write operations.

Method of

SelectedHTMLReader class

Syntax

public SelectedHTMLReader(Reader in,
                          Writer out) throws IOException

Parameters

in
Stream to read from
out
Stream to write to. Can be null.

Description

This method creates a stream that is used for read-write operations. If the out parameter is supplied, all text outside of the HTML selection comments is automatically copied to the output stream.

Before the constructor returns, all the HTML text before the selection start comment is copied to the output stream.

Throws

IOException

The Composer Plug-in API uses standard Java exceptions and exception handling. For more information, see your Java documentation.

[Top] [IO Package Classes] [Composer Plug-in API Reference


Methods


close

Closes the input stream.

Method of

SelectedHTMLReader class

Syntax

public void close() throws IOException

Description

If an output stream was supplied to the constructor, any HTML text remaining in the input stream is flushed to the output stream. The output stream is not closed.

Overrides

This function overrides the close function in the Reader class.

[Top] [IO Package Classes] [Composer Plug-in API Reference


read

Reads the input stream.

Method of

SelectedHTMLReader class

Syntax

public int read() throws IOException

Description

All three forms of the read() function were implemented for the sake of completeness. For performance reasons, use read(char[],
int, int)
when possible.

Overrides

This function overrides the read function in the Reader class.

Throws

IOException

The Composer Plug-in API uses standard Java exceptions and exception handling. For more information, see your Java documentation.

[Top] [IO Package Classes] [Composer Plug-in API Reference


read

Reads the input stream from a string buffer.

Method of

SelectedHTMLReader class

Syntax

public int read(char buf[]) throws IOException

Parameters

buf[]
Text of input steam to read

Description

All three forms of the read() function were implemented for the sake of completeness. For performance reasons, use read(char[],
int, int)
when possible.

Overrides

This function overrides the read function in the Reader class.

Throws

IOException

The Composer Plug-in API uses standard Java exceptions and exception handling. For more information, see your Java documentation.

[Top] [IO Package Classes] [Composer Plug-in API Reference


read

Reads input stream of specified length from specified place in the string buffer.

Method of

SelectedHTMLReader class

Syntax

public int read(char buf[],
                int start,
                int length) throws IOException

Parameters

buf[]
Text of input steam to read
start
Place in buffer to start reading (offset)
length
Length, in bytes, of data to read

Description

Use this form of the function in preference to the others where possible for performance reasons. All three forms of this function were implemented for the sake of completeness.

Overrides

This function overrides the read function in the Reader class.

Throws

IOException

The Composer Plug-in API uses standard Java exceptions and exception handling. For more information, see your Java documentation.

[Top] [IO Package Classes] [Composer Plug-in API Reference


skip

Skips specified number of bytes.

Method of

SelectedHTMLReader class

Syntax

public long skip(long count) throws IOException

Parameters

count
Number of bytes to skip

Overrides

This function overrides the skip function in the Reader class.

Throws

IOException

The Composer Plug-in API uses standard Java exceptions and exception handling. For more information, see your Java documentation.

[Top] [IO Package Classes] [Composer Plug-in API Reference


Tag


Represents an HTML tag.

Class of

netscape.plugin.composer.io package

Superclass

netscape.plugin.composer.io.Token

Description

An HTML tag has a name, an open or close property, and zero or more attributes.

An HTML tag's attribute has a name and a value. If the value is the empty string, the attribute is printed as NAME; otherwise it is printed as NAME=VALUE.

This table summarizes Tag class methods:

Constructor Description
Tag(String) Creates an open instance of the Tag class
Tag(String,
boolean)
Creates an instance of the Tag class
Methods Description
addAttribute(
String, String)
Adds an attribute name and value pair to the tag
clearAttributes() Clears the existing attributes
clone() Clones the tag
containsAttribute(
String)
Tests whether this tag has a particular attribute
equals(Object) Performs an equality test
getAttributes() Gets an enumeration of the attributes of the current tag
getName() Gets the name of a tag
hasAttributes() Tests whether tag has attributes
hashCode() Computes a hash code
isClose() Gets the open/close state of the tag
isOpen() Gets the open/close state of the tag
lookupAttribute(String) Looks up the value associated with a given tag attribute
removeAttribute(String) Removes an attribute name and value pair from the tag
toString() Translates the Tag object into a string representation


See Also

Comment, Entity, JavaScriptEntity, LexicalStream, SelectedHTMLReader, Text, Token, Reader

[Top] [IO Package Classes] [Composer Plug-in API Reference


Constructors


Tag

Creates an open instance of the Tag class.

Method of

Tag class

Syntax

public Tag(String name)

Parameters

name
Name of the tag; automatically converted to uppercase

Description

This method always creates a new open tag. To create closed tags, use the constructor that takes a second Boolean parameter.

[Top] [IO Package Classes] [Composer Plug-in API Reference


Tag

Creates an instance of the Tag class.

Method of

Tag class

Syntax

public Tag(String name, boolean open)

Parameters

name
Name of the tag. Automatically converted to upper case.
open
true if this is an open tag.

Description

This method creates a new tag.

[Top] [IO Package Classes] [Composer Plug-in API Reference]


Methods


addAttribute

Adds an attribute name and value pair to the tag.

Method of

Tag class

Syntax

public String addAttribute(String name, String value)

Parameters

name
Name of the attribute; always converted to uppercase
value
Value of the attribute

Description

If the attribute already exists, addAttribute replaces and returns the old value.

[Top] [IO Package Classes] [Composer Plug-in API Reference


clearAttributes

Clears the existing attributes.

Method of

Tag class

Syntax

public void clearAttributes()

[Top] [IO Package Classes] [Composer Plug-in API Reference


clone

Clones the tag.

Method of

Tag class

Syntax

public Object clone()

Overrides

This function overrides the clone function in the Object class.

[Top] [IO Package Classes] [Composer Plug-in API Reference]


containsAttribute

Tests whether this tag has a particular attribute.

Method of

Tag class

Syntax

public boolean containsAttribute(String name)

Parameters

name
Attribute you are searching for; must be in uppercase

Returns

[Top] [IO Package Classes] [Composer Plug-in API Reference


equals

Tests whether this tag equals another tag, including the name and the attributes.

Method of

Tag class

Syntax

public boolean equals(Object other)

Parameters

other
Tag to test for equality

Returns

Overrides

This function overrides the equals function in the Object class.

[Top] [IO Package Classes] [Composer Plug-in API Reference


getAttributes

Gets an enumeration of the attributes of the current tag.

Method of

Tag class

Syntax

public Enumeration getAttributes()

Returns

An enumeration of the attributes of this tag.

[Top] [IO Package Classes] [Composer Plug-in API Reference


getName

Gets the name of a tag.

Method of

Tag class

Syntax

public String getName()

Returns

Name of the tag, always in uppercase.

[Top] [IO Package Classes] [Composer Plug-in API Reference


hasAttributes

Tests whether a tag has attributes.

Method of

Tag class

Syntax

public boolean hasAttributes()

Returns

An iterator over the attributes.

[Top] [IO Package Classes] [Composer Plug-in API Reference]


hashCode

Computes a hash code.

Method of

Tag class

Syntax

public int hashCode()

Returns

The hash code for the tag.

Overrides

This function overrides the hashCode function in the Object class.

[Top] [IO Package Classes] [Composer Plug-in API Reference]


isClose

Gets the open/close state of the tag.

Method of

Tag class

Syntax

public boolean isClose()

Returns

[Top] [IO Package Classes] [Composer Plug-in API Reference]


isOpen

Gets the open/close state of the tag.

Method of

Tag class

Syntax

public boolean isOpen()

Returns

[Top] [IO Package Classes] [Composer Plug-in API Reference


lookupAttribute

Looks up the value associated with a given tag attribute.

Method of

Tag class

Syntax

public String lookupAttribute(String name)

Parameters

name
Name of the attribute; must be in uppercase

Returns

The value of the attribute or null if the attribute does not exist.

[Top] [IO Package Classes] [Composer Plug-in API Reference


removeAttribute

Removes an attribute name and value pair from the tag.

Method of

Tag class

Syntax

public String removeAttribute(String name)

Parameters

name
Name of the attribute; must be in uppercase

Returns

The value of the attribute, or null if the attribute was not part of the tag.

[Top] [IO Package Classes] [Composer Plug-in API Reference


toString

Translates the Tag object into a string representation.

Method of

Tag class

Syntax

public String toString()

Returns

The HTML string representation of the tag

Overrides

This function overrides the toString function in the Object class.

[Top] [IO Package Classes] [Composer Plug-in API Reference


Text


Represents a token for the text of an HTML document.

Class of

netscape.plugin.composer.io package

Superclass

netscape.plugin.composer.io.Token

Description

This class extends Token, which is the base class for HTML tokens.

The HTML document contains text at its lowest level. The Text class represents a token for the text of an HTML document. Plug-ins can process text as Text class objects or as a set of HTML Token class objects. The approach you use depends upon the type of editing the plug-in needs to do. In most cases, tokens are more useful because they contain more information than text units and so make the developer's job easier.

This table summarizes Text class methods:

Constructor Description
Text(String) Creates an instance of the Text class from a given string
Methods Description
equals(Object) Performs an equality test
getText() Copies the text to the document
hashCode() Calculates the hash code for this object
isNewline() Checks for a newline character
setText(String) Places the text in the dialog box
toString() Converts the text to its HTML representation


See Also

Comment, Entity, JavaScriptEntity, LexicalStream, SelectedHTMLReader, Tag, Token, Reader

[Top] [IO Package Classes] [Composer Plug-in API Reference


Constructors


Text

Creates an instance of the Text class from a given string.

Method of

Text class

Syntax

public Text(String text)

Parameters

text
Text content of string

[Top] [IO Package Classes] [Composer Plug-in API Reference


Methods


equals

Checks for equality.

Method of

Text class

Syntax

public boolean equals(Object other)

Parameters

other
Text to test for equality

Returns

  • true: The text specified by other is the same as this text.
  • false: The text specified by other is not the same as this text.
  • Overrides

    This function overrides equals in the Object class.

    [Top] [IO Package Classes] [Composer Plug-in API Reference


    getText

    Copies the text in the dialog box to the document.

    Method of

    Text class

    Syntax

    public String getText()

    Parameters

    text
    Text to get from the dialog box

    Description

    This function copies the text in the dialog box and places that text in the document.

    Returns

    The copied text.

    [Top] [IO Package Classes] [Composer Plug-in API Reference


    hashCode

    Calculates the hash code for this object.

    Method of

    Text class

    Syntax

    public int hashCode()

    Returns

    The hash code for this object.

    Overrides

    This function overrides hashCode in the Object class.

    [Top] [IO Package Classes] [Composer Plug-in API Reference


    isNewline

    Checks whether the text is a solitary newline character.

    Method of

    Text class

    Syntax

    public boolean isNewline() 

    Returns

  • true: Text is a solitary newline character.
  • false: Text is not a solitary newline character.
  • [Top] [IO Package Classes] [Composer Plug-in API Reference


    setText

    Places the text in a dialog box.

    Method of

    Text class

    Syntax

    public void setText(String text)

    Parameters

    text
    Text to place in the dialog box.

    [Top] [IO Package Classes] [Composer Plug-in API Reference


    toString

    Converts the text to its HTML representation.

    Method of

    Text class

    Syntax

    public String toString()

    Returns

    The HTML representation of the text.

    Overrides

    This function overrides toString in the Object class.

    [Top] [IO Package Classes] [Composer Plug-in API Reference


    Token


    Represents an HTML token.

    Class of

    netscape.plugin.composer.io package

    Superclass

    java.lang.Object

    Description

    The Token class is the base class for HTML tokens. This class has no protocol of its own beyond its inheritance from Object. The Token class implements the Cloneable interface, which allows token objects to be cloneable. To learn more about this class, look at the classes derived from it:

    The HTML document contains text at its lowest level. Plug-ins can process text as Text class objects or as a set of HTML Token class objects. The approach you use depends upon the type of editing the plug-in needs to do. In most cases, tokens are more useful because they contain more information than text units and so make the developer's job easier.

    The Colorize and DocInfo samples, included in the Composer Plug-in Kit, deal with tokens.

    This table shows the Token class constructor, its only method:

    Constructor Description
    Token() Creates an instance of the Token class


    See Also

    Comment, Entity, JavaScriptEntity, LexicalStream, SelectedHTMLReader, Tag, Text, Reader

    [Top] [IO Package Classes] [Composer Plug-in API Reference


    Constructors


    Token

    Creates an instance of the Token class.

    Method of

    Token class

    Syntax

    public Token()

    [Top] [IO Package Classes] [Composer Plug-in API Reference]



    Copyright © 1997 Netscape Communications Corporation