SourceID_attribute.java revision 3170:dc017a37aac5
1230557Sjimharris/* 2230557Sjimharris * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. 3230557Sjimharris * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4230557Sjimharris * 5230557Sjimharris * This code is free software; you can redistribute it and/or modify it 6230557Sjimharris * under the terms of the GNU General Public License version 2 only, as 7230557Sjimharris * published by the Free Software Foundation. Oracle designates this 8230557Sjimharris * particular file as subject to the "Classpath" exception as provided 9230557Sjimharris * by Oracle in the LICENSE file that accompanied this code. 10230557Sjimharris * 11230557Sjimharris * This code is distributed in the hope that it will be useful, but WITHOUT 12230557Sjimharris * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13230557Sjimharris * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14230557Sjimharris * version 2 for more details (a copy is included in the LICENSE file that 15230557Sjimharris * accompanied this code). 16230557Sjimharris * 17230557Sjimharris * You should have received a copy of the GNU General Public License version 18230557Sjimharris * 2 along with this work; if not, write to the Free Software Foundation, 19230557Sjimharris * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20230557Sjimharris * 21230557Sjimharris * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22230557Sjimharris * or visit www.oracle.com if you need additional information or have any 23230557Sjimharris * questions. 24230557Sjimharris */ 25230557Sjimharris 26230557Sjimharrispackage com.sun.tools.classfile; 27230557Sjimharris 28230557Sjimharrisimport java.io.IOException; 29230557Sjimharris 30230557Sjimharris/** 31230557Sjimharris * <p><b>This is NOT part of any supported API. 32230557Sjimharris * If you write code that depends on this, you do so at your own risk. 33230557Sjimharris * This code and its internal interfaces are subject to change or 34230557Sjimharris * deletion without notice.</b> 35230557Sjimharris */ 36230557Sjimharrispublic class SourceID_attribute extends Attribute { 37230557Sjimharris 38230557Sjimharris SourceID_attribute(ClassReader cr, int name_index, int length) throws IOException { 39230557Sjimharris super(name_index, length); 40230557Sjimharris sourceID_index = cr.readUnsignedShort(); 41230557Sjimharris } 42230557Sjimharris 43230557Sjimharris public SourceID_attribute(ConstantPool constant_pool, int sourceID_index) 44230557Sjimharris throws ConstantPoolException { 45230557Sjimharris this(constant_pool.getUTF8Index(Attribute.SourceID), sourceID_index); 46230557Sjimharris } 47230557Sjimharris 48230557Sjimharris public SourceID_attribute(int name_index, int sourceID_index) { 49230557Sjimharris super(name_index, 2); 50230557Sjimharris this.sourceID_index = sourceID_index; 51230557Sjimharris } 52230557Sjimharris 53230557Sjimharris String getSourceID(ConstantPool constant_pool) throws ConstantPoolException { 54230557Sjimharris return constant_pool.getUTF8Value(sourceID_index); 55230557Sjimharris } 56230557Sjimharris 57230557Sjimharris public <R, D> R accept(Visitor<R, D> visitor, D data) { 58230557Sjimharris return visitor.visitSourceID(this, data); 59230557Sjimharris } 60230557Sjimharris 61230557Sjimharris public final int sourceID_index; 62230557Sjimharris} 63230557Sjimharris