1cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath/* 2cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * Licensed to the Apache Software Foundation (ASF) under one or more 3cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * contributor license agreements. See the NOTICE file distributed with 4cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * this work for additional information regarding copyright ownership. 5cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * The ASF licenses this file to You under the Apache License, Version 2.0 6cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * (the "License"); you may not use this file except in compliance with 7cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * the License. You may obtain a copy of the License at 8cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * 9cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * http://www.apache.org/licenses/LICENSE-2.0 10cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * 11cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * Unless required by applicable law or agreed to in writing, software 12cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * distributed under the License is distributed on an "AS IS" BASIS, 13cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * See the License for the specific language governing permissions and 15cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath * limitations under the License. 16cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath */ 17cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath 18c46a2ea848e7a62cd5ee24216e446ad7b9ba7629Piotr Jastrzebskipackage org.apache.harmony.tests.support; 19cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath 20cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamathimport java.util.ResourceBundle; 21cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath 22cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamathpublic class P { 23cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath private Class c; 24cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath 25cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath public void setClazz(Class c) { 26cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath this.c = c; 27cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath } 28cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath 29cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath public String findProp(String key) { 30cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath return findProp(this.c, key); 31cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath } 32cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath 33cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath private String findProp(Class cls, String key) { 34cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath String ret = null; 35cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath try { 36cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath ResourceBundle b = ResourceBundle.getBundle(cls.getName()); 37cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath ret = (String) b.getObject(key); 38cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath } catch (Exception e) { 39cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath } 40cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath if (ret == null && !cls.equals(Object.class) && !cls.isPrimitive()) { 41cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath ret = findProp(cls.getSuperclass(), key); 42cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath } 43cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath return ret; 44cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath } 45cb318c6f4fe5b0e20099fa85f1b95ccb2d24119fNarayan Kamath} 46