1 /*
   2  * Copyright (c) 2014, 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.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * A representation of information about a class.  Note that classes
  26  * here define only one method.
  27  */
  28 public class ClassData {
  29 
  30     public enum Package {
  31         /**
  32          * Same package as the callsite.
  33          */
  34         SAME,
  35         /**
  36          * Different package from the callsite.
  37          */
  38         DIFFERENT,
  39         /**
  40          * Same as DIFFERENT, and also implies that the class access
  41          * is package-private.
  42          */
  43         INACCESSIBLE,
  44         /**
  45          * Different from everything else.  Used in selection only, to
  46          * test skipping package-private definitions.
  47          */
  48         OTHER,
  49         /**
  50          * Placeholder, used solely by the template dumper for
  51          * printing out the effects of templates.  Don't use for
  52          * anything else.
  53          */
  54         PLACEHOLDER;
  55     }
  56 
  57     /**
  58      * The package ID for the class.
  59      */
  60     public final Package packageId;
  61 
  62     /**
  63      * The method data for the method definition.  If there is no
  64      * method definition, this will be null.
  65      */
  66     public final MethodData methoddata;
  67 
  68     /**
  69      * The class access.  Note that this is controlled by the packageId.
  70      */
  71     public final MethodData.Access access;
  72 
  73     // This is a hardwired value necessary for ClassBuilder
  74     public final MethodData.Context abstraction = MethodData.Context.INSTANCE;
  75 
  76     public ClassData(final Package packageId,
  77                      final MethodData methoddata) {
  78         this.packageId = packageId;
  79         this.methoddata = methoddata;
  80 
  81         if (packageId == Package.INACCESSIBLE)
  82             access = MethodData.Access.PACKAGE;
  83         else
  84             access = MethodData.Access.PUBLIC;
  85     }
  86 
  87     public String toString() {
  88         StringBuilder sb = new StringBuilder();
  89         sb.append(" { ");
  90 
  91         if (methoddata != null) {
  92             sb.append(methoddata);
  93         }
  94 
  95         sb.append(" }\n\n");
  96 
  97         return sb.toString();
  98     }
  99 
 100 }