Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/flexstor/common/awt/HelpFileMapper.java


1   /*
2    * HelpFileMapper.java
3    *
4    * Copyright $Date: 2003/08/11 02:22:32 $ FLEXSTOR.net Inc.
5    *
6    * This work is licensed for use and distribution under license terms found at
7    * http://www.flexstor.org/license.html
8    *
9    */
10  
11  package com.flexstor.common.awt;
12  
13  import java.io.IOException;
14  
15  import com.flexstor.common.settings.Settings;
16  import com.flexstor.common.util.International;
17  import com.flexstor.common.util.PropertyMapper;
18  import com.flexstor.common.util.PropertyMapperException;
19  
20  /**
21   * HelpFileMapper provides functionality to retrieve the help file mapped
22   *                  to an specified help ID through the HelpFileMap.xx file.
23   *
24   * @author Jose Hernandez
25   */
26  public class HelpFileMapper
27  {
28    // MKS macro expander
29    public final static String IDENTIFIER = "$Id: HelpFileMapper.java,v 1.2 2003/08/11 02:22:32 aleric Exp $";
30  
31     /** The name of the help mapping file */
32     private static final String           HELP_MAPPING_FILE = "HelpFileMap";
33     
34     /** The instance of the Property Mapper object used to access the help mapping file */
35     private              PropertyMapper pm                = null;
36     
37     /**
38      * @exception IOException if there is any problem accessing the file.
39      */
40     public HelpFileMapper()
41        throws IOException   
42     {
43        String sResDir = Settings.getString( Settings.RESOURCE_LOCATION);
44        
45        pm = new PropertyMapper();
46        pm.readInputFile( sResDir + HELP_MAPPING_FILE + "." + International.getLanguage() );
47     }
48  
49     /**
50      * Retrieve the name of the file mapped to an specified help ID.
51      *
52      * @param  nHelpID the help ID to retrieve a file name for.
53      * @return the name of the file mapped to the specified help ID.
54      */
55     public String getFile( int nHelpID )
56     {
57        String sHelpID   = ( new Integer( nHelpID ) ).toString();
58        String sFileName = null;
59        
60        String[] saSections = pm.getSections();
61           
62        for ( int i = 0; i < saSections.length; i++ )
63        {
64           try
65           {
66              sFileName = ( String )( pm.getSection( saSections[i] ) ).get( sHelpID );
67           }
68           catch ( PropertyMapperException e ) {}
69            
70           if ( sFileName != null )
71              return sFileName;
72        }
73  
74        return null;
75     }
76    
77  } // end of class