com.lizardtech.djvu
Class DjVmDir

java.lang.Object
  extended by com.lizardtech.djvu.DjVuObject
      extended by com.lizardtech.djvu.DjVmDir
All Implemented Interfaces:
Codec, DjVuInterface, java.lang.Cloneable

public final class DjVmDir
extends DjVuObject
implements java.lang.Cloneable, Codec

This class represents an index structure for bundled and indexed documents.

Version:
$Revision: 1.3 $
Author:
Bill C. Riemers

Nested Class Summary
static class DjVmDir.File
          This class stores the details about a single page of include file within a document.
 
Field Summary
static int version
          The version of this class.
 
Fields inherited from class com.lizardtech.djvu.DjVuObject
hasReferences
 
Constructor Summary
DjVmDir()
          Creates a new DjVmDir object.
 
Method Summary
 java.lang.Object clone()
          Create a copy by value of this instance.
static DjVmDir createDjVmDir(DjVuInterface ref)
          Creates an instance of DjVmDir with the options interherited from the specified reference.
 DjVmDir.File createFile()
          Create a new instance of DjVmDir.File
 DjVmDir.File createFile(java.lang.String load_name, java.lang.String save_name, java.lang.String title, int file_type)
          Create a new instance of DjVmDir.File
 void decode(DataPool pool)
          Called to decode the data source and initialize this index.
 void delete_file(java.lang.String id)
          Called to remove the named file from the index.
 int get_file_pos(DjVmDir.File f)
          Called to find the position of a File in the list
 java.util.Vector get_files_list()
          Query the file list.
 int get_files_num()
          Query the size of the file list
 int get_page_pos(int page_num)
          Query the position of a page in the list
 int get_pages_num()
          Query the number of pages in the index.
 DjVmDir.File get_shared_anno_file()
          Query the document shared annotation
 java.net.URL getInitURL()
          Get the top level URL used to initialize this document.
 int getPageno(java.lang.String url)
          Convert a relative url to a page number.
 DjVmDir.File id_to_file(java.lang.String id)
          Called to map an id to a File.
 int insert_file(DjVmDir.File file)
          Called to add a file to the index.
 int insert_file(DjVmDir.File file, int pos_num)
          Called to add a file to the index.
 boolean is_bundled()
          Query if the index is for a bundled document.
 boolean is_indirect()
          Query if the index is for an indirect document.
 boolean isImageData()
          Query if this is image data.
 DjVmDir.File name_to_file(java.lang.String name)
          Query the File mapped to name.
 DjVmDir.File page_to_file(int page_num)
          Query the File mapped to the specified page number.
 void set_file_name(java.lang.String id, java.lang.String name)
          Set the filename corresponding to an id.
 void set_file_title(java.lang.String id, java.lang.String title)
          Set the title corresponding to an id.
 void setInitURL(java.net.URL url)
          Set the top level URL used to initialize this document.
 DjVmDir.File title_to_file(java.lang.String title)
          Find the DjVmDir.File with the specified title.
 
Methods inherited from class com.lizardtech.djvu.DjVuObject
checkLockTime, create, create, createSoftReference, createWeakReference, getDjVuOptions, getFromReference, invoke, setDjVuOptions
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.lizardtech.djvu.DjVuInterface
getDjVuOptions, setDjVuOptions
 

Field Detail

version

public static final int version
The version of this class.

See Also:
Constant Field Values
Constructor Detail

DjVmDir

public DjVmDir()
Creates a new DjVmDir object.

Method Detail

createDjVmDir

public static DjVmDir createDjVmDir(DjVuInterface ref)
Creates an instance of DjVmDir with the options interherited from the specified reference.

Parameters:
ref - Object to interherit DjVuOptions from.
Returns:
a new instance of DjVmDir.

isImageData

public boolean isImageData()
Query if this is image data.

Specified by:
isImageData in interface Codec
Returns:
false

setInitURL

public void setInitURL(java.net.URL url)
Set the top level URL used to initialize this document.

Parameters:
url - DOCUMENT ME!

getInitURL

public java.net.URL getInitURL()
Get the top level URL used to initialize this document.

Returns:
the top level URL

getPageno

public int getPageno(java.lang.String url)
Convert a relative url to a page number. The first page number is page 0.

Parameters:
url - The URL to convert
Returns:
the page number if found, otherwise -1

clone

public java.lang.Object clone()
Create a copy by value of this instance. Note that this method assumes this class is final.

Overrides:
clone in class java.lang.Object
Returns:
the newly created copy

createFile

public DjVmDir.File createFile()
Create a new instance of DjVmDir.File

Returns:
the new instance of DjVmDir.File

createFile

public DjVmDir.File createFile(java.lang.String load_name,
                               java.lang.String save_name,
                               java.lang.String title,
                               int file_type)
Create a new instance of DjVmDir.File

Parameters:
load_name - the name used for loading
save_name - the name used for saving
title - the title
file_type - the type of record
Returns:
the new instance of DjVmDir.File

decode

public void decode(DataPool pool)
            throws java.io.IOException
Called to decode the data source and initialize this index.

Specified by:
decode in interface Codec
Parameters:
pool - data source
Throws:
java.io.IOException - if an error occurs

delete_file

public void delete_file(java.lang.String id)
Called to remove the named file from the index.

Parameters:
id - the name of the file to remove

get_file_pos

public int get_file_pos(DjVmDir.File f)
Called to find the position of a File in the list

Parameters:
f - the file to search for
Returns:
the position of the file or -1

get_files_list

public java.util.Vector get_files_list()
Query the file list.

Returns:
the vector of DjVmDir.File objects

get_files_num

public int get_files_num()
Query the size of the file list

Returns:
the size of the file list

get_page_pos

public int get_page_pos(int page_num)
Query the position of a page in the list

Parameters:
page_num - page number to search for
Returns:
the list position or -1

get_pages_num

public int get_pages_num()
Query the number of pages in the index.

Returns:
the number of pages in the index

get_shared_anno_file

public DjVmDir.File get_shared_anno_file()
Query the document shared annotation

Returns:
the document shared annotation

id_to_file

public DjVmDir.File id_to_file(java.lang.String id)
Called to map an id to a File.

Parameters:
id - the load name to look for
Returns:
the DjVmDir.File record

insert_file

public int insert_file(DjVmDir.File file)
                throws java.io.IOException
Called to add a file to the index.

Parameters:
file - DjVmDir.File object to add
Returns:
the position where the File was added
Throws:
java.io.IOException - if an error occurs

insert_file

public int insert_file(DjVmDir.File file,
                       int pos_num)
                throws java.io.IOException
Called to add a file to the index.

Parameters:
file - DjVmDir.File object to add
pos_num - the position to insert the file
Returns:
the position where the File was added
Throws:
java.io.IOException - if an error occurs

is_bundled

public boolean is_bundled()
Query if the index is for a bundled document.

Returns:
true if bundled

is_indirect

public boolean is_indirect()
Query if the index is for an indirect document.

Returns:
true if indirect

name_to_file

public DjVmDir.File name_to_file(java.lang.String name)
Query the File mapped to name.

Parameters:
name - the name to look for
Returns:
the File or null

page_to_file

public DjVmDir.File page_to_file(int page_num)
Query the File mapped to the specified page number.

Parameters:
page_num - the page number to look for
Returns:
the File or null

set_file_name

public void set_file_name(java.lang.String id,
                          java.lang.String name)
                   throws java.io.IOException
Set the filename corresponding to an id.

Parameters:
id - the id to map
name - the name to map
Throws:
java.io.IOException - if an error occurs

set_file_title

public void set_file_title(java.lang.String id,
                           java.lang.String title)
                    throws java.io.IOException
Set the title corresponding to an id.

Parameters:
id - the id to map
title - the title to map to
Throws:
java.io.IOException - if an error occurs

title_to_file

public DjVmDir.File title_to_file(java.lang.String title)
Find the DjVmDir.File with the specified title.

Parameters:
title - the title to search for
Returns:
the DjVmDir.File