KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > memory > renderings > TableRenderingContentDescriptor


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.debug.internal.ui.views.memory.renderings;
13
14 import java.math.BigInteger JavaDoc;
15
16 import org.eclipse.debug.core.DebugException;
17 import org.eclipse.debug.core.model.IMemoryBlock;
18 import org.eclipse.debug.core.model.IMemoryBlockExtension;
19
20 public class TableRenderingContentDescriptor{
21     private AbstractBaseTableRendering fRendering;
22     private int fPreBuffer; // number of lines before the top visible line
23
private int fPostBuffer; // number of lines after thes last visible line
24
private BigInteger JavaDoc fLoadAddress; // Top address to load at the table
25
private int fNumLines; // number of visible lines
26
private BigInteger JavaDoc fMemoryBlockBaseAddress; // base address of the memory block when this input is set
27
private BigInteger JavaDoc fStartAddress;
28     private BigInteger JavaDoc fEndAddress;
29     
30     private int fAddressSize = -1;
31     private int fAddressableSize = -1;
32     
33     private boolean fAlignAddress = true;
34     
35     private boolean fIsDynamicLoad;
36     
37     public TableRenderingContentDescriptor(AbstractBaseTableRendering rendering)
38     {
39         fRendering = rendering;
40     }
41
42     public int getPostBuffer() {
43         return fPostBuffer;
44     }
45     public int getPreBuffer() {
46         return fPreBuffer;
47     }
48     public BigInteger JavaDoc getLoadAddress() {
49         return fLoadAddress;
50     }
51     
52     public IMemoryBlock getMemoryBlock()
53     {
54         return fRendering.getMemoryBlock();
55     }
56     public void setPostBuffer(int postBuffer) {
57         fPostBuffer = postBuffer;
58     }
59     public void setPreBuffer(int preBuffer) {
60         fPreBuffer = preBuffer;
61     }
62
63     public void setLoadAddress(BigInteger JavaDoc address)
64     {
65         fLoadAddress = address;
66     }
67     public BigInteger JavaDoc getContentBaseAddress() {
68         
69         if (fMemoryBlockBaseAddress == null)
70         {
71             try {
72                 updateContentBaseAddress();
73             } catch (DebugException e) {
74                 fMemoryBlockBaseAddress = new BigInteger JavaDoc("0"); //$NON-NLS-1$
75
}
76         }
77         
78         return fMemoryBlockBaseAddress;
79     }
80     
81     public void updateContentBaseAddress() throws DebugException {
82         IMemoryBlock memoryBlock = fRendering.getMemoryBlock();
83         if (memoryBlock instanceof IMemoryBlockExtension)
84             fMemoryBlockBaseAddress = ((IMemoryBlockExtension)memoryBlock).getBigBaseAddress();
85         else
86             fMemoryBlockBaseAddress = BigInteger.valueOf(memoryBlock.getStartAddress());
87     }
88     
89     /**
90      * @return start address of the memory block
91      */

92     public BigInteger JavaDoc getStartAddress()
93     {
94         if (fStartAddress == null)
95         {
96             try {
97                 IMemoryBlock memoryBlock = fRendering.getMemoryBlock();
98                 if(memoryBlock instanceof IMemoryBlockExtension)
99                 {
100                     BigInteger JavaDoc startAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockStartAddress();
101                     if (startAddress != null)
102                         fStartAddress = startAddress;
103                 }
104             } catch (DebugException e) {
105                 // default to 0 if we have trouble getting the start address
106
fStartAddress = BigInteger.valueOf(0);
107             }
108             
109             if (fStartAddress == null)
110                 fStartAddress = BigInteger.valueOf(0);
111         }
112         return fStartAddress;
113     }
114     
115     /**
116      * @return end address of the memory block
117      */

118     public BigInteger JavaDoc getEndAddress()
119     {
120         if (fEndAddress == null)
121         {
122             IMemoryBlock memoryBlock = fRendering.getMemoryBlock();
123             if(memoryBlock instanceof IMemoryBlockExtension)
124             {
125                 BigInteger JavaDoc endAddress;
126                 try {
127                     endAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockEndAddress();
128                     if (endAddress != null)
129                         fEndAddress = endAddress;
130                 } catch (DebugException e) {
131                     fEndAddress = null;
132                 }
133                 
134                 if (fEndAddress == null)
135                 {
136                     int addressSize;
137                     try {
138                         addressSize = ((IMemoryBlockExtension)memoryBlock).getAddressSize();
139                     } catch (DebugException e) {
140                         addressSize = 4;
141                     }
142                     
143                     endAddress = BigInteger.valueOf(2);
144                     endAddress = endAddress.pow(addressSize*8);
145                     endAddress = endAddress.subtract(BigInteger.valueOf(1));
146                     fEndAddress = endAddress;
147                 }
148             }
149             
150             if (fEndAddress == null)
151                 fEndAddress = BigInteger.valueOf(Integer.MAX_VALUE);
152         }
153         return fEndAddress;
154     }
155     
156     public int getNumLines()
157     {
158         return fNumLines;
159     }
160     
161     public void setNumLines(int numLines)
162     {
163         fNumLines = numLines;
164     }
165     
166     public AbstractBaseTableRendering getRendering()
167     {
168         return fRendering;
169     }
170
171     public int getAddressableSize() {
172         return fAddressableSize;
173     }
174
175     public void setAddressableSize(int addressableSize) {
176         fAddressableSize = addressableSize;
177     }
178
179     public int getAddressSize() {
180         return fAddressSize;
181     }
182
183     public void setAddressSize(int addressSize) {
184         fAddressSize = addressSize;
185     }
186     
187     public void setDynamicLoad(boolean dynamic)
188     {
189         fIsDynamicLoad = dynamic;
190     }
191     
192     public boolean isDynamicLoad()
193     {
194         return fIsDynamicLoad;
195     }
196     
197     public boolean isMemoryBlockBaseAddressInitialized()
198     {
199         return (fMemoryBlockBaseAddress != null);
200     }
201     
202     public boolean isAlignAddressToBoundary()
203     {
204         return fAlignAddress;
205     }
206     
207     public void setAlignAddressToBoundary(boolean align)
208     {
209         fAlignAddress = align;
210     }
211
212 }
213
Popular Tags