1 /*******************************************************************************
2  * Copyright (c) 2000, 2015 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.debug.internal.ui.views.variables;
15 
16 import org.eclipse.debug.core.DebugException;
17 import org.eclipse.debug.core.ILaunch;
18 import org.eclipse.debug.core.model.IDebugTarget;
19 import org.eclipse.debug.core.model.IIndexedValue;
20 import org.eclipse.debug.core.model.IVariable;
21 import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
22 
23 /**
24  * A parition (subrange) of values of an indexed value
25  */
26 public class IndexedValuePartition implements IIndexedValue {
27 
28 	// the starting offset of this parition, into the associated collection
29 	private int fOffset;
30 
31 	// the length of this partition
32 	private int fLength;
33 
34 	// the indexed value
35 	private IIndexedValue fValue;
36 
37 	/**
38 	 * Creates a parition for an indexed value.
39 	 *
40 	 * @param value indexed value
41 	 * @param offset beginning offset of this partition (into the value)
42 	 * @param length the length of this parition
43 	 */
IndexedValuePartition(IIndexedValue value, int offset, int length)44 	public IndexedValuePartition(IIndexedValue value, int offset, int length) {
45 		fValue = value;
46 		fOffset = offset;
47 		fLength = length;
48 	}
49 
50 	@Override
getSize()51 	public int getSize() {
52 		return fLength;
53 	}
54 
55 	@Override
getVariable(int offset)56 	public IVariable getVariable(int offset) throws DebugException {
57 		return fValue.getVariable(offset);
58 	}
59 
60 	@Override
getReferenceTypeName()61 	public String getReferenceTypeName() throws DebugException {
62 		return fValue.getReferenceTypeName();
63 	}
64 
65 	@Override
getValueString()66 	public String getValueString() {
67 		return IInternalDebugCoreConstants.EMPTY_STRING;
68 	}
69 
70 	@Override
getVariables()71 	public IVariable[] getVariables() throws DebugException {
72 		return getVariables(fOffset, fLength);
73 	}
74 
75 	@Override
hasVariables()76 	public boolean hasVariables() {
77 		return fLength > 0;
78 	}
79 
80 	@Override
isAllocated()81 	public boolean isAllocated() throws DebugException {
82 		return fValue.isAllocated();
83 	}
84 
85 	@Override
getDebugTarget()86 	public IDebugTarget getDebugTarget() {
87 		return fValue.getDebugTarget();
88 	}
89 
90 	@Override
getLaunch()91 	public ILaunch getLaunch() {
92 		return fValue.getLaunch();
93 	}
94 
95 	@Override
getModelIdentifier()96 	public String getModelIdentifier() {
97 		return fValue.getModelIdentifier();
98 	}
99 
100 	@Override
getAdapter(Class<T> adapter)101 	public <T> T getAdapter(Class<T> adapter) {
102 		return fValue.getAdapter(adapter);
103 	}
104 
105 	@Override
getVariables(int offset, int length)106 	public IVariable[] getVariables(int offset, int length) throws DebugException {
107 		return fValue.getVariables(offset, length);
108 	}
109 
110 	@Override
getInitialOffset()111 	public int getInitialOffset() {
112 		return fOffset;
113 	}
114 
115 }
116