Showing the changes to java/pkg/sun/reflect/generics/repository/AbstractRepository.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,85 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. | ||
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| 4 | * | ||
| 5 | * This code is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms of the GNU General Public License version 2 only, as | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 10 | * | ||
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 14 | * version 2 for more details (a copy is included in the LICENSE file that | ||
| 15 | * accompanied this code). | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License version | ||
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, | ||
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | * | ||
| 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| 22 | * or visit www.oracle.com if you need additional information or have any | ||
| 23 | * questions. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.reflect.generics.repository; | ||
| 27 | |||
| 28 | import sun.reflect.generics.factory.GenericsFactory; | ||
| 29 | import sun.reflect.generics.tree.Tree; | ||
| 30 | import sun.reflect.generics.visitor.Reifier; | ||
| 31 | |||
| 32 | |||
| 33 | /** | ||
| 34 | * Abstract superclass for representing the generic type information for | ||
| 35 | * a reflective entity. | ||
| 36 | * The code is not dependent on a particular reflective implementation. | ||
| 37 | * It is designed to be used unchanged by at least core reflection and JDI. | ||
| 38 | */ | ||
| 39 | public abstract class AbstractRepository<T extends Tree> { | ||
| 40 | |||
| 41 | // A factory used to produce reflective objects. Provided when the | ||
| 42 | //repository is created. Will vary across implementations. | ||
| 43 | private GenericsFactory factory; | ||
| 44 | |||
| 45 | private T tree; // the AST for the generic type info | ||
| 46 | |||
| 47 | //accessors | ||
| 48 | private GenericsFactory getFactory() { return factory;} | ||
| 49 | |||
| 50 | /** | ||
| 51 | * Accessor for <tt>tree</tt>. | ||
| 52 | * @return the cached AST this repository holds | ||
| 53 | */ | ||
| 54 | protected T getTree(){ return tree;} | ||
| 55 | |||
| 56 | /** | ||
| 57 | * Returns a <tt>Reifier</tt> used to convert parts of the | ||
| 58 | * AST into reflective objects. | ||
| 59 | * @return a <tt>Reifier</tt> used to convert parts of the | ||
| 60 | * AST into reflective objects | ||
| 61 | */ | ||
| 62 | protected Reifier getReifier(){return Reifier.make(getFactory());} | ||
| 63 | |||
| 64 | /** | ||
| 65 | * Constructor. Should only be used by subclasses. Concrete subclasses | ||
| 66 | * should make their constructors private and provide public factory | ||
| 67 | * methods. | ||
| 68 | * @param rawSig - the generic signature of the reflective object | ||
| 69 | * that this repository is servicing | ||
| 70 | * @param f - a factory that will provide instances of reflective | ||
| 71 | * objects when this repository converts its AST | ||
| 72 | */ | ||
| 73 | protected AbstractRepository(String rawSig, GenericsFactory f) { | ||
| 74 | tree = parse(rawSig); | ||
| 75 | factory = f; | ||
| 76 | } | ||
| 77 | |||
| 78 | /** | ||
| 79 | * Returns the AST for the genric type info of this entity. | ||
| 80 | * @param s - a string representing the generic signature of this | ||
| 81 | * entity | ||
| 82 | * @return the AST for the generic type info of this entity. | ||
| 83 | */ | ||
| 84 | protected abstract T parse(String s); | ||
| 85 | } | ||