it.unimo.dbgroup.momis.tools
Class TranslationMap

java.lang.Object
  extended byit.unimo.dbgroup.momis.tools.TranslationMap
All Implemented Interfaces:
java.io.Serializable

public class TranslationMap
extends java.lang.Object
implements java.io.Serializable

Manage a translation map.
Used in the SIM process:
ODL -< Odbtools (OLCD-<XML) -< Thesaurus

Author:
Alberto Corni, Jun 2000
See Also:
Serialized Form

Field Summary
private  java.util.HashMap _instanceMap
          Map indexed over the inserted object.
Guarantees that the same object is called ever with the same name.
private  java.util.HashMap _instanceMapNames
          Name Management.
private  java.util.HashMap _nameMap
          Map indexed over the name given to the object.
Guarantees that the names are uniques.
private  java.util.HashMap _nameMapNames
          Name management.
private static int TRUNCATESIZE
          Map indexed over the name given to the object.
Guarantees that the names are uniques.
 
Constructor Summary
TranslationMap()
          Reads a file and put it in a string.
 
Method Summary
 java.lang.Object get(java.lang.String name)
          Search for the object related to the given name.
 java.lang.Object getName(java.lang.String name)
          Name Mapping.
private  java.lang.String getUniqueName(java.lang.String suggestedName, java.util.Map inMap)
          Starting from the suggested Name computes an unique name on the map inMap.
static void main(java.lang.String[] args)
          Routine used to test the class.
 java.lang.String put(java.lang.String suggestedName, java.lang.Object instance)
          Insert an object into 'this' map.
 java.lang.String putName(java.lang.String stringToTranslate)
          Insert a string into 'this' map.
 java.lang.String toStringOld()
          String representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRUNCATESIZE

private static final int TRUNCATESIZE
Map indexed over the name given to the object.
Guarantees that the names are uniques.
MAP: key=nameString, Value=IntanceObject

See Also:
Constant Field Values

_nameMap

private java.util.HashMap _nameMap
Map indexed over the name given to the object.
Guarantees that the names are uniques.
MAP: key=nameString, Value=IntanceObject


_instanceMap

private java.util.HashMap _instanceMap
Map indexed over the inserted object.
Guarantees that the same object is called ever with the same name.
MAP: key=IntanceObject, Value=nameString


_nameMapNames

private java.util.HashMap _nameMapNames
Name management. Map indexed over the tuncated name.
Guarantees that the names are uniques.
MAP: key=tuncatedName, Value=fullName


_instanceMapNames

private java.util.HashMap _instanceMapNames
Name Management. Map indexed over the full Name.
Guarantees that the same name is truncated ever in the same way.
MAP: key=fullName, Value=truncatedName

Constructor Detail

TranslationMap

public TranslationMap()
Reads a file and put it in a string.

Method Detail

put

public java.lang.String put(java.lang.String suggestedName,
                            java.lang.Object instance)
Insert an object into 'this' map.
A new instance (the object to insert) is inserted with the suggested name if the name and the object are not present in the map.

Parameters:
suggestedName - suggested name for the instance.
instance - the object to insert.
Returns:
the name choosen for the instance.

getUniqueName

private java.lang.String getUniqueName(java.lang.String suggestedName,
                                       java.util.Map inMap)
Starting from the suggested Name computes an unique name on the map inMap.

Returns:
a not existing name in the map inMap.

get

public java.lang.Object get(java.lang.String name)
Search for the object related to the given name.

Returns:
null if the instance is not found.

putName

public java.lang.String putName(java.lang.String stringToTranslate)
Insert a string into 'this' map.
The methods putName and getName are designed to translate uniquely names between ODL and OLCD.
Since OLCD supports names with maximum length of 15 chars this routine will truncate chars to 15 chars preserving uniquely (I mean, the same name will be translated ever and only in a given mode).

Parameters:
stringToTranslate - name to be truncated.
Returns:
the truncated unique name.

getName

public java.lang.Object getName(java.lang.String name)
Name Mapping. Search for the fullName related to the given truncated name.

Returns:
null if the instance is not found.

toStringOld

public java.lang.String toStringOld()
String representation.


main

public static void main(java.lang.String[] args)
Routine used to test the class.

Tests the tools.



Universita' di Modena e Reggio Emilia