Files

Overview

The Niagara Framework is built upon the fundamental principle that everything of interest is modeled as a BObject. Files are one of the most basic entities which are mapped into the object model.

The Niagara file model is a comprehensive architecture for mapping all files into a consistent set of APIs:

API

The javax.baja.file package provides the core APIs used for file access. There are three core concepts in the file model:

  1. BIFile: represents a file. In general file extensions are mapped to specific Types of BIFile using the registry. Effectively the Niagara Type wraps the MIME type. For example common file types include file:TextFile, file:XmlFile, file:ImageFile, file:WordFile. The "file" module contains mappings for common file extensions.
  2. BIFileStore: models a BIFile backing store. For example a file:TextFile might exist on the file system, in a zip file, or over a network. Each of these file storage mechanism reads and writes the file differently. There a BIFileStore for every BIFile which may be accessed via the BIFile.getStore() method. Common store types include baja:LocalFileStore, baja:MemoryFileStore, and baja:ZipFileEntry.
  3. BFileSpace: represents a set of files with a common storage model. BFileSpaces are responsible for resolving FilePaths into BIFiles. The prototypical file space is the singleton for local file system BFileSystem. The ord "local:|file:" always maps to BFileSystem.INSTANCE.

Mapping File Extensions

You can create custom file types for specific file extensions by following these rules: