Source Code Cross Referenced for EclipseDebuggerModel.java in  » XML-UI » xui32 » com » xoetrope » editor » eclipse » visualizer » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML UI » xui32 » com.xoetrope.editor.eclipse.visualizer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.editor.eclipse.visualizer;
002:
003:        import net.xoetrope.xui.data.XModel;
004:        import net.xoetrope.xui.helper.NumberFormatter;
005:
006:        import org.eclipse.jdt.debug.core.IJavaDebugTarget;
007:        import org.eclipse.jdt.debug.core.IJavaObject;
008:        import org.eclipse.jdt.debug.core.IJavaStackFrame;
009:        import org.eclipse.jdt.debug.core.IJavaThread;
010:        import org.eclipse.jdt.debug.core.IJavaType;
011:        import org.eclipse.jdt.debug.core.IJavaValue;
012:
013:        import com.xoetrope.carousel.visualizer.VisualiserDebuggerModel;
014:
015:        public class EclipseDebuggerModel extends VisualiserDebuggerModel {
016:            private IJavaStackFrame stackFrame;
017:            private IJavaObject modelNode;
018:
019:            private static IJavaValue[] oneArgsArray = new IJavaValue[1];
020:            private static IJavaValue[] twoArgsArray = new IJavaValue[2];
021:            private static IJavaValue[] threeArgsArray = new IJavaValue[3];
022:
023:            /**
024:             * Creates a new instance of <code>EclipseDebuggerModel</code>
025:             * @param sFrame a stack frame in a thread on a JVM
026:             * @param jObject <code>IjavaObject</code> instance that is to be adapted
027:             * by this object.
028:             */
029:            public EclipseDebuggerModel(IJavaStackFrame sFrame,
030:                    IJavaObject jObject) {
031:                stackFrame = sFrame;
032:                modelNode = jObject;
033:            }
034:
035:            /**
036:             * Calls the <code>getValueString()</code> method on the encapsulated
037:             * <code>IJavaObject</code> instance. 
038:             */
039:            public String getNodeString() {
040:                String val = null;
041:                try {
042:                    val = modelNode.getValueString();
043:                } catch (Exception ex) {
044:                    val = null;
045:                }
046:                return val;
047:            }
048:
049:            public XModel reset() {
050:                throw new UnsupportedOperationException();
051:            }
052:
053:            public void setTagName(String name) {
054:                try {
055:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
056:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
057:                            .getDebugTarget();
058:                    oneArgsArray[0] = target.newValue(name);
059:                    modelNode.sendMessage("setTagName",
060:                            "(Ljava/lang/String;)V", oneArgsArray, thread,
061:                            false);
062:                } catch (Exception ex) {
063:                    ex.printStackTrace();
064:                }
065:            }
066:
067:            public String getTagName() {
068:                String val = null;
069:                try {
070:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
071:                    IJavaObject tagName = (IJavaObject) modelNode.sendMessage(
072:                            "getTagName", "()Ljava/lang/String;", null, thread,
073:                            false);
074:                    val = tagName.getValueString();
075:                } catch (Exception ex) {
076:                    val = null;
077:                    ex.printStackTrace();
078:                }
079:                return val;
080:            }
081:
082:            /**
083:             * Determine if there is no id set for this model in the datasource
084:             * @return true if there was no name for the element in the DataSource, an
085:             * example of this is the annonymouse nodes used to represent the record of
086:             * a table e.g. <tr><td>...</td><td>...</td></tr>
087:             */
088:            public boolean hasAutoId() {
089:                boolean val = false;
090:                try {
091:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
092:                    IJavaValue hasAutoId = modelNode.sendMessage("hasAutoId",
093:                            "()Z;", null, thread, false);
094:                    val = "true".equals(hasAutoId.getValueString());
095:                } catch (Exception ex) {
096:                    val = false;
097:                    ex.printStackTrace();
098:                }
099:                return val;
100:            }
101:
102:            /**
103:             * Gets the value of the ID attribute
104:             * @return the ID attribute
105:             */
106:            public String getId() {
107:                String val = null;
108:                try {
109:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
110:                    IJavaObject id = (IJavaObject) modelNode.sendMessage(
111:                            "getId", "()Ljava/lang/String;", null, thread,
112:                            false);
113:                    val = id.getValueString();
114:                } catch (Exception ex) {
115:                    val = null;
116:                    ex.printStackTrace();
117:                }
118:                return val;
119:            }
120:
121:            /**
122:             * Sets the ID attribute
123:             * @param newId the new name
124:             */
125:            public void setId(String newId) {
126:                try {
127:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
128:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
129:                            .getDebugTarget();
130:                    oneArgsArray[0] = target.newValue(newId);
131:                    modelNode.sendMessage("setId", "(Ljava/lang/String;)V",
132:                            oneArgsArray, thread, false);
133:                } catch (Exception ex) {
134:                    ex.printStackTrace();
135:                }
136:            }
137:
138:            /**
139:             * Get the value of the element located at the path in the element parameter
140:             * If the attribName parameter is not null we get the value of the attributeValues.
141:             * @param element the path to the XModel we require
142:             * @return the value of the XModel or the attribute
143:             */
144:            public Object get(String element) {
145:                Object val = null;
146:                try {
147:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
148:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
149:                            .getDebugTarget();
150:                    oneArgsArray[0] = target.newValue(element);
151:                    IJavaObject child = (IJavaObject) modelNode.sendMessage(
152:                            "get", "(Ljava/lang/String;)Ljava/lang/Object;",
153:                            oneArgsArray, thread, false);
154:                    val = new EclipseDebuggerModel(stackFrame, child);
155:                } catch (Exception ex) {
156:                    val = null;
157:                    ex.printStackTrace();
158:                }
159:                return val;
160:            }
161:
162:            /**
163:             * Set the named attribute value of this XModel node. If the attribute name if null
164:             * than this node's value is updated.
165:             * @param elementName The path to the XModel in the format "base/foo"
166:             * @param newObject The new value of the XModel
167:             */
168:            public void set(String elementName, Object newObject) {
169:                throw new UnsupportedOperationException();
170:            }
171:
172:            /**
173:             * Returns the index of the attribiteNames array whose value is the same
174:             * as the attribName
175:             * @param attribName The name of the attribute we are trying to locate
176:             * @return The index of the attributeNames array containg the name
177:             */
178:            public int getAttribute(String attribName) {
179:                int val = 0;
180:                try {
181:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
182:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
183:                            .getDebugTarget();
184:                    oneArgsArray[0] = target.newValue(attribName);
185:                    IJavaValue attribute = modelNode.sendMessage(
186:                            "getAttribute", "(Ljava/lang/String;)I",
187:                            oneArgsArray, thread, false);
188:                    val = Integer.parseInt(attribute.getValueString());
189:                } catch (Exception ex) {
190:                    val = 0; // TODO: val = -1 ???
191:                    ex.printStackTrace();
192:                }
193:                return val;
194:            }
195:
196:            /**
197:             * Sets the attribute value
198:             * @param i The index of the attributeValues array whose value we want
199:             * @param value the value object
200:             */
201:            public void setAttribValue(int i, Object value) {
202:                throw new UnsupportedOperationException();
203:            }
204:
205:            /**
206:             * Sets the attribute name and value
207:             * @param i The index of the attributeValues array whose value we want
208:             * @param attribName the name of the attribute
209:             * @param value the value object
210:             */
211:            public void setAttribValue(int i, String attribName, Object value) {
212:                throw new UnsupportedOperationException();
213:            }
214:
215:            /**
216:             * Get the XModel at element i
217:             * @param i The index of the values array
218:             * @return The XModel at location i
219:             */
220:            public XModel get(int i) {
221:                XModel val = null;
222:                try {
223:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
224:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
225:                            .getDebugTarget();
226:                    oneArgsArray[0] = target.newValue(i);
227:                    IJavaObject child = (IJavaObject) modelNode.sendMessage(
228:                            "get", "(I)Lnet/xoetrope/xui/data/XModel;",
229:                            oneArgsArray, thread, false);
230:                    val = new EclipseDebuggerModel(stackFrame, child);
231:                } catch (Exception ex) {
232:                    val = null;
233:                    ex.printStackTrace();
234:                }
235:                return val;
236:            }
237:
238:            /**
239:             * Retrieve the parent XModel of this XModel instance
240:             * @return The parent XModel to which this instance belongs
241:             */
242:            public XModel getParent() {
243:                XModel val = null;
244:                try {
245:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
246:                    IJavaObject parent = (IJavaObject) modelNode.sendMessage(
247:                            "getParent", "()Lnet/xoetrope/xui/data/XModel;",
248:                            null, thread, false);
249:                    val = new EclipseDebuggerModel(stackFrame, parent);
250:                } catch (Exception ex) {
251:                    val = null;
252:                    ex.printStackTrace();
253:                }
254:                return val;
255:            }
256:
257:            /**
258:             * Gets the value attribute
259:             * @return the value of the model
260:             */
261:            public Object get() {
262:                Object val = null;
263:                try {
264:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
265:                    IJavaObject object = (IJavaObject) modelNode.sendMessage(
266:                            "get", "()Ljava/lang/Object;", null, thread, false);
267:                    IJavaType type = object.getJavaType();
268:                    if (type != null)
269:                        val = ("java.lang.String".equals(type.getName()) ? object
270:                                .getValueString()
271:                                : new EclipseDebuggerModel(stackFrame, object));
272:
273:                } catch (Exception ex) {
274:                    ex.printStackTrace();
275:                }
276:                return val;
277:            }
278:
279:            /**
280:             * Sets the model value
281:             * @param s the new value
282:             */
283:            public void set(Object object) {
284:                throw new UnsupportedOperationException();
285:            }
286:
287:            /**
288:             * Used for elements which need a name assigned temporarily because one doesn't
289:             * exist in the DataSource.
290:             * @param b true if there was no name in the DataSource
291:             */
292:            public void hasAutoId(boolean b) {
293:                try {
294:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
295:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
296:                            .getDebugTarget();
297:                    oneArgsArray[0] = target.newValue(b);
298:                    modelNode.sendMessage("hasAutoId", "(Z)V", oneArgsArray,
299:                            thread, false);
300:                } catch (Exception ex) {
301:                    ex.printStackTrace();
302:                }
303:            }
304:
305:            /**
306:             * Retrieve the name of the attribute at the specified index
307:             * @param i the index of the attributeNames array whose value we want
308:             * @param the string value of the attributeNames array at position i
309:             */
310:            public String getAttribName(int i) {
311:                String val = null;
312:                try {
313:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
314:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
315:                            .getDebugTarget();
316:                    oneArgsArray[0] = target.newValue(i);
317:                    IJavaObject attribName = (IJavaObject) modelNode
318:                            .sendMessage("getAttribName",
319:                                    "(I)Ljava/lang/String;", oneArgsArray,
320:                                    thread, false);
321:                    if (attribName != null)
322:                        val = attribName.getValueString();
323:                } catch (Exception ex) {
324:                    ex.printStackTrace();
325:                }
326:                return val;
327:            }
328:
329:            /**
330:             * Retrieve the value of the attribute at the specified index, convert it to a
331:             * String and return it.
332:             * @param i The index of the attributeValues array whose value we want
333:             * @return The string value of the attributeValues array at position i
334:             */
335:            public String getAttribValueAsString(int i) {
336:                String val = null;
337:                try {
338:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
339:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
340:                            .getDebugTarget();
341:                    oneArgsArray[0] = target.newValue(i);
342:                    IJavaObject attribValue = (IJavaObject) modelNode
343:                            .sendMessage("getAttribValueAsString",
344:                                    "(I)Ljava/lang/String;", oneArgsArray,
345:                                    thread, false);
346:                    if (attribValue != null)
347:                        val = attribValue.getValueString();
348:                } catch (Exception ex) {
349:                    val = null;
350:                    ex.printStackTrace();
351:                }
352:                return val;
353:            }
354:
355:            /**
356:             * Retrieve the value of the attribute at the specified index and return it.
357:             * @param i The index of the attributeValues array whose value we want
358:             * @return The string value of the attributeValues array at position i
359:             */
360:            public Object getAttribValue(int i) {
361:                Object val = null;
362:                try {
363:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
364:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
365:                            .getDebugTarget();
366:                    oneArgsArray[0] = target.newValue(i);
367:                    IJavaObject attribValue = (IJavaObject) modelNode
368:                            .sendMessage("getAttribValue",
369:                                    "(I)Ljava/lang/Object;", oneArgsArray,
370:                                    thread, false);
371:                    val = new EclipseDebuggerModel(stackFrame, attribValue);
372:                } catch (Exception ex) {
373:                    val = null;
374:                    ex.printStackTrace();
375:                }
376:                return val;
377:            }
378:
379:            /**
380:             * Retrieve the value of the attribute at the specified index, convert it to a
381:             * double and return it.
382:             * @param i The index of the attributeValues array whose value we want
383:             * @return The double value of the attributeValues array at position i
384:             * @deprecated use getAttribValueAsDouble( i, decimalSeparator, groupingSeparator ) 
385:             * instead, if the locale is different from the locale used to write the values 
386:             * to the model, then the parsed value may be incorrect.
387:             */
388:            public double getAttribValueAsDouble(int i) {
389:                double val = 0.0;
390:                try {
391:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
392:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
393:                            .getDebugTarget();
394:                    oneArgsArray[0] = target.newValue(i);
395:                    IJavaValue attribValue = modelNode.sendMessage(
396:                            "getAttribValueAsDouble", "(I)D", oneArgsArray,
397:                            thread, false);
398:                    if (attribValue != null)
399:                        val = Double.parseDouble(attribValue.getValueString());
400:                } catch (Exception ex) {
401:                    val = 0.0; // TODO: val = -1 ???
402:                    ex.printStackTrace();
403:                }
404:                return val;
405:            }
406:
407:            /**
408:             * Convert the attribute at the specified index to a double and return it
409:             * @param i The index of the attributeValues array whose value we want
410:             *  @param decimalSeparator the decimal separator
411:             * @param groupingSeparator the grouping (thousands) separator
412:             * @return The double value of the attributeValues array at position i
413:             */
414:            public double getAttribValueAsDouble(int i, char decimalSeparator,
415:                    char groupingSeparator) {
416:                double val = 0.0;
417:                try {
418:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
419:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
420:                            .getDebugTarget();
421:                    oneArgsArray[0] = target.newValue(i);
422:                    IJavaValue attribValue = modelNode.sendMessage(
423:                            "getAttribValueAsDouble", "(I)D", oneArgsArray,
424:                            thread, false);
425:                    if (attribValue != null)
426:                        val = NumberFormatter.parseDouble(attribValue
427:                                .getValueString(), decimalSeparator,
428:                                groupingSeparator);
429:                } catch (Exception ex) {
430:                    val = 0.0; // TODO: val = -1 ???
431:                    ex.printStackTrace();
432:                }
433:
434:                return val;
435:            }
436:
437:            /**
438:             * Retrieve the value of the attribute at the specified index, convert it to an int
439:             * and return it.
440:             * @param i The index of the attributeValues array whose value we want
441:             * @return The int value of the attributeValues array at position i
442:             */
443:            public int getAttribValueAsInt(int i) {
444:                int val = 0;
445:                try {
446:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
447:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
448:                            .getDebugTarget();
449:                    oneArgsArray[0] = target.newValue(i);
450:                    IJavaValue attribValue = modelNode.sendMessage(
451:                            "getAttribValueAsInt", "(I)I", oneArgsArray,
452:                            thread, false);
453:                    if (attribValue != null)
454:                        val = Integer.parseInt(attribValue.getValueString());
455:                } catch (Exception ex) {
456:                    val = 0;
457:                    ex.printStackTrace();
458:                }
459:                return val;
460:            }
461:
462:            /**
463:             * Retrieve the named child, convert it's value to a double and return it.
464:             * @param elementName The name of the child whose value is required
465:             * @return the value as a double
466:             */
467:            public double getValueAsDouble(String elementName) {
468:                double val = 0.0;
469:                try {
470:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
471:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
472:                            .getDebugTarget();
473:                    oneArgsArray[0] = target.newValue(elementName);
474:                    IJavaValue attribValue = modelNode.sendMessage(
475:                            "getValueAsDouble", "(Ljava/lang/String;)D",
476:                            oneArgsArray, thread, false);
477:                    if (attribValue != null)
478:                        val = Double.parseDouble(attribValue.getValueString());
479:                } catch (Exception ex) {
480:                    val = 0.0;
481:                    ex.printStackTrace();
482:                }
483:                return val;
484:            }
485:
486:            /**
487:             * Retrieve the named child, convert it's value to an int and return it.
488:             * @param elementName The name of the child to be retrieved
489:             * @return the value as an int
490:             */
491:            public int getValueAsInt(String elementName) {
492:                int val = 0;
493:                try {
494:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
495:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
496:                            .getDebugTarget();
497:                    oneArgsArray[0] = target.newValue(elementName);
498:                    IJavaValue attribValue = modelNode.sendMessage(
499:                            "getValueAsInt", "(Ljava/lang/String;)I",
500:                            oneArgsArray, thread, false);
501:                    if (attribValue != null)
502:                        val = Integer.parseInt(attribValue.getValueString());
503:                } catch (Exception ex) {
504:                    val = 0;
505:                    ex.printStackTrace();
506:                }
507:                return val;
508:            }
509:
510:            /**
511:             * Retrieve the named child, convert it's value to a String and return it.
512:             * @param elementName The name of the child whose value is required
513:             * @return the value as a string
514:             */
515:            public String getValueAsString(String elementName) {
516:                String val = null;
517:                try {
518:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
519:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
520:                            .getDebugTarget();
521:                    oneArgsArray[0] = target.newValue(elementName);
522:                    IJavaValue attribValue = modelNode.sendMessage(
523:                            "getValueAsString",
524:                            "(Ljava/lang/String;)Ljava/lang/String;",
525:                            oneArgsArray, thread, false);
526:                    if (attribValue != null)
527:                        val = attribValue.getValueString();
528:                } catch (Exception ex) {
529:                    val = null;
530:                    ex.printStackTrace();
531:                }
532:                return val;
533:            }
534:
535:            /**
536:             * Get a hash code for the node.
537:             * @return the node's hash code
538:             */
539:            public int hashCode() {
540:                int val = -1;
541:                try {
542:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
543:                    IJavaValue hashCode = modelNode.sendMessage("hashCode",
544:                            "()I", null, thread, false);
545:                    if (hashCode != null)
546:                        val = Integer.parseInt(hashCode.getValueString());
547:                } catch (Exception ex) {
548:                    val = -1;
549:                    ex.printStackTrace();
550:                }
551:                return val;
552:            }
553:
554:            /**
555:             * Gets the number of immediate children of this node
556:             * @return the number of child nodes
557:             */
558:            public int getNumChildren() {
559:                int val = 0;
560:                try {
561:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
562:                    IJavaValue hashCode = modelNode.sendMessage(
563:                            "getNumChildren", "()I", null, thread, false);
564:                    if (hashCode != null)
565:                        val = Integer.parseInt(hashCode.getValueString());
566:                } catch (Exception ex) {
567:                    val = 0;
568:                    ex.printStackTrace();
569:                }
570:                return val;
571:            }
572:
573:            /**
574:             * Gets the number of attributes of this node
575:             * @return the number of attributes
576:             */
577:            public int getNumAttributes() {
578:                int val = 0;
579:                try {
580:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
581:                    IJavaValue hashCode = modelNode.sendMessage(
582:                            "getNumAttributes", "()I", null, thread, false);
583:                    if (hashCode != null)
584:                        val = Integer.parseInt(hashCode.getValueString());
585:                } catch (Exception ex) {
586:                    val = 0;
587:                    ex.printStackTrace();
588:                }
589:                return val;
590:            }
591:
592:            /**
593:             * Sets the number of children of this node
594:             * @param num the new number of children
595:             */
596:            public void setNumChildren(int num) {
597:                try {
598:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
599:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
600:                            .getDebugTarget();
601:                    oneArgsArray[0] = target.newValue(num);
602:                    modelNode.sendMessage("setNumChildren", "(I)V",
603:                            oneArgsArray, thread, false);
604:                } catch (Exception ex) {
605:                    ex.printStackTrace();
606:                }
607:            }
608:
609:            /**
610:             * Append a node
611:             * @param childNode the child node
612:             */
613:            public void append(XModel childNode) {
614:                throw new UnsupportedOperationException();
615:            }
616:
617:            /**
618:             * Append a new node with the specified name. This method does no replace any
619:             * existing nodes.
620:             * @param elementName The immediate path to the XModel requried
621:             * @return The value of the XModel or the attribute
622:             */
623:            public Object append(String elementName) {
624:                Object val = null;
625:                try {
626:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
627:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
628:                            .getDebugTarget();
629:                    oneArgsArray[0] = target.newValue(elementName);
630:                    IJavaObject attribValue = (IJavaObject) modelNode
631:                            .sendMessage("append",
632:                                    "(Ljava/lang/String;)Ljava/lang/Object;",
633:                                    oneArgsArray, thread, false);
634:                    val = new EclipseDebuggerModel(stackFrame, attribValue);
635:                } catch (Exception ex) {
636:                    val = null;
637:                    ex.printStackTrace();
638:                }
639:                return val;
640:            }
641:
642:            /**
643:             * Remove a child
644:             * @param value the ID or name of this node
645:             */
646:            public void removeChild(String elementName) {
647:                try {
648:                    IJavaThread thread = (IJavaThread) stackFrame.getThread();
649:                    IJavaDebugTarget target = (IJavaDebugTarget) stackFrame
650:                            .getDebugTarget();
651:                    oneArgsArray[0] = target.newValue(elementName);
652:                    modelNode.sendMessage("removeChild",
653:                            "(Ljava/lang/String;)V", oneArgsArray, thread,
654:                            false);
655:                } catch (Exception ex) {
656:                    ex.printStackTrace();
657:                }
658:            }
659:
660:            /**
661:             * Remove a child node
662:             * childNode the child node to be removed
663:             */
664:            public void removeChild(XModel childNode) {
665:                throw new UnsupportedOperationException();
666:            }
667:
668:            /**
669:             * Inserts a node at the specified index in the list of children
670:             * @param newNode the new model node
671:             * @param idx the index at which to insert
672:             */
673:            public void insertChildAt(XModel newNode, int idx) {
674:                throw new UnsupportedOperationException();
675:            }
676:
677:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.