diff options
Diffstat (limited to 'libjava/classpath/gnu/classpath/jdwp/value')
14 files changed, 1573 insertions, 0 deletions
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/ArrayValue.java b/libjava/classpath/gnu/classpath/jdwp/value/ArrayValue.java new file mode 100644 index 000000000..69b1ebd2a --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/ArrayValue.java @@ -0,0 +1,92 @@ +/* ObjectValue.java -- JDWP wrapper class for an Object value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ObjectId; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an Array value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public class ArrayValue + extends Value +{ + // The Array wrapped by this class represented as a Object + Object _value; + + /** + * Create a new ArrayValue from an Object + * + * @param value the Object to wrap + */ + public ArrayValue(Object value) + { + super(JdwpConstants.Tag.ARRAY); + _value = value; + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return _value; + } + + /** + * Write the wrapped object to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + ObjectId oid = VMIdManager.getDefault().getObjectId(_value); + oid.write(os); + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/BooleanValue.java b/libjava/classpath/gnu/classpath/jdwp/value/BooleanValue.java new file mode 100644 index 000000000..1ae5b4dee --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/BooleanValue.java @@ -0,0 +1,99 @@ +/* BooleanValue.java -- JDWP wrapper class for a boolean value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an boolean value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public final class BooleanValue + extends Value +{ + // The boolean wrapped by this class + boolean _value; + + /** + * Create a new BooleanValue from an boolean + * + * @param value the boolean to wrap + */ + public BooleanValue(boolean value) + { + super(JdwpConstants.Tag.BOOLEAN); + _value = value; + } + + /** + * Get the value held in this Value + * + * @return the value represented by this Value object + */ + public boolean getValue() + { + return _value; + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return new Boolean(_value); + } + + /** + * Write the wrapped boolean to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + os.writeBoolean(_value); + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/ByteValue.java b/libjava/classpath/gnu/classpath/jdwp/value/ByteValue.java new file mode 100644 index 000000000..64de0dc88 --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/ByteValue.java @@ -0,0 +1,99 @@ +/* ByteValue.java -- JDWP wrapper class for a byte value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an byte value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public final class ByteValue + extends Value +{ + // The byte wrapped by this class + byte _value; + + /** + * Create a new ByteValue from an byte + * + * @param value the byte to wrap + */ + public ByteValue(byte value) + { + super(JdwpConstants.Tag.BYTE); + _value = value; + } + + /** + * Get the value held in this Value + * + * @return the value represented by this Value object + */ + public byte getValue() + { + return _value; + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return new Byte(_value); + } + + /** + * Write the wrapped byte to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + os.writeByte(_value); + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/CharValue.java b/libjava/classpath/gnu/classpath/jdwp/value/CharValue.java new file mode 100644 index 000000000..3781065a6 --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/CharValue.java @@ -0,0 +1,99 @@ +/* CharValue.java -- JDWP wrapper class for a char value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an char value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public final class CharValue + extends Value +{ + // The char wrapped by this class + char _value; + + /** + * Create a new CharValue from an char + * + * @param value the char to wrap + */ + public CharValue(char value) + { + super(JdwpConstants.Tag.CHAR); + _value = value; + } + + /** + * Get the value held in this Value + * + * @return the value represented by this Value object + */ + public char getValue() + { + return _value; + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return new Character(_value); + } + + /** + * Write the wrapped char to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + os.writeChar(_value); + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/DoubleValue.java b/libjava/classpath/gnu/classpath/jdwp/value/DoubleValue.java new file mode 100644 index 000000000..1c9a8714d --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/DoubleValue.java @@ -0,0 +1,99 @@ +/* DoubleValue.java -- JDWP wrapper class for a double value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an double value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public final class DoubleValue + extends Value +{ + // The double wrapped by this class + double _value; + + /** + * Create a new DoubleValue from an double + * + * @param value the double to wrap + */ + public DoubleValue(double value) + { + super(JdwpConstants.Tag.DOUBLE); + _value = value; + } + + /** + * Get the value held in this Value + * + * @return the value represented by this Value object + */ + public double getValue() + { + return _value; + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return new Double(_value); + } + + /** + * Write the wrapped double to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + os.writeDouble(_value); + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/FloatValue.java b/libjava/classpath/gnu/classpath/jdwp/value/FloatValue.java new file mode 100644 index 000000000..ffd79f660 --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/FloatValue.java @@ -0,0 +1,99 @@ +/* FloatValue.java -- JDWP wrapper class for a float value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 +afloat with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an float value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public final class FloatValue + extends Value +{ + // The float wrapped by this class + float _value; + + /** + * Create a new FloatValue from an float + * + * @param value the float to wrap + */ + public FloatValue(float value) + { + super(JdwpConstants.Tag.FLOAT); + _value = value; + } + + /** + * Get the value held in this Value + * + * @return the value represented by this Value object + */ + public float getValue() + { + return _value; + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return new Float(_value); + } + + /** + * Write the wrapped float to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + os.writeFloat(_value); + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/IntValue.java b/libjava/classpath/gnu/classpath/jdwp/value/IntValue.java new file mode 100644 index 000000000..b1a07fd1e --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/IntValue.java @@ -0,0 +1,99 @@ +/* IntValue.java -- JDWP wrapper class for an int value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an int value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public final class IntValue + extends Value +{ + // The int wrapped by this class + int _value; + + /** + * Create a new IntValue from an int + * + * @param value the int to wrap + */ + public IntValue(int value) + { + super(JdwpConstants.Tag.INT); + _value = value; + } + + /** + * Get the value held in this Value + * + * @return the value represented by this Value object + */ + public int getValue() + { + return _value; + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return new Integer(_value); + } + + /** + * Write the wrapped int to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + os.writeInt(_value); + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/LongValue.java b/libjava/classpath/gnu/classpath/jdwp/value/LongValue.java new file mode 100644 index 000000000..748311708 --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/LongValue.java @@ -0,0 +1,99 @@ +/* LongValue.java -- JDWP wrapper class for a long value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an long value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public final class LongValue + extends Value +{ + // The long wrapped by this class + long _value; + + /** + * Create a new LongValue from an long + * + * @param value the long to wrap + */ + public LongValue(long value) + { + super(JdwpConstants.Tag.LONG); + _value = value; + } + + /** + * Get the value held in this Value + * + * @return the value represented by this Value object + */ + public long getValue() + { + return _value; + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return new Long(_value); + } + + /** + * Write the wrapped long to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + os.writeLong(_value); + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/ObjectValue.java b/libjava/classpath/gnu/classpath/jdwp/value/ObjectValue.java new file mode 100644 index 000000000..d7dc7dae9 --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/ObjectValue.java @@ -0,0 +1,102 @@ +/* ObjectValue.java -- JDWP wrapper class for an Object value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ObjectId; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an Object value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public final class ObjectValue + extends Value +{ + // The Object wrapped by this class + Object _value; + + /** + * Create a new ObjectValue from an Object + * + * @param value the Object to wrap + */ + public ObjectValue(Object value) + { + super(JdwpConstants.Tag.OBJECT); + _value = value; + } + + /** + * Get the value held in this Value + * + * @return the value represented by this Value object + */ + public Object getValue() + { + return _value; + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return _value; + } + + /** + * Write the wrapped object to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + ObjectId oid = VMIdManager.getDefault().getObjectId(_value); + oid.write(os); + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/ShortValue.java b/libjava/classpath/gnu/classpath/jdwp/value/ShortValue.java new file mode 100644 index 000000000..16fae4759 --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/ShortValue.java @@ -0,0 +1,99 @@ +/* ShortValue.java -- JDWP wrapper class for a short value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an short value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public final class ShortValue + extends Value +{ + // The short wrapped by this class + short _value; + + /** + * Create a new ShortValue from a short + * + * @param value the short to wrap + */ + public ShortValue(short value) + { + super(JdwpConstants.Tag.SHORT); + _value = value; + } + + /** + * Get the value held in this Value + * + * @return the value represented by this Value object + */ + public short getValue() + { + return _value; + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return new Short(_value); + } + + /** + * Write the wrapped short to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + os.writeShort(_value); + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/StringValue.java b/libjava/classpath/gnu/classpath/jdwp/value/StringValue.java new file mode 100644 index 000000000..f64661f9f --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/StringValue.java @@ -0,0 +1,103 @@ +/* StringValue.java -- JDWP wrapper class for an String value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ObjectId; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an String value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public final class StringValue + extends Value +{ + // The String wrapped by this class + String _value; + + /** + * Create a new StringValue from an String + * + * @param value the String to wrap + */ + public StringValue(String value) + { + super(JdwpConstants.Tag.STRING); + _value = value; + } + + /** + * Get the value held in this Value + * + * @return the value represented by this Value object + */ + public String getValue() + { + return _value; + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return _value; + } + + /** + * Write the wrapped object to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + ObjectId oid = VMIdManager.getDefault().getObjectId (_value); + oid.write (os); + + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/Value.java b/libjava/classpath/gnu/classpath/jdwp/value/Value.java new file mode 100644 index 000000000..39f1c9cce --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/Value.java @@ -0,0 +1,155 @@ +/* Value.java -- base class of JDWP values + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.exception.InvalidClassException; +import gnu.classpath.jdwp.exception.InvalidObjectException; +import gnu.classpath.jdwp.exception.InvalidTagException; +import gnu.classpath.jdwp.exception.JdwpInternalErrorException; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; + +/** + * Superclass for all JDWP Values. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public abstract class Value +{ + // A Tag representing the type of this value + private byte _tag; + + /** + * Create a new value of type tag. + * + * @param tag the type of the value + */ + protected Value(byte tag) + { + _tag = tag; + } + + /** + * Get the tag for this Value + * + * @return the byte tag of this Value + */ + public byte getTag() + { + return _tag; + } + + /** + * Calls the dervied classes writeValue method to write its value to the + * DataOutputStream. + * + * @param os write the value here + * @throws IOException + */ + public void writeUntagged(DataOutputStream os) + throws IOException + { + write(os); + } + + /** + * Will write the given object as a tagged value to the DataOutputStream. + * + * @param os write the value here + * @param obj the Object to write + * @throws IOException + */ + public void writeTagged(DataOutputStream os) + throws IOException + { + os.write (_tag); + write(os); + } + + /** + * This method must write the value to the DataOutputStream in a manner + * appropriate for the type of the value. + * + * @param os DataOutputStream to write to + * @throws IOException + */ + protected abstract void write(DataOutputStream os) + throws IOException; + + /** + * Returns an object representing this type + * + * @return an Object represntation of this value + */ + protected abstract Object getObject(); + + /** + * Get an untagged object from the ByteBuffer + * + * @param bb the ByteBuffer to extract the value from + * @param type a Class representing the type + * @return an Object from the ByteBuffer of the type of the Class parameter + * @throws JdwpInternalErrorException + * @throws InvalidObjectException + */ + public static Object getUntaggedObject(ByteBuffer bb, Class type) + throws JdwpInternalErrorException, InvalidObjectException, InvalidClassException + { + Value val = ValueFactory.createFromUntagged(bb, type); + return val.getObject(); + } + + /** + * Get an untagged object from the ByteBuffer + * + * @param bb the ByteBuffer to extract the value from + * @param tag a byte tag representing the type + * @return an Object from the ByteBuffer of the type of the Class parameter + * @throws JdwpInternalErrorException + * @throws InvalidObjectException + */ + public static Object getTaggedObject(ByteBuffer bb) + throws JdwpInternalErrorException, InvalidObjectException, InvalidTagException + { + Value val = ValueFactory.createFromTagged(bb); + return val.getObject(); + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/ValueFactory.java b/libjava/classpath/gnu/classpath/jdwp/value/ValueFactory.java new file mode 100644 index 000000000..ee7ddfae1 --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/ValueFactory.java @@ -0,0 +1,247 @@ +/* ValueFactory.java -- factory to create JDWP Values + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.exception.InvalidClassException; +import gnu.classpath.jdwp.exception.InvalidObjectException; +import gnu.classpath.jdwp.exception.InvalidTagException; +import gnu.classpath.jdwp.exception.JdwpInternalErrorException; +import gnu.classpath.jdwp.id.ObjectId; +import gnu.classpath.jdwp.util.JdwpString; + +import java.nio.ByteBuffer; + +/** + * A factory to create JDWP Values. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public class ValueFactory +{ + /** + * Creates a new Value of appropriate type for the value in the ByteBuffer + * by reading the tag byte from the front of the buffer. + * + * @param bb contains the Object + * @return A new Value of appropriate type + * @throws JdwpInternalErrorException + * @throws InvalidObjectException + */ + public static Value createFromTagged(ByteBuffer bb) + throws JdwpInternalErrorException, InvalidObjectException, InvalidTagException + { + return create(bb, bb.get()); + } + + /** + * Creates a new Value of appropriate type for the value in the ByteBuffer + * by checking the type of the Class passed in. + * + * @param bb contains the Object + * @param type a Class representing the type of the value in the ByteBuffer + * @return A new Value of appropriate type + * @throws JdwpInternalErrorException + * @throws InvalidObjectException + */ + public static Value createFromUntagged(ByteBuffer bb, Class type) + throws JdwpInternalErrorException, InvalidObjectException, InvalidClassException + { + byte tag = getTagForClass(type); + + try + { + return create(bb, tag); + } + catch (InvalidTagException ite) + { + throw new InvalidClassException(ite); + } + } + + /** + * Creates a new Value of appropriate type for the value in the ByteBuffer. + * + * @param bb contains the Object + * @param tag a byte representing the type of the object + * @return A new Value of appropriate type + * @throws JdwpInternalErrorException + * @throws InvalidObjectException + */ + private static Value create(ByteBuffer bb, byte tag) + throws JdwpInternalErrorException, InvalidObjectException, InvalidTagException + { + Value val = null; + switch(tag) + { + case JdwpConstants.Tag.BYTE: + val = new ByteValue(bb.get()); + break; + case JdwpConstants.Tag.BOOLEAN: + val = new BooleanValue((bb.get() != 0)); + break; + case JdwpConstants.Tag.CHAR: + val = new CharValue(bb.getChar()); + break; + case JdwpConstants.Tag.SHORT: + val = new ShortValue(bb.getShort()); + break; + case JdwpConstants.Tag.INT: + val = new IntValue(bb.getInt()); + break; + case JdwpConstants.Tag.FLOAT: + val = new FloatValue(bb.getFloat()); + break; + case JdwpConstants.Tag.LONG: + val = new LongValue(bb.getLong()); + break; + case JdwpConstants.Tag.DOUBLE: + val = new DoubleValue(bb.getDouble()); + break; + case JdwpConstants.Tag.VOID: + val = new VoidValue(); + break; + case JdwpConstants.Tag.ARRAY: + case JdwpConstants.Tag.THREAD: + case JdwpConstants.Tag.OBJECT: + case JdwpConstants.Tag.THREAD_GROUP: + case JdwpConstants.Tag.CLASS_LOADER: + case JdwpConstants.Tag.CLASS_OBJECT: + ObjectId oid = VMIdManager.getDefault().readObjectId(bb); + val = new ObjectValue(oid.getObject()); + break; + case JdwpConstants.Tag.STRING: + val = new StringValue(JdwpString.readString(bb)); + break; + default: + throw new InvalidTagException(tag); + } + + return val; + } + + /** + * Creates a tag for the type of the class. + * + * @param klass the type to get a tag for + * @return a byte tag representing the class + * @throws JdwpInternalErrorException + * @throws InvalidObjectException + */ + private static byte getTagForClass(Class klass) + throws JdwpInternalErrorException + { + byte tag; + + if (klass.isPrimitive()) + { + if (klass == byte.class) + tag = JdwpConstants.Tag.BYTE; + else if (klass == boolean.class) + tag = JdwpConstants.Tag.BOOLEAN; + else if (klass == char.class) + tag = JdwpConstants.Tag.CHAR; + else if (klass == short.class) + tag = JdwpConstants.Tag.SHORT; + else if (klass == int.class) + tag = JdwpConstants.Tag.INT; + else if (klass == float.class) + tag = JdwpConstants.Tag.FLOAT; + else if (klass == long.class) + tag = JdwpConstants.Tag.LONG; + else if (klass == double.class) + tag = JdwpConstants.Tag.DOUBLE; + else if (klass == void.class) + tag = JdwpConstants.Tag.VOID; + else + throw new JdwpInternalErrorException("Invalid primitive class"); + } + else + { + tag = JdwpConstants.Tag.OBJECT; + } + + return tag; + } + + /** + * Create a value type for an Object of type determined by a Class. This is + * a special case where a value needs to be created, but the value to create + * it for is already in an object, not in a buffer. + * + * @param value the Object to convert to a Value + * @param type the Class type of the object + * @return a new Value representing this object + */ + public static Value createFromObject(Object value, Class type) + { + Value val = null; + + if (type.isPrimitive()) + { + if (type == byte.class) + val = new ByteValue(((Byte) value).byteValue()); + else if (type == boolean.class) + val = new BooleanValue(((Boolean) value).booleanValue()); + else if (type == char.class) + val = new CharValue(((Character) value).charValue()); + else if (type == short.class) + val = new ShortValue(((Short) value).shortValue()); + else if (type == int.class) + val = new IntValue(((Integer) value).intValue()); + else if (type == float.class) + val = new FloatValue(((Float) value).floatValue()); + else if (type == long.class) + val = new LongValue(((Long) value).longValue()); + else if (type == double.class) + val = new DoubleValue(((Double) value).doubleValue()); + else if (type == void.class) + val = new VoidValue(); + } + else + { + if (type.isAssignableFrom(String.class)) + val = new StringValue ((String) value); + else + val = new ObjectValue(value); + } + + return val; + } +} diff --git a/libjava/classpath/gnu/classpath/jdwp/value/VoidValue.java b/libjava/classpath/gnu/classpath/jdwp/value/VoidValue.java new file mode 100644 index 000000000..ae117347d --- /dev/null +++ b/libjava/classpath/gnu/classpath/jdwp/value/VoidValue.java @@ -0,0 +1,82 @@ +/* VoidValue.java -- JDWP wrapper class for a void value + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.value; + +import gnu.classpath.jdwp.JdwpConstants; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Wrapper for an void value. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public class VoidValue + extends Value +{ + /** + * Create a new VoidValue. + */ + public VoidValue () + { + super(JdwpConstants.Tag.VOID); + } + + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + @Override + protected Object getObject() + { + return null; + } + + /** + * Write the wrapped void to the given DataOutputStream. + * + * @param os the output stream to write to + */ + @Override + protected void write(DataOutputStream os) + throws IOException + { + } +} |