[Jarspy-commits] CVS: JarSpy/src/com/ociweb/classinfo/constantpool AbstractConstantPoolEntry.java,NO
Status: Beta
Brought to you by:
brown_j
Update of /cvsroot/jarspy/JarSpy/src/com/ociweb/classinfo/constantpool
In directory usw-pr-cvs1:/tmp/cvs-serv12193
Added Files:
AbstractConstantPoolEntry.java CP_ClassEntry.java
CP_DoubleEntry.java CP_FieldrefEntry.java CP_FloatEntry.java
CP_IntegerEntry.java CP_InterfaceMethodrefEntry.java
CP_LongEntry.java CP_MethodrefEntry.java
CP_NameAndTypeEntry.java CP_StringEntry.java CP_Utf8Entry.java
ConstantPool.java ConstantPoolEntry.java
ConstantPoolEntryType.java DefaultCP_ClassEntry.java
DefaultCP_DoubleEntry.java DefaultCP_FieldrefEntry.java
DefaultCP_FloatEntry.java DefaultCP_IntegerEntry.java
DefaultCP_InterfaceMethodrefEntry.java
DefaultCP_LongEntry.java DefaultCP_MethdrefEntry.java
DefaultCP_NameAndTypeEntry.java DefaultCP_StringEntry.java
DefaultCP_Utf8Entry.java DefaultConstantPool.java
DefaultNULLCPEntry.java
Log Message:
added constantpool package
--- NEW FILE: AbstractConstantPoolEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* AbstractConstantPoolEntry
*/
public abstract class AbstractConstantPoolEntry
implements ConstantPoolEntry {
private final ConstantPoolEntryType type;
public AbstractConstantPoolEntry(ConstantPoolEntryType type) {
this.type = type;
}
public ConstantPoolEntryType getType() {
return type;
}
public String toString() {
return getType() + ": " + getValueDescription();
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
abstract String getValueDescription();
}
--- NEW FILE: CP_ClassEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* CP_ClassEntry
*/
public interface CP_ClassEntry extends ConstantPoolEntry {
public short getIndex();
}
--- NEW FILE: CP_DoubleEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* CP_DoubleEntry
*/
public interface CP_DoubleEntry extends ConstantPoolEntry {
}
--- NEW FILE: CP_FieldrefEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* CP_FieldrefEntry
*/
public interface CP_FieldrefEntry extends ConstantPoolEntry {
}
--- NEW FILE: CP_FloatEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* CP_FloatEntry
*/
public interface CP_FloatEntry extends ConstantPoolEntry {
}
--- NEW FILE: CP_IntegerEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* CP_IntegerEntry
*/
public interface CP_IntegerEntry extends ConstantPoolEntry {
}
--- NEW FILE: CP_InterfaceMethodrefEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* CP_InterfaceMethodrefEntry
*/
public interface CP_InterfaceMethodrefEntry extends ConstantPoolEntry {
}
--- NEW FILE: CP_LongEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* CP_LongEntry
*/
public interface CP_LongEntry extends ConstantPoolEntry {
}
--- NEW FILE: CP_MethodrefEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* CP_MethodrefEntry
*/
public interface CP_MethodrefEntry extends ConstantPoolEntry {
}
--- NEW FILE: CP_NameAndTypeEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* CP_NameAndTypeEntry
*/
public interface CP_NameAndTypeEntry extends ConstantPoolEntry {
}
--- NEW FILE: CP_StringEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* CP_StringEntry
*/
public interface CP_StringEntry extends ConstantPoolEntry {
public short getIndex();
}
--- NEW FILE: CP_Utf8Entry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* CP_Utf8Entry
*/
public interface CP_Utf8Entry extends ConstantPoolEntry {
public String getValue();
}
--- NEW FILE: ConstantPool.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* ConstantPool
*/
public interface ConstantPool {
/**
* @return an array of <code>ConstantPoolEntry</code>
* objects contained in this constant pool
*/
public ConstantPoolEntry[] getEntries();
/**
* @param index into the constant pool
* @return the entry at index
*/
public ConstantPoolEntry getEntryAt(int index);
}
--- NEW FILE: ConstantPoolEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* ConstantPoolEntry
*/
public interface ConstantPoolEntry {
public ConstantPoolEntryType getType();
}
--- NEW FILE: ConstantPoolEntryType.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* ConstantPoolEntryType
*/
public final class ConstantPoolEntryType {
public static final ConstantPoolEntryType CLASS_TYPE =
new ConstantPoolEntryType("Class");
public static final ConstantPoolEntryType DOUBLE_TYPE =
new ConstantPoolEntryType("Double");
public static final ConstantPoolEntryType FIELDREF_TYPE =
new ConstantPoolEntryType("Fieldref");
public static final ConstantPoolEntryType FLOAT_TYPE =
new ConstantPoolEntryType("Float");
public static final ConstantPoolEntryType INTEGER_TYPE =
new ConstantPoolEntryType("Integer");
public static final ConstantPoolEntryType INTERFACE_METHODREF_TYPE =
new ConstantPoolEntryType("InterfaceMethodref");
public static final ConstantPoolEntryType LONG_TYPE =
new ConstantPoolEntryType("Long");
public static final ConstantPoolEntryType METHODREF_TYPE =
new ConstantPoolEntryType("Methodref");
public static final ConstantPoolEntryType NAMEANDTYPE_TYPE =
new ConstantPoolEntryType("NameAndType");
public static final ConstantPoolEntryType STRING_TYPE =
new ConstantPoolEntryType("String");
public static final ConstantPoolEntryType UTF8_TYPE =
new ConstantPoolEntryType("Utf8");
public static final ConstantPoolEntryType NULL_ENTRY =
new ConstantPoolEntryType("null");
private String typeName;
private ConstantPoolEntryType(String typeName) {
this.typeName = typeName;
}
public String getTypeName() {
return typeName;
}
public String toString() {
return getTypeName();
}
}
--- NEW FILE: DefaultCP_ClassEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultCP_ClassEntry
*/
public class DefaultCP_ClassEntry extends AbstractConstantPoolEntry
implements CP_ClassEntry {
private final short index;
public DefaultCP_ClassEntry(short index) {
super(ConstantPoolEntryType.CLASS_TYPE);
this.index = index;
}
public short getIndex() {
return index;
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return "index = " + index;
}
}
--- NEW FILE: DefaultCP_DoubleEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultCP_DoubleEntry
*/
public class DefaultCP_DoubleEntry extends AbstractConstantPoolEntry
implements CP_DoubleEntry {
private final double value;
public DefaultCP_DoubleEntry(double value) {
super(ConstantPoolEntryType.DOUBLE_TYPE);
this.value = value;
}
public double getValue() {
return value;
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return "value = " + value;
}
}
--- NEW FILE: DefaultCP_FieldrefEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultCP_FieldrefEntry
*/
public class DefaultCP_FieldrefEntry extends AbstractConstantPoolEntry
implements CP_FieldrefEntry {
private final short classIndex;
private final short nameAndTypeIndex;
public DefaultCP_FieldrefEntry(short classIndex,
short nameAndTypeIndex) {
super(ConstantPoolEntryType.FIELDREF_TYPE);
this.classIndex = classIndex;
this.nameAndTypeIndex = nameAndTypeIndex;
}
public short getClassIndex() {
return classIndex;
}
public short getNameAndTypeIndex() {
return nameAndTypeIndex;
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return "classIndex = " + classIndex + ", nameAndTypeIndex = " + nameAndTypeIndex;
}
}
--- NEW FILE: DefaultCP_FloatEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultCP_FloatEntry
*/
public class DefaultCP_FloatEntry extends AbstractConstantPoolEntry
implements CP_FloatEntry {
private final float value;
public DefaultCP_FloatEntry(float value) {
super(ConstantPoolEntryType.FLOAT_TYPE);
this.value = value;
}
public float getValue() {
return value;
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return "value = " + value;
}
}
--- NEW FILE: DefaultCP_IntegerEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultCP_IntegerEntry
*/
public class DefaultCP_IntegerEntry extends AbstractConstantPoolEntry
implements CP_IntegerEntry {
private final int value;
public DefaultCP_IntegerEntry(int value) {
super(ConstantPoolEntryType.INTEGER_TYPE);
this.value = value;
}
public int getValue() {
return value;
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return "value = " + value;
}
}
--- NEW FILE: DefaultCP_InterfaceMethodrefEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultCP_InterfaceMethodrefEntry
*/
public class DefaultCP_InterfaceMethodrefEntry extends AbstractConstantPoolEntry
implements CP_InterfaceMethodrefEntry {
private final short classIndex;
private final short nameAndTypeIndex;
public DefaultCP_InterfaceMethodrefEntry(short classIndex,
short nameAndTypeIndex) {
super(ConstantPoolEntryType.INTERFACE_METHODREF_TYPE);
this.classIndex = classIndex;
this.nameAndTypeIndex = nameAndTypeIndex;
}
public short getClassIndex() {
return classIndex;
}
public short getNameAndTypeIndex() {
return nameAndTypeIndex;
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return "classIndex = " + classIndex + ", nameAndTypeIndex = " + nameAndTypeIndex;
}
}
--- NEW FILE: DefaultCP_LongEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultCP_LongEntry
*/
public class DefaultCP_LongEntry extends AbstractConstantPoolEntry
implements CP_LongEntry {
private final long value;
public DefaultCP_LongEntry(long value) {
super(ConstantPoolEntryType.LONG_TYPE);
this.value = value;
}
public long getValue() {
return value;
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return "value = " + value;
}
}
--- NEW FILE: DefaultCP_MethdrefEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultCP_MethdrefEntry
*/
public class DefaultCP_MethdrefEntry extends AbstractConstantPoolEntry
implements CP_MethodrefEntry {
private final short classIndex;
private final short nameAndTypeIndex;
public DefaultCP_MethdrefEntry(short classIndex,
short nameAndTypeIndex) {
super(ConstantPoolEntryType.METHODREF_TYPE);
this.classIndex = classIndex;
this.nameAndTypeIndex = nameAndTypeIndex;
}
public short getClassIndex() {
return classIndex;
}
public short getNameAndTypeIndex() {
return nameAndTypeIndex;
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return "classIndex = " + classIndex + ", nameAndTypeIndex = " + nameAndTypeIndex;
}
}
--- NEW FILE: DefaultCP_NameAndTypeEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultCP_NameAndTypeEntry
*/
public class DefaultCP_NameAndTypeEntry extends AbstractConstantPoolEntry
implements CP_NameAndTypeEntry {
private final short nameIndex;
private final short descriptorIndex;
public DefaultCP_NameAndTypeEntry(short nameIndex,
short descriptorIndex) {
super(ConstantPoolEntryType.NAMEANDTYPE_TYPE);
this.nameIndex = nameIndex;
this.descriptorIndex = descriptorIndex;
}
public short getNameIndex() {
return nameIndex;
}
public short getDescriptorIndex() {
return descriptorIndex;
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return "nameIndex = " + nameIndex + ", descriptorIndex = " + descriptorIndex;
}
}
--- NEW FILE: DefaultCP_StringEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultCP_StringEntry
*/
public class DefaultCP_StringEntry extends AbstractConstantPoolEntry
implements CP_StringEntry {
private final short index;
public DefaultCP_StringEntry(short index) {
super(ConstantPoolEntryType.STRING_TYPE);
this.index = index;
}
public short getIndex() {
return index;
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return "index = " + index;
}
}
--- NEW FILE: DefaultCP_Utf8Entry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultCP_Utf8Entry
*/
public class DefaultCP_Utf8Entry extends AbstractConstantPoolEntry
implements CP_Utf8Entry {
private final String value;
public DefaultCP_Utf8Entry(String value) {
super(ConstantPoolEntryType.UTF8_TYPE);
this.value = value;
}
public String getValue() {
return value;
}
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return value;
}
}
--- NEW FILE: DefaultConstantPool.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
import java.io.DataInputStream;
import java.io.IOException;
import java.text.DecimalFormat;
/**
* DefaultConstantPool
*/
public class DefaultConstantPool implements ConstantPool {
private static final byte CONSTANT_Utf8 = 1;
private static final byte CONSTANT_Integer = 3;
private static final byte CONSTANT_Float = 4;
private static final byte CONSTANT_Long = 5;
private static final byte CONSTANT_Double = 6;
private static final byte CONSTANT_Class = 7;
private static final byte CONSTANT_String = 8;
private static final byte CONSTANT_Fieldref = 9;
private static final byte CONSTANT_Methodref = 10;
private static final byte CONSTANT_InterfaceMethodref = 11;
private static final byte CONSTANT_NameAndType = 12;
private final ConstantPoolEntry[] entries;
public DefaultConstantPool(DataInputStream di)
throws IOException {
short constantPoolSize = di.readShort();
entries = new ConstantPoolEntry[constantPoolSize];
entries[0] = DefaultNULLCPEntry.INSTANCE;
for (int i = 1; i < constantPoolSize; i++) {
int tag = di.readUnsignedByte();
switch (tag) {
case CONSTANT_Utf8:
entries[i] = new DefaultCP_Utf8Entry(di.readUTF());
break;
case CONSTANT_Integer:
entries[i] = new DefaultCP_IntegerEntry(di.readInt());
break;
case CONSTANT_Float:
entries[i] = new DefaultCP_FloatEntry(di.readFloat());
break;
case CONSTANT_Long:
entries[i] = new DefaultCP_LongEntry(di.readLong());
entries[++i] = DefaultNULLCPEntry.INSTANCE;
break;
case CONSTANT_Double:
entries[i] = new DefaultCP_DoubleEntry(di.readDouble());
entries[++i] = DefaultNULLCPEntry.INSTANCE;
break;
case CONSTANT_Class:
entries[i] = new DefaultCP_ClassEntry(di.readShort());
break;
case CONSTANT_String:
entries[i] = new DefaultCP_StringEntry(di.readShort());
break;
case CONSTANT_Fieldref:
short fieldClassIndex = di.readShort();
short fieldNameAndTypeIndex = di.readShort();
entries[i] = new DefaultCP_FieldrefEntry(fieldClassIndex, fieldNameAndTypeIndex);
break;
case CONSTANT_Methodref:
short methodClassIndex = di.readShort();
short methodNameAndTypeIndex = di.readShort();
entries[i] = new DefaultCP_MethdrefEntry(methodClassIndex, methodNameAndTypeIndex);
break;
case CONSTANT_InterfaceMethodref:
short interfaceMethodClassIndex = di.readShort();
short interfaceNameAndTypeIndex = di.readShort();
entries[i] = new DefaultCP_InterfaceMethodrefEntry(interfaceMethodClassIndex, interfaceNameAndTypeIndex);
break;
case CONSTANT_NameAndType:
short nameIndex = di.readShort();
short descriptorIndex = di.readShort();
entries[i] = new DefaultCP_NameAndTypeEntry(nameIndex, descriptorIndex);
break;
default:
throw new IllegalArgumentException("Invalid ConstantPool Tag: " +
tag);
}
}
}
public ConstantPoolEntry[] getEntries() {
return entries;
}
/**
* @param index into the constant pool
* @return the entry at index
*/
public ConstantPoolEntry getEntryAt(int index) {
return entries[index];
}
public String toString() {
StringBuffer sb = new StringBuffer("Constant Pool:\n");
int numberOfCharacters = String.valueOf(entries.length).length();
String formatString = "0";
for (int i = 1; i < numberOfCharacters; i++) {
formatString = "0" + formatString;
}
DecimalFormat formatter = new DecimalFormat(formatString);
for (int i = 1; i < entries.length; i++) {
sb.append("[" + formatter.format(i) + "] " + entries[i] + "\n");
}
return sb.toString();
}
}
--- NEW FILE: DefaultNULLCPEntry.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.classinfo.constantpool;
/**
* DefaultNULLCPEntry
*/
public final class DefaultNULLCPEntry extends AbstractConstantPoolEntry {
public static final DefaultNULLCPEntry INSTANCE =
new DefaultNULLCPEntry();
/**
*
* @return a <code>String</code> representing the value of this entry
*/
String getValueDescription() {
return "";
}
private DefaultNULLCPEntry() {
super(ConstantPoolEntryType.NULL_ENTRY);
}
}
|