Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIArrayValue.java')
-rw-r--r--org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIArrayValue.java180
1 files changed, 118 insertions, 62 deletions
diff --git a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIArrayValue.java b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIArrayValue.java
index cc084f025..c2c24be23 100644
--- a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIArrayValue.java
+++ b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIArrayValue.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.jdt.internal.debug.core.model;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -27,14 +26,18 @@ import com.sun.jdi.ClassNotLoadedException;
import com.sun.jdi.InvalidTypeException;
import com.sun.jdi.Value;
-public class JDIArrayValue extends JDIObjectValue implements IJavaArray, IIndexedValue{
-
- private int fLength = -1;
+public class JDIArrayValue extends JDIObjectValue implements IJavaArray,
+ IIndexedValue {
+
+ private int fLength = -1;
/**
* Constructs a value which is a reference to an array.
- * @param target debug target on which the array exists
- * @param value the reference to the array
+ *
+ * @param target
+ * debug target on which the array exists
+ * @param value
+ * the reference to the array
*/
public JDIArrayValue(JDIDebugTarget target, ArrayReference value) {
super(target, value);
@@ -44,13 +47,13 @@ public class JDIArrayValue extends JDIObjectValue implements IJavaArray, IIndexe
* @see IJavaArray#getValues()
*/
public IJavaValue[] getValues() throws DebugException {
- List list = getUnderlyingValues();
+ List<Value> list = getUnderlyingValues();
int count = list.size();
IJavaValue[] values = new IJavaValue[count];
JDIDebugTarget target = (JDIDebugTarget) getDebugTarget();
for (int i = 0; i < count; i++) {
- Value value = (Value)list.get(i);
+ Value value = list.get(i);
values[i] = JDIValue.createValue(target, value);
}
return values;
@@ -61,7 +64,7 @@ public class JDIArrayValue extends JDIObjectValue implements IJavaArray, IIndexe
*/
public IJavaValue getValue(int index) throws DebugException {
Value v = getUnderlyingValue(index);
- return JDIValue.createValue((JDIDebugTarget)getDebugTarget(), v);
+ return JDIValue.createValue((JDIDebugTarget) getDebugTarget(), v);
}
/**
@@ -72,7 +75,10 @@ public class JDIArrayValue extends JDIObjectValue implements IJavaArray, IIndexe
try {
fLength = getArrayReference().length();
} catch (RuntimeException e) {
- targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayValue_exception_while_retrieving_array_length, new String[] {e.toString()}), e);
+ targetRequestFailed(
+ MessageFormat.format(
+ JDIDebugModelMessages.JDIArrayValue_exception_while_retrieving_array_length,
+ e.toString()), e);
}
}
return fLength;
@@ -83,39 +89,52 @@ public class JDIArrayValue extends JDIObjectValue implements IJavaArray, IIndexe
*/
public void setValue(int index, IJavaValue value) throws DebugException {
try {
- getArrayReference().setValue(index, ((JDIValue)value).getUnderlyingValue());
+ getArrayReference().setValue(index,
+ ((JDIValue) value).getUnderlyingValue());
} catch (IndexOutOfBoundsException e) {
throw e;
} catch (InvalidTypeException e) {
- targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array, new String[] {e.toString()}), e);
+ targetRequestFailed(
+ MessageFormat.format(
+ JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array,
+ e.toString()), e);
} catch (ClassNotLoadedException e) {
- targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array, new String[] {e.toString()}), e);
+ targetRequestFailed(
+ MessageFormat.format(
+ JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array,
+ e.toString()), e);
} catch (RuntimeException e) {
- targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array, new String[] {e.toString()}), e);
+ targetRequestFailed(
+ MessageFormat.format(
+ JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array,
+ e.toString()), e);
}
}
/**
- * Returns the underlying array reference for this
- * array.
+ * Returns the underlying array reference for this array.
*
* @return underlying array reference
*/
+ @Override
protected ArrayReference getArrayReference() {
- return (ArrayReference)getUnderlyingValue();
+ return (ArrayReference) getUnderlyingValue();
}
-
+
/**
- * Returns the underlying value at the given index
- * from the underlying array reference.
+ * Returns the underlying value at the given index from the underlying array
+ * reference.
*
- * @param index the index at which to retrieve a value
+ * @param index
+ * the index at which to retrieve a value
* @return value
- * @exception DebugException if this method fails. Reasons include:<ul>
- * <li>Failure communicating with the VM. The DebugException's
- * status code contains the underlying exception responsible for
- * the failure.</li>
- * </ul>
+ * @exception DebugException
+ * if this method fails. Reasons include:
+ * <ul>
+ * <li>Failure communicating with the VM. The
+ * DebugException's status code contains the underlying
+ * exception responsible for the failure.</li>
+ * </ul>
*/
protected Value getUnderlyingValue(int index) throws DebugException {
try {
@@ -123,111 +142,149 @@ public class JDIArrayValue extends JDIObjectValue implements IJavaArray, IIndexe
} catch (IndexOutOfBoundsException e) {
throw e;
} catch (RuntimeException e) {
- targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayValue_exception_while_retrieving_value_from_array, new String[] {e.toString()}), e);
+ targetRequestFailed(
+ MessageFormat.format(
+ JDIDebugModelMessages.JDIArrayValue_exception_while_retrieving_value_from_array,
+ e.toString()), e);
}
// execution will not reach this line as
// an exception will be thrown
return null;
}
-
+
/**
- * Returns the underlying values
- * from the underlying array reference.
+ * Returns the underlying values from the underlying array reference.
*
* @return list of values
- * @exception DebugException if this method fails. Reasons include:<ul>
- * <li>Failure communicating with the VM. The DebugException's
- * status code contains the underlying exception responsible for
- * the failure.</li>
- * </ul>
+ * @exception DebugException
+ * if this method fails. Reasons include:
+ * <ul>
+ * <li>Failure communicating with the VM. The
+ * DebugException's status code contains the underlying
+ * exception responsible for the failure.</li>
+ * </ul>
*/
- protected List getUnderlyingValues() throws DebugException {
+ protected List<Value> getUnderlyingValues() throws DebugException {
try {
return getArrayReference().getValues();
} catch (IndexOutOfBoundsException e) {
return Collections.EMPTY_LIST;
} catch (RuntimeException e) {
- targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayValue_exception_while_retrieving_values_from_array, new String[] {e.toString()}), e);
+ targetRequestFailed(
+ MessageFormat.format(
+ JDIDebugModelMessages.JDIArrayValue_exception_while_retrieving_values_from_array,
+ e.toString()), e);
}
// execution will not reach this line as
// an exception will be thrown
return null;
- }
+ }
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.debug.core.model.IIndexedValue#getSize()
*/
public int getSize() throws DebugException {
return getLength();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.debug.core.model.IIndexedValue#getVariable(int)
*/
public IVariable getVariable(int offset) throws DebugException {
if (offset >= getLength()) {
- requestFailed(JDIDebugModelMessages.JDIArrayValue_6, null);
+ requestFailed(JDIDebugModelMessages.JDIArrayValue_6, null);
}
- return new JDIArrayEntryVariable(getJavaDebugTarget(), getArrayReference(), offset, fLogicalParent);
+ return new JDIArrayEntryVariable(getJavaDebugTarget(),
+ getArrayReference(), offset, fLogicalParent);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.debug.core.model.IIndexedValue#getVariables(int, int)
*/
- public IVariable[] getVariables(int offset, int length) throws DebugException {
+ public IVariable[] getVariables(int offset, int length)
+ throws DebugException {
if (offset >= getLength()) {
- requestFailed(JDIDebugModelMessages.JDIArrayValue_6, null);
+ requestFailed(JDIDebugModelMessages.JDIArrayValue_6, null);
}
if ((offset + length - 1) >= getLength()) {
- requestFailed(JDIDebugModelMessages.JDIArrayValue_8, null);
+ requestFailed(JDIDebugModelMessages.JDIArrayValue_8, null);
}
IVariable[] variables = new IVariable[length];
int index = offset;
for (int i = 0; i < length; i++) {
- variables[i] = new JDIArrayEntryVariable(getJavaDebugTarget(), getArrayReference(), index, fLogicalParent);
+ variables[i] = new JDIArrayEntryVariable(getJavaDebugTarget(),
+ getArrayReference(), index, fLogicalParent);
index++;
}
return variables;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.debug.core.model.IIndexedValue#getInitialOffset()
*/
public int getInitialOffset() {
return 0;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.debug.core.model.IValue#hasVariables()
*/
+ @Override
public boolean hasVariables() throws DebugException {
return getLength() > 0;
}
- /* (non-Javadoc)
- * @see org.eclipse.jdt.debug.core.IJavaArray#setValues(int, int, org.eclipse.jdt.debug.core.IJavaValue[], int)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jdt.debug.core.IJavaArray#setValues(int, int,
+ * org.eclipse.jdt.debug.core.IJavaValue[], int)
*/
- public void setValues(int offset, int length, IJavaValue[] values, int startOffset) throws DebugException {
+ public void setValues(int offset, int length, IJavaValue[] values,
+ int startOffset) throws DebugException {
try {
- List list = new ArrayList(values.length);
- for (int i = 0; i < values.length; i++) {
- list.add(((JDIValue)values[i]).getUnderlyingValue());
+ List<Value> list = new ArrayList<Value>(values.length);
+ for (IJavaValue value : values) {
+ list.add(((JDIValue) value).getUnderlyingValue());
}
getArrayReference().setValues(offset, list, startOffset, length);
} catch (IndexOutOfBoundsException e) {
throw e;
} catch (InvalidTypeException e) {
- targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array, new String[] {e.toString()}), e);
+ targetRequestFailed(
+ MessageFormat.format(
+ JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array,
+ e.toString()), e);
} catch (ClassNotLoadedException e) {
- targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array, new String[] {e.toString()}), e);
+ targetRequestFailed(
+ MessageFormat.format(
+ JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array,
+ e.toString()), e);
} catch (RuntimeException e) {
- targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array, new String[] {e.toString()}), e);
+ targetRequestFailed(
+ MessageFormat.format(
+ JDIDebugModelMessages.JDIArrayValue_exception_while_setting_value_in_array,
+ e.toString()), e);
}
-
+
}
- /* (non-Javadoc)
- * @see org.eclipse.jdt.debug.core.IJavaArray#setValues(org.eclipse.jdt.debug.core.IJavaValue[])
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jdt.debug.core.IJavaArray#setValues(org.eclipse.jdt.debug
+ * .core.IJavaValue[])
*/
public void setValues(IJavaValue[] values) throws DebugException {
int length = Math.min(values.length, getSize());
@@ -235,4 +292,3 @@ public class JDIArrayValue extends JDIObjectValue implements IJavaArray, IIndexe
}
}
-

Back to the top