001: /**
002: * YGuard -- an obfuscation library for Java(TM) classfiles.
003: *
004: * Original Copyright (c) 1999 Mark Welsh (markw@retrologic.com)
005: * Modifications Copyright (c) 2002 yWorks GmbH (yguard@yworks.com)
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: * The author may be contacted at yguard@yworks.com
022: *
023: * Java and all Java-based marks are trademarks or registered
024: * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
025: */package com.yworks.yguard.obf.classfile;
026:
027: import java.io.*;
028: import java.util.*;
029:
030: /**
031: * Representation of an Local Variable table entry.
032: *
033: * @author Mark Welsh
034: */
035: public class LocalVariableInfo {
036: // Constants -------------------------------------------------------------
037:
038: // Fields ----------------------------------------------------------------
039: private int u2startpc;
040: private int u2length;
041: private int u2nameIndex;
042: private int u2descriptorIndex;
043: private int u2index;
044:
045: // Class Methods ---------------------------------------------------------
046: public static LocalVariableInfo create(DataInput din)
047: throws java.io.IOException {
048: if (din == null)
049: throw new NullPointerException("DataInput cannot be null!");
050: LocalVariableInfo lvi = new LocalVariableInfo();
051: lvi.read(din);
052: return lvi;
053: }
054:
055: // Instance Methods ------------------------------------------------------
056: private LocalVariableInfo() {
057: }
058:
059: /** Return name index into Constant Pool. */
060: protected int getNameIndex() {
061: return u2nameIndex;
062: }
063:
064: /** Set the name index. */
065: protected void setNameIndex(int index) {
066: u2nameIndex = index;
067: }
068:
069: /** Return descriptor index into Constant Pool. */
070: protected int getDescriptorIndex() {
071: return u2descriptorIndex;
072: }
073:
074: /** Set the descriptor index. */
075: protected void setDescriptorIndex(int index) {
076: u2descriptorIndex = index;
077: }
078:
079: /** Check for Utf8 references to constant pool and mark them. */
080: protected void markUtf8Refs(ConstantPool pool) {
081: pool.incRefCount(u2nameIndex);
082: pool.incRefCount(u2descriptorIndex);
083: }
084:
085: private void read(DataInput din) throws java.io.IOException {
086: u2startpc = din.readUnsignedShort();
087: u2length = din.readUnsignedShort();
088: u2nameIndex = din.readUnsignedShort();
089: u2descriptorIndex = din.readUnsignedShort();
090: u2index = din.readUnsignedShort();
091: }
092:
093: /** Export the representation to a DataOutput stream. */
094: public void write(DataOutput dout) throws java.io.IOException {
095: dout.writeShort(u2startpc);
096: dout.writeShort(u2length);
097: dout.writeShort(u2nameIndex);
098: dout.writeShort(u2descriptorIndex);
099: dout.writeShort(u2index);
100: }
101: }
|