1 /* 2 * Copyright 2006 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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 import java.util.Locale; 23 24 /** 25 * A <code>AbstractMethodCreator</code> specialized for 26 * <code>ConstantsImplCreator</code>. 27 */ 28 abstract class AbstractLocalizableMethodCreator extends AbstractMethodCreator { 29 /** 30 * Constructor for <code>AbstractLocalizableMethodCreator</code>. 31 * 32 * @param classCreator Creator associated with this method creator 33 */ 34 public AbstractLocalizableMethodCreator( 35 AbstractGeneratorClassCreator classCreator) { 36 super(classCreator); 37 } 38 39 /** 40 * Enables caching to store computed values. 41 */ 42 protected void enableCache() { 43 ((ConstantsImplCreator) currentCreator).setNeedCache(true); 44 } 45 46 /** 47 * Gets the associated locale. 48 * 49 * @return the locale 50 */ 51 protected Locale getLocale() { 52 return getResources().getLocale(); 53 } 54 55 /** 56 * Get the resources associated with this class. 57 * 58 * @return associated resources. 59 */ 60 protected AbstractResource getResources() { 61 return ((ConstantsImplCreator) currentCreator).getResourceBundle(); 62 } 63 } 64