Stylus Studio File System Java API

 

The Stylus Studio File System Java API is available only in Stylus Studio XML Professional Edition.

The Stylus Studio File System Java API is a set of interfaces that allows you to

  • Create and register your own custom file systems
  • Programmatically call an adapter to convert a file from one format to another using Stylus Studio's built-in converters, or converters you define using the Convert to XML module

This section provides an overview of the Stylus Studio File System Java API and describes how to create and register a custom file system. It assumes knowledge of Java programming principles and procedures.

In this section

This section covers the following topics:

For more information

To learn how to use the Stylus Studio File System Java API to programmatically call an adapter, see Invoking an Adapter Programmatically.

Overview

The Stylus Studio File System Java API consists of the following classes, summarized in Table 74.

Class
Description
StylusFile
Public interface that provides an abstract representation of a file in a custom file system.
StylusFileFactory
Public final class that defines a factory API that enables applications to read and write data streams using any file system that implements the StylusFile interface.
StylusFileHelpers
Public class of static helpers for use with StylusFile and StylusFileSystem interfaces and the StylusFile class.
StylusFileSystem
Public interface that represents a custom file system, enabling you to connect to and and browse files on that file system.
StylusFileSystemOptions
Public interface that provides optional methods
Table 74. File System Java API Classes

These files are packaged in CustomFileSystem.jar, which is in the Stylus Studio \bin directory.

Javadoc for the Stylus Studio File System Java API

Javadoc for the Stylus Studio File System Java API is installed with Stylus Studio. It is available in the Stylus Studio /doc/Javadoc directory. Open index.html to get started. The Javadoc is also available on the Stylus Studio Web site, www.stylusstudio.com.

Custom File Systems

A file system is view that represents information as a series of files in at least one folder or directory. An individual file within that file system - such as an XML document, an XQuery program, or a DTD - can contain any text or binary information.

A custom file system is a way to extend the file/folder metaphor beyond traditional disk-based files (accessed with the file: scheme), and even beyond web-based files (WebDAV's http: and https:, and the ftp: scheme of the file transfer protocol) for example. Stylus Studio supports several standard and custom file systems, including Windows, WebDAV, and FTP.

These file systems are referred to as "custom" because, although some are packaged with Stylus Studio, you can create your own. For example, you could create an LDAP custom file system to query an LDAP directory as if it were a file system.

There is a Java API that allows you to access the custom file interface in Stylus Studio.

Tip

 

The Stylus Studio interface to Sleepycat Software's Berkeley DB XML was implemented using the File System Java API to create a custom file system.

Creating a Custom File System

The process of creating a custom file system in Stylus Studio involves two main steps:

1. Use the Stylus Studio File System Java API, create the Java wrapper class for your data source. See File System Interfaces for more information on this step.
2. Register the finished custom file system with Stylus Studio, to make it available through the Stylus Studio Open, Save, and Save As dialog boxes, as shown in Figure 332. See Registering a Custom File System for more information on this step.

Figure 332. Custom File System Registered with Stylus Studio

File System Interfaces

The Stylus Studio file system interfaces are packaged in CustomFileSystem.jar, in the Stylus Studio \bin directory. To define a custom file system, you implement these interfaces:

  • com.exln.stylus.io.StylusFile, and
  • com.exln.stylus.io.StylusFileSystem

Once you have implemented the interfaces, compile them into your own .jar file ( myCustomFileSystem.jar, for example), and register the custom file system with Stylus Studio.

Examples

Implementation examples of the StylusFileSystem and StylusFile interfaces, JavaFileSystem.java and JavaFile.java, are included in the \examples\CustomFileSystem directory where you installed Stylus Studio.

Registering a Custom File System

Before you begin

This section assumes you have already implemented the custom file system interfaces, compiled, and created a .jar file ( myFileSystem.jar, for example.). You cannot complete the registration process unless the custom file system has been created.

In this section

This section covers the following topics:

The Custom File Systems Page

You use the Custom File Systems page of the Options dialog box to register a custom file system.

Figure 333. Options Dialog Box for Custom File Systems

How to Display

To display the Custom File Systems page:
1. In the Stylus Studio menu bar, select Tools > Options.

The Options dialog box appears.

2. If necessary, expand Application Settings and click Custom File Systems.

The Custom File Systems page appears.

Fields

The Custom File Systems page of the Options dialog box has the following fields which you need to specify values for in order to register your custom file system.

Name

When you click the New button ( ) to create a new custom file system, Stylus Studio displays an entry field for the name.

Figure 334. Naming a New Custom File System

You should replace the default name ( FileSystem1, for example) with the name you want to associate with the custom file system. The name you enter is displayed in Stylus Studio Open, Save, and Save As dialog boxes.

Classpath

You use the Classpath field to specify the required classpath for the custom file system.

Class name

You use the Class name field to specify the name of the custom file system class created using the Stylus Studio custom file system Java API. If you use the Browse button, Stylus Studio filters the files displayed in the Java Class Browser dialog box to show only those classes that implement the CustomFileSystem.jar interfaces.

Icon bitmap

You use the Icon bitmap field to specify the icon to associate with the custom file system. This icon appears in the Open, Save, and Save As dialog boxes. If the Icon bitmap field is left empty, Stylus Studio uses a default icon ( ).

How to Register a Custom File System

To register a custom file system:
1. Display the Custom File Systems page of the Options dialog box. See How to Display if you need help with this step.
2. Click the New button and enter a name for the custom file system. Remember that this value appears in the Open, Save, and Save As dialog boxes along with the icon you select.
3. Specify the classpath and class name.
4. Optionally, specify the icon you want to use to represent the custom file system.
5. Click OK.
 
Free Stylus Studio XML Training: