de.h2b.taglets
Class CrossRefMap

java.lang.Object
  extended by de.h2b.taglets.CrossRefMap

@ClassLabel(copyright="Copyright (C) 2008 Hans-Hermann Bode",
            ident="$Id: CrossRefMap.java,v 1.5 2008/12/14 17:05:37 h2b Exp $")
public final class CrossRefMap
extends java.lang.Object

A singleton that provides for a unique map of CrossRefTables.

The only instance of this object is returned by the getInstance method. Besides methods getTable for retrieving tables from the map (which also populate the map with tables as needed), there is a (load/save mechanism for the map as a whole which can be used instead of the corresponding mechanism of CrossRefTable to avoid flooding the directories with auxiliary files.

Since:
h2taglets 0.1
Version:
$Revision: 1.5 $, $Date: 2008/12/14 17:05:37 $
Author:
h2b
See Also:
CrossRefTable

Method Summary
static CrossRefMap getInstance()
          Returns the only instance of this singleton.
 CrossRefTable getTable(java.lang.String key)
          Returns the cross-ref table associated to a given key.
 CrossRefTable getTable(java.lang.String key, java.lang.String path)
          Returns the cross-ref table associated to a given key.
 void load(java.io.File f)
          Loads the map from a file.
 void save(java.io.File f)
          Saves the map to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static CrossRefMap getInstance()
Returns the only instance of this singleton.

Returns:
the instance
Since:
h2taglets 0.1

getTable

public CrossRefTable getTable(java.lang.String key)
Returns the cross-ref table associated to a given key. If the map does not contain the key already, the latter will be added first with a new CrossRefTable as value.

Parameters:
key - the key whose table is in demand
Returns:
the CrossRefTable associated with the key
Since:
h2taglets 0.1

getTable

public CrossRefTable getTable(java.lang.String key,
                              java.lang.String path)
Returns the cross-ref table associated to a given key. If the map does not contain the key already, the latter will be added first with a new CrossRefTable(path) as value. If path is null, that value is CrossRefTable().

Parameters:
key - the key whose table is in demand
path - the pathname of the auxiliary file for storing the table
Returns:
the CrossRefTable associated with the key
Since:
h2taglets 0.1
See Also:
CrossRefTable.CrossRefTable(String)

load

public void load(java.io.File f)
Loads the map from a file. If the file doesn't exist or an exception occurs during loading, an empty map is created. Note that in both cases any existing entries of the map are destroyed.

Parameters:
f - the file the map is to be loaded from
Since:
h2taglets 0.1

save

public void save(java.io.File f)
Saves the map to a file. If the file is null, nothing happens. If an exception occurs, a warning message is output.

Parameters:
f - the file the map is to be saved to
Since:
h2taglets 0.1


Copyright © 2008 Hans-Hermann Bode, Berlin, Germany. All Rights Reserved.