01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.i18n.rebind;
17:
18: import com.google.gwt.i18n.rebind.util.AbstractResource;
19: import com.google.gwt.user.rebind.AbstractGeneratorClassCreator;
20: import com.google.gwt.user.rebind.AbstractMethodCreator;
21:
22: /**
23: * A <code>AbstractMethodCreator</code> specialized for
24: * <code>ConstantsImplCreator</code>.
25: */
26: abstract class AbstractLocalizableMethodCreator extends
27: AbstractMethodCreator {
28: /**
29: * Constructor for <code>AbstractLocalizableMethodCreator</code>.
30: *
31: * @param classCreator Creator associated with this method creator
32: */
33: public AbstractLocalizableMethodCreator(
34: AbstractGeneratorClassCreator classCreator) {
35: super (classCreator);
36: }
37:
38: /**
39: * Enables caching to store computed values.
40: */
41: protected void enableCache() {
42: ((ConstantsImplCreator) currentCreator).setNeedCache(true);
43: }
44:
45: /**
46: * Gets the associated locale.
47: *
48: * @return the locale
49: */
50: protected String getLocaleName() {
51: return getResources().getLocaleName();
52: }
53:
54: /**
55: * Get the resources associated with this class.
56: *
57: * @return associated resources.
58: */
59: protected AbstractResource getResources() {
60: return ((ConstantsImplCreator) currentCreator)
61: .getResourceBundle();
62: }
63: }
|