Document


Represents an abstract HTML document.

Class of

netscape.plugin.composer package

Superclass

java.lang.Object

Description

The Document object is the HTML document upon which the Composer plug-in operates. A Document object contains HTML text and a work directory. You must place images and other embedded files you are inserting into the document in this directory.

The document's name is a relative URL (universal resource locator). The plug-in uses Document methods to find the URLs of the document and its work directory.

Document methods use Char streams to access document text. You do not subclass from this class.

This table summarizes Document class methods:

Constructor Description
Document() Creates an instance of the Document class
Methods Description
editDocument(String) Opens a URL for editing
getBase() Gets the base URL of the document
getDocumentURL() Gets the document URL (if known) for this document
getEventName() Gets the event that triggers this plug-in
getInput() Gets an input stream for a document
getOutput() Gets an output stream for a document
getText() Gets the entire raw HTML text of the document as a string
getWorkDirectory() Gets the work directory of the document
getWorkDirectoryURL() Gets the work directory of the document as a URL
redirectDocumentOpen(
String)
Redirects the edit event to a new document URL
setText(String) Sets the entire raw HTML text of the document


See Also

Factory, ImageEncoder, ImageEncoderFactory, Plugin

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


Constructor


Document

Creates an instance of the Document class.

Method of

Document class

Syntax

public Document()

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


Methods


editDocument

Opens a URL for editing.

Method of

Document class

Syntax

public static void editDocument(String url)

Parameters

url
String containing the URL to be edited

Description

You can use this method to programmatically open a URL for editing by the user. You do not have to call this method from within a Composer Plug-in; you can call it from any Java or JavaScript running in Communicator. editDocument operates asynchronously.

To see how this method works, see the EditHomePage sample.

Returns

This method returns no errors or status information.

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


getBase

Gets the base URL of the document.

Method of

Document class

Syntax

public abstract URL getBase()

Description

Any relative URLs included in the document are relative to its base URL.

Returns

The base URL of the document.

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


getDocumentURL

Gets the document URL (if known) for this document.

Method of

Document class

Syntax

public URL getDocumentURL()

Description

During a publish event or a save event, this method returns the URL of the destination to which the document is being published or saved.

Returns

The document URL (if it is known) for this document, or null if no document URL is available.

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


getEventName

Gets the event that triggers this plug-in.

Method of

Document class

Syntax

public String getEventName()

Description

This method gets the event that triggered this plug-in invocation. The standard events are:

For information about using this method and Composer Plug-in events, see "How Composer Plug-ins Handle Events."

Returns

The event that triggered the plug-in invocation, or null if this is a normal invocation. The event name is null when the plug-in is invoked from a menu (the Tools menu) rather than in response to an event.

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


getInput

Gets an input stream for a document.

Method of

Document class

Syntax

public abstract Reader getInput() throws IOException

Description

The input stream is used for reading information from the document. Before creating another input stream for the same document, the caller must finish with the stream and close it with the out.close method.

Use this method rather than getText if you plan to tokenize the raw HTML code of the document. Use getText if you want to perform string-based operations on the raw HTML code of the document.

Returns

An input stream for the document.

Throws

IOException

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

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


getOutput

Gets an output stream for a document.

Method of

Document class

Syntax

public abstract Writer getOutput() throws IOException

Description

You use this function to write information into a document. Before creating another output stream for the same document, the caller must finish with the stream and close it with the out.close method.

Use this method rather than setText if you are processing tokenized HTML. Use setText if you have performed string-based operations on the raw HTML code of the document.

Returns

An output stream for the document.

Throws

IOException

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

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


getText

Gets the entire raw HTML text of the document as a string.

Method of

Document class

Syntax

public abstract String getText() throws IOException

Description

This method reads information from a document and closes the output stream.

Use this method rather than getInput if you want to perform string-based operations on the raw HTML code of the document. Use getInput if you plan to tokenize the HTML.

Returns

The entire raw HTML text of the document as a string.

Throws

IOException

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

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


getWorkDirectory

Gets the work directory of the document.

Method of

Document class

Syntax

public abstract File getWorkDirectory()

Description

You need to know the work directory in order to add files to the document. Any files that you add to your document must be placed in its work directory.

Returns

The work directory for the document.

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


getWorkDirectoryURL

Gets the work directory of the document as a URL.

Method of

Document class

Syntax

public abstract URL getWorkDirectoryURL()

Description

You need this URL in order to add files to the document; files added to the document must be placed in this directory.

Returns

The work directory for the document as a URL.

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


redirectDocumentOpen

Redirects the edit event to a new document URL.

Method of

Document class

Syntax

public void redirectDocumentOpen(String newURL)

Parameters

newURL
URL, expressed as a string, to use to edit the document

Description

The plug-in substitutes the address specified in this method for that of the current document when the user clicks Edit on a web page. It opens the specified document rather than the current document.

This method is only meaningful when the event is edit. It can be useful when the publishing URL is different from the editing URL, for example, when you use an FTP server to access the backing store of an HTTP server.

To see how this method works, see the RedirectTest sample, which changes a request to edit pages from a web site into a request to edit pages from an FTP site.

Returns

An output stream for the document.

Throws

IOException

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

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


setText

Sets the entire raw HTML text of the document.

Method of

Document class

Syntax

public abstract void setText(String text) throws IOException

Parameters

text
The new entire raw HTML text of the document

Description

This method writes information into a document and closes the input stream.

Use this method rather than getOutput if you have performed string-based operations on the raw HTML code of the document. Use getOutput if you are processing tokenized HTML.

Returns

The entire raw HTML text of the document as a string.

Throws

IOException

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

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


Factory


Used to create plug-ins at runtime.

Class of

netscape.plugin.composer package

Superclass

java.lang.Object

Description

The Factory object is used for menu structure building. You can use a Factory class to create plug-ins at runtime.

When Netscape Composer starts up, it examines each plug-in file's netscape_plugin_composer.ini file to check whether it defines the property netscape.plugin.composer.Factory.

Most developers do not need to use this class; you can simply use the netscape.plugin.composer.classes property to name your plug-in classes directly. However, the Factory class provides additional flexibility. Here are some possible uses for a Factory class:

This table summarizes Factory class methods:

Constructor Description
Factory() Creates an instance of the Factory class
Method Description
getPlugins(File, Properties) Returns an enumeration of plug-ins


See Also

Document, ImageEncoder, ImageEncoderFactory, Plugin

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


Constructors


Factory

Creates an instance of the Factory class.

Method of

Factory class

Syntax

public Factory()

Description

A default constructor must be public to allow your class to be instantiated by name. Your class should be public, too, so that classes in other packages can have access to its methods.

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


Methods


getPlugins

Returns an enumeration of plug-ins.

Method of

Factory class

Syntax

public Enumeration getPlugins(File pluginFileName,
                              Properties properties)

Parameters

pluginFileName
Plug-in file to scan
properties Properties of the plug-in file to scan

Description

This method is responsible for creating and returning an array of plug-ins. By default, this method searches the netscape_plugin_composer.ini file for the property netscape.plugin.composer.classes, and creates one instance of each of the plug-in names in that string.

Returns

List of plug-ins to add to Composer.

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


Plugin


Allows arbitrary transformations of the Composer's current document.

Class of

netscape.plugin.composer package

Superclass

java.lang.Object

Description

All composer plug-ins extend the Plugin class. This class is like the Java Applet or Application classes, in that it is the main class of its program. A plug-in is instantiated when the first Composer window opens, and is deleted when the application exits.

When you write a plug-in, you must override the methods of the Plugin class. The perform method does the actual work of the plug-in. When a plug-in is invoked, its perform method is called with the current document, which it can examine and modify. The document can change arbitrarily between calls to perform. You may even be given two different documents on two successive calls to perform.

Three Plugin methods identify the plug-in in the user interface and allow menu access to it, including the plug-in name, category, and a hint message that shows up when the user moves the cursor over the plug-in name on the menu. If the plug-in is registered as a menu option plug-in, its name and category appear on the Tools menu of the Composer window after it is installed.

This table summarizes Plugin class methods:

Constructor Description
Plugin() Creates an instance of the Plugin class
Methods Description
getCategory() Gets the human readable category text of the plug-in
getHint() Gets the human readable hint text for the plug-in
getName() Gets the human readable name of the plug-in
perform(Document) Executes the plug-in


See Also

Document, Factory, ImageEncoder, ImageEncoderFactory

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


Constructors


Plugin

Creates an instance of the Plugin class.

Method of

Plugin class

Syntax

public Plugin()

Description

A default constructor must be public so that your plug-in can be instantiated by name. Your class should be public, too, so that classes in other packages can have access to its methods.

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


Methods


getCategory

Get the human readable category text of the plug-in.

Method of

Plugin class

Syntax

public String getCategory()

Description

The category is the title of the submenu that contains the plug-in on the Tools menu. The default is the name of the plug-in class. If several plug-ins have the same category, they all appear in the same menu.

In the user interface, categories collect plug-ins in groups that are meaningful to users. You can put all of your product's plug-ins into one category or you can place your plug-ins in several different ones. The sample plug-ins included with the Composer Plug-in Kit are assigned categories based on their functions.

Returns

The human readable category of the plug-in.

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


getHint

Gets the human readable hint text of the plug-in.

Method of

Plugin class

Syntax

public String getHint()

Description

The hint is a one-sentence description of what the plug-in does. The default is the name of the plug-in class. The hint appears in the status line as the user moves the cursor over the menu item that activates the plug-in.

Returns

The human readable hint for the plug-in.

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


getName

Gets the human readable name of the plug-in.

Method of

Plugin class

Syntax

public String getName()

Description

This is the name of the menu item that activates the plug-in on the Tools menu. The default is the name of the plug-in class.

Returns

The human readable name of the plug-in.

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


perform

Executes the plug-in.

Method of

Plugin class

Syntax

public boolean perform(Document document) throws IOException

Parameter

document The current document; the HTML document on which the plug-in is operating

Description

You override this method to perform most of the plug-in's work and to call other methods used by the plug-in. Use the overridden perform method to get the text from the document, analyze it, interact with the user, and modify the text.

Because the rest of the Composer user interface is held in a modal state while the plug-in is executing, consider finishing quickly or displaying a progress message to the user.

For information about preparing your plug-in's perform method so that you can test the plug-in in the Composer Testbed, see "Preparing for Running in the Testbed."

Returns

Throws

IOException

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

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


ImageEncoder


Extends the image file formats that Composer can write.

Class of

netscape.plugin.composer package

Superclass

java.lang.Object

Description

An image encoder is a special type of Composer Plug-in that encodes image data to match specific image formats, allowing you to increase the number of image file formats that Composer can write. An image encoder examines the input data, communicates with the user as necessary, and then writes the encoded image to the output stream.

Starting with Communicator 4.0, you can use image encoders to encode any kind of image that is natively supported by the Navigator, including JPEG, GIF, and XPM.

ImageEncoder is like the Composer plugin and Java Applet and Application classes, in that it is the main class of your program. This is where control passes from the Composer window to the plug-in.

The image encoder is built like a plug-in and shares its development issues. It differs from plug-ins in several ways. For more information and directions for writing and compiling image encoders, see "Writing and Using Image Encoders." To package and install image encoders, you follow the same procedures as for any Composer Plug-in.

This table summarizes ImageEncoder class methods:

Constructor Description
ImageEncoder() Creates an instance of the ImageEncoder class
Methods Description
encode(ImageProducer,
OutputStream)
Encodes the image
encoders() Returns a listing of the encoders currently loaded into Communicator
getFileExtension() Gets the standard file extension of the image format
getFileType(byte[]) Gets the Mac OS file type of the image format
getHint() Gets the human readable hint text for the image encoder
getName() Gets the human readable name of the image encoder
needsQuantizedSource() Finds whether the source image should be quantized (reduces the number of required bits per pixel)
register(ImageEncoder) Used to register an encoder with the system


See Also

ImageEncoderFactory, Plugin

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


Constructor


ImageEncoder

Creates an instance of the ImageEncoder class.

Method of

ImageEncoder class

Syntax

public ImageEncoder()

Description

A default constructor must be public to allow your image encoder to be instantiated by name. Your class should be public, too, so that classes in other packages can have access to its methods.

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


Methods


encode

Encodes the image.

Method of

ImageEncoder class

Syntax

public boolean encode(ImageProducer source,
                      OutputStream output) throws IOException

Parameters

source
The image to encode.
output Output stream to which to write the encoded information.

Description

Override this method to perform the bulk of the image encoder's work. In this method, the image encoder reads the image information from the image source, interacts with the user, and writes the encoded information to the output stream.

ImageEncoder.encode corresponds to Plugin.perform, in that this method performs the work of the image encoder.

Returns

Throws

IOException

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

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


encoders

Returns an enumeration of all the encoders currently loaded into Communicator.

Method of

ImageEncoder class

Syntax

public static Enumeration encoders()

Description

Your plug-in can call this method to get all the encoders currently loaded into Communicator. From this list, the user can choose an encoder and call its encode method.

Returns

An enumeration of all the encoders currently loaded into Communicator.

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


getFileExtension

Gets the standard file extension of the image encoder.

Method of

ImageEncoder class

Syntax

public String getFileExtension()

Description

This method gets the standard file extension of the image format, not including the period. Communicator uses the file extension to determine the MIME type of the file.

Returns

The human readable category for the image encoder or an empty string (default).

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


getFileType

Mac OS only

Gets the Mac OS file type of the image format.

Method of

ImageEncoder class

Syntax

public void getFileType(byte type[])

Parameters

type
Four-byte array for the file type of the image format.

Description

Like the MIME type, the Mac OS file type is a way of specifying the type of a file. The MIME type is operating system independent, while the Mac OS file type is specific to the Mac OS. An image encoder does not require a MIME type because the file extension returned from getFileExtension is used to determine the MIME type.

To run on the Mac OS, an image encoder must implement getFileType. For more information about FileType, refer to your Apple Developer Technical Support or the Apple Macintosh OS documentation.

Returns

Mac OS file type of the image format or '????' (default).

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


getHint

Gets the human readable hint text for the image encoder.

Method of

ImageEncoder class

Syntax

public String getHint()

Description

The hint is a one-sentence description of what the image encoder does. This text shows up in the status line as the user moves the cursor over the image encoder's menu name.

Returns

The human readable hint for the image encoder or the name of the image encoder class (the default).

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


getName

Gets the human readable name of the image encoder.

Method of

ImageEncoder class

Syntax

public String getName()

Description

This is the name of the menu item that activates the image encoder on the Tools menu. The default is the name of the image encoder class.

Returns

The human readable name of the image encoder.

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


needsQuantizedSource

Finds whether the source image should be quantized.

Method of

ImageEncoder class

Syntax

public Boolean needsQuantizedSource()

Description

This method determines whether the source image should be quantized before it is passed to encode. Quantizing reduces the number of required bits per pixel from 24 to 8 bits per pixel (reduces distinct colors in the document to 256 or fewer), and is used when image formats require a lower number of bits/colors.

If this method returns true, then the source image is quantized to contain 256 or fewer distinct colors. If you want to use a specific quantization technique, or if you want to make quantization an option for the user, then you should return false from this method and supply your own quantization code.

Returns

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


register

Registers an encoder with the system.

Method of

ImageEncoder class

Syntax

public static void register(ImageEncoder encoder);

Parameters

encoder
The encoder to register.

Description

Registering an encoder makes it available for any program to use.

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


ImageEncoderFactory


Used to create image encoders at runtime.

Class of

netscape.plugin.composer package

Superclass

netscape.plugin.composer.ImageEncoderFactory

Description

When Composer starts up, it examines each plug-in's netscape_plugin_composer.ini file to see whether it defines the property netscape.plugin.composer.ImageEncoderFactory. If so, Composer assumes that the value of that property is the name of a class derived from ImageEncoderFactory. It instantiates that class, and its getImageEncoders method is called. This method creates and returns an enumerator of image encoders.

Most developers do not need to use the ImageEncoderFactory class. They can simply use the netscape.plugin.composer.ImageEncoder.classes property to name their ImageEncoder classes directly. However, the ImageEncoderFactory class provides additional flexibility. Here are some possible uses for an ImageEncoderFactory class:

This table summarizes ImageEncoderFactory class methods:

Constructor Description
ImageEncoderFactory() Creates an instance of the ImageEncoderFactory class
Method Description
getImageEncoders(
File, Properties)
Returns an enumeration of plug-ins


See Also

Document, Factory, ImageEncoder, Plugin

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


Constructor


ImageEncoderFactory

Creates an instance of the ImageEncoderFactory class.

Method of

ImageEncoderFactory class

Syntax

public ImageEncoderFactory()

Description

A default constructor must be public to allow the image encoder to be instantiated by name. Also, the image encoder factory class should be public so that classes in other packages can have access to its methods.

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


Method


getImageEncoders

Returns an enumeration of plug-ins.

Method of

ImageEncoderFactory class

Syntax

public Enumeration getImageEncoders(File pluginFileName,
                                    Properties properties)

Parameters

pluginFileName
Plug-in file to scan.
properties Properties of the plug-in file to scan.

Description

This function searches the properties for the property netscape.plugin.composer.ImageEncoder.classes and creates one instance of each of the plug-in names in that string.

Returns

A list of image encoders to add to the Composer.

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



Copyright © 1997 Netscape Communications Corporation