KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > api > persistence > enhancer > classfile > ExceptionTable


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25 package com.sun.jdo.api.persistence.enhancer.classfile;
26
27 import java.io.*;
28 import java.util.Vector JavaDoc;
29 import java.util.Enumeration JavaDoc;
30
31 /**
32  * ExceptionTable represents the exception handlers within the code
33  * of a method.
34  */

35
36 public class ExceptionTable {
37   /* A variable length list of ExceptionRange objects */
38   private Vector JavaDoc theVector = new Vector JavaDoc();
39
40   /* public accessors */
41
42   /**
43    * Return an enumeration of the exception handlers
44    * Each element in the enumeration is an ExceptionRange
45    */

46   public Enumeration JavaDoc handlers() {
47     return theVector.elements();
48   }
49
50   /**
51    * Add an exception handler to the list
52    */

53   public void addElement(ExceptionRange range) {
54     theVector.addElement(range);
55   }
56
57   public ExceptionTable() { }
58
59   /* package local methods */
60
61   static ExceptionTable read(DataInputStream data, CodeEnv env)
62     throws IOException {
63     ExceptionTable excTable = new ExceptionTable();
64     int nExcepts = data.readUnsignedShort();
65     while (nExcepts-- > 0) {
66       excTable.addElement(ExceptionRange.read(data, env));
67     }
68     return excTable;
69   }
70
71   void write(DataOutputStream out) throws IOException {
72     out.writeShort(theVector.size());
73     for (int i=0; i<theVector.size(); i++)
74       ((ExceptionRange) theVector.elementAt(i)).write(out);
75   }
76
77   void print(PrintStream out, int indent) {
78     ClassPrint.spaces(out, indent);
79     out.println("Exception Table: ");//NOI18N
80
for (int i=0; i<theVector.size(); i++)
81       ((ExceptionRange) theVector.elementAt(i)).print(out, indent+2);
82   }
83 }
84
85
86
87
Popular Tags