KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > resourcebundle > PagesEngineResourceBundle


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12
//
13
//
14
// NK 18.02.2002 - added in Jahia
15
//
16

17 package org.jahia.resourcebundle;
18
19 import java.util.Hashtable JavaDoc;
20 import java.util.ResourceBundle JavaDoc;
21
22 import org.jahia.params.ParamBean;
23 import org.jahia.services.pages.ContentPage;
24
25
26 /**
27  * Tools to handles Pages engine resource bundle.
28  *
29  * @author Khue Nguyen
30  * @version 1.0
31  */

32 public class PagesEngineResourceBundle
33 {
34
35     private static final String JavaDoc CLASS_NAME = PagesEngineResourceBundle.class.getName();
36
37     private static PagesEngineResourceBundle mInstance ;
38
39     private Hashtable JavaDoc resources ;
40
41
42     private PagesEngineResourceBundle(){
43         resources = new Hashtable JavaDoc();
44     }
45
46
47     public static synchronized PagesEngineResourceBundle getInstance(){
48
49         if ( mInstance == null ){
50             mInstance = new PagesEngineResourceBundle();
51         }
52         return mInstance;
53     }
54
55
56     /**
57      * Add a resource bundle
58      *
59      * @param JahiaPage page
60      * @param ResourceBundle res
61      * @param ParamBean jParams
62      */

63     public void addResourceBundle(ContentPage contentPage, ResourceBundle JavaDoc res, ParamBean jParams ){
64
65         if ( contentPage == null || res == null || jParams == null )
66             return;
67         resources.put( JahiaResourceBundle.ENGINE_DEFAULT_RESOURCE_BUNDLE + "_" + contentPage.getID(), res );
68     }
69
70     /**
71      * Returns a resource bundle for a given page
72      *
73      * @param JahiaPage page
74      * @return ResourceBundle res
75      * @param ParamBean jParams
76      */

77     public ResourceBundle JavaDoc getResourceBundle(ContentPage contentPage, ParamBean jParams ){
78
79         if ( contentPage == null || jParams == null )
80             return null;
81
82         ResourceBundle JavaDoc res = (ResourceBundle JavaDoc)resources.get( JahiaResourceBundle.ENGINE_DEFAULT_RESOURCE_BUNDLE
83                               + "_" + contentPage.getID() );
84         return res;
85     }
86
87 }
88
89
Popular Tags