< prev index next >

src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java

Print this page




   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.bcel.internal.classfile;
  23 



  24 
  25 import  com.sun.org.apache.bcel.internal.Constants;
  26 import  java.io.*;
  27 
  28 /**
  29  * This class is derived from <em>Attribute</em> and represents a reference
  30  * to a <a href="http://www.inf.fu-berlin.de/~bokowski/pmgjava/index.html">PMG</a>
  31  * attribute.
  32  *
  33  * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  34  * @see     Attribute
  35  */
  36 public final class PMGClass extends Attribute {
  37   private int pmg_class_index, pmg_index;



  38 
  39   /**
  40    * Initialize from another object. Note that both objects use the same
  41    * references (shallow copy). Use clone() for a physical copy.
  42    */
  43   public PMGClass(PMGClass c) {
  44     this(c.getNameIndex(), c.getLength(), c.getPMGIndex(), c.getPMGClassIndex(),
  45          c.getConstantPool());
  46   }
  47 

  48   /**
  49    * Construct object from file stream.
  50    * @param name_index Index in constant pool to CONSTANT_Utf8
  51    * @param length Content length in bytes
  52    * @param file Input stream
  53    * @param constant_pool Array of constants
  54    * @throws IOException
  55    */
  56   PMGClass(int name_index, int length, DataInputStream file,
  57            ConstantPool constant_pool) throws IOException
  58   {
  59     this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(),
  60          constant_pool);
  61   }
  62 

  63   /**
  64    * @param name_index Index in constant pool to CONSTANT_Utf8
  65    * @param length Content length in bytes


  66    * @param constant_pool Array of constants
  67    * @param PMGClass_index Index in constant pool to CONSTANT_Utf8
  68    */
  69   public PMGClass(int name_index, int length, int pmg_index, int pmg_class_index,
  70                   ConstantPool constant_pool)
  71   {
  72     super(Constants.ATTR_PMG, name_index, length, constant_pool);
  73     this.pmg_index       = pmg_index;
  74     this.pmg_class_index = pmg_class_index;
  75   }
  76 

  77   /**
  78    * Called by objects that are traversing the nodes of the tree implicitely
  79    * defined by the contents of a Java class. I.e., the hierarchy of methods,
  80    * fields, attributes, etc. spawns a tree of objects.
  81    *
  82    * @param v Visitor object
  83    */
  84    public void accept(Visitor v) {

  85      System.err.println("Visiting non-standard PMGClass object");
  86    }
  87 

  88   /**
  89    * Dump source file attribute to file stream in binary format.
  90    *
  91    * @param file Output file stream
  92    * @throws IOException
  93    */
  94   public final void dump(DataOutputStream file) throws IOException
  95   {
  96     super.dump(file);
  97     file.writeShort(pmg_index);
  98     file.writeShort(pmg_class_index);
  99   }
 100 

 101   /**
 102    * @return Index in constant pool of source file name.
 103    */
 104   public final int getPMGClassIndex() { return pmg_class_index; }



 105 
 106   /**
 107    * @param PMGClass_index.
 108    */
 109   public final void setPMGClassIndex(int pmg_class_index) {
 110     this.pmg_class_index = pmg_class_index;
 111   }
 112 

 113   /**
 114    * @return Index in constant pool of source file name.
 115    */
 116   public final int getPMGIndex() { return pmg_index; }



 117 
 118   /**
 119    * @param PMGClass_index.
 120    */
 121   public final void setPMGIndex(int pmg_index) {
 122     this.pmg_index = pmg_index;
 123   }
 124 

 125   /**
 126    * @return PMG name.
 127    */
 128   public final String getPMGName() {
 129     ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(pmg_index,
 130                                                              Constants.CONSTANT_Utf8);
 131     return c.getBytes();
 132   }
 133 

 134   /**
 135    * @return PMG class name.
 136    */
 137   public final String getPMGClassName() {
 138     ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(pmg_class_index,
 139                                                              Constants.CONSTANT_Utf8);
 140     return c.getBytes();
 141   }
 142 

 143   /**
 144    * @return String representation
 145    */

 146   public final String toString() {
 147     return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")";
 148   }
 149 

 150   /**
 151    * @return deep copy of this attribute
 152    */
 153   public Attribute copy(ConstantPool constant_pool) {
 154     return (PMGClass)clone();

 155   }
 156 }


   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.bcel.internal.classfile;
  23 
  24 import java.io.DataInput;
  25 import java.io.DataOutputStream;
  26 import java.io.IOException;
  27 
  28 import com.sun.org.apache.bcel.internal.Const;

  29 
  30 /**
  31  * This class is derived from <em>Attribute</em> and represents a reference
  32  * to a PMG attribute.

  33  *
  34  * @version $Id: PMGClass.java 1749603 2016-06-21 20:50:19Z ggregory $
  35  * @see     Attribute
  36  */
  37 public final class PMGClass extends Attribute {
  38 
  39     private int pmg_class_index;
  40     private int pmg_index;
  41 
  42 
  43     /**
  44      * Initialize from another object. Note that both objects use the same
  45      * references (shallow copy). Use copy() for a physical copy.
  46      */
  47     public PMGClass(final PMGClass c) {
  48         this(c.getNameIndex(), c.getLength(), c.getPMGIndex(), c.getPMGClassIndex(), c
  49                 .getConstantPool());
  50     }
  51 
  52 
  53     /**
  54      * Construct object from input stream.
  55      * @param name_index Index in constant pool to CONSTANT_Utf8
  56      * @param length Content length in bytes
  57      * @param input Input stream
  58      * @param constant_pool Array of constants
  59      * @throws IOException
  60      */
  61     PMGClass(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
  62             throws IOException {
  63         this(name_index, length, input.readUnsignedShort(), input.readUnsignedShort(), constant_pool);


  64     }
  65 
  66 
  67     /**
  68      * @param name_index Index in constant pool to CONSTANT_Utf8
  69      * @param length Content length in bytes
  70      * @param pmg_index index in constant pool for source file name
  71      * @param pmg_class_index Index in constant pool to CONSTANT_Utf8
  72      * @param constant_pool Array of constants

  73      */
  74     public PMGClass(final int name_index, final int length, final int pmg_index, final int pmg_class_index,
  75             final ConstantPool constant_pool) {
  76         super(Const.ATTR_PMG, name_index, length, constant_pool);

  77         this.pmg_index = pmg_index;
  78         this.pmg_class_index = pmg_class_index;
  79     }
  80 
  81 
  82     /**
  83      * Called by objects that are traversing the nodes of the tree implicitely
  84      * defined by the contents of a Java class. I.e., the hierarchy of methods,
  85      * fields, attributes, etc. spawns a tree of objects.
  86      *
  87      * @param v Visitor object
  88      */
  89     @Override
  90     public void accept( final Visitor v ) {
  91         System.err.println("Visiting non-standard PMGClass object");
  92     }
  93 
  94 
  95     /**
  96      * Dump source file attribute to file stream in binary format.
  97      *
  98      * @param file Output file stream
  99      * @throws IOException
 100      */
 101     @Override
 102     public final void dump( final DataOutputStream file ) throws IOException {
 103         super.dump(file);
 104         file.writeShort(pmg_index);
 105         file.writeShort(pmg_class_index);
 106     }
 107 
 108 
 109     /**
 110      * @return Index in constant pool of source file name.
 111      */
 112     public final int getPMGClassIndex() {
 113         return pmg_class_index;
 114     }
 115 
 116 
 117     /**
 118      * @param pmg_class_index
 119      */
 120     public final void setPMGClassIndex( final int pmg_class_index ) {
 121         this.pmg_class_index = pmg_class_index;
 122     }
 123 
 124 
 125     /**
 126      * @return Index in constant pool of source file name.
 127      */
 128     public final int getPMGIndex() {
 129         return pmg_index;
 130     }
 131 
 132 
 133     /**
 134      * @param pmg_index
 135      */
 136     public final void setPMGIndex( final int pmg_index ) {
 137         this.pmg_index = pmg_index;
 138     }
 139 
 140 
 141     /**
 142      * @return PMG name.
 143      */
 144     public final String getPMGName() {
 145         final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(pmg_index,
 146                 Const.CONSTANT_Utf8);
 147         return c.getBytes();
 148     }
 149 
 150 
 151     /**
 152      * @return PMG class name.
 153      */
 154     public final String getPMGClassName() {
 155         final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(pmg_class_index,
 156                 Const.CONSTANT_Utf8);
 157         return c.getBytes();
 158     }
 159 
 160 
 161     /**
 162      * @return String representation
 163      */
 164     @Override
 165     public final String toString() {
 166         return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")";
 167     }
 168 
 169 
 170     /**
 171      * @return deep copy of this attribute
 172      */
 173     @Override
 174     public Attribute copy( final ConstantPool _constant_pool ) {
 175         return (Attribute) clone();
 176     }
 177 }
< prev index next >