or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

ast-browser.mdconsole-application.mdindex.mdobject-inspector.mdsystem-integration.mdtext-editing.md

object-inspector.mddocs/

0

# Object Inspector

1

2

The Object Inspector provides comprehensive runtime object introspection and property browsing capabilities for debugging and exploration of Groovy objects and Java objects.

3

4

## Main Object Browser

5

6

```groovy { .api }

7

class ObjectBrowser {

8

// Static Entry Points

9

static void main(String[] args)

10

static void inspect(Object objectUnderInspection)

11

}

12

```

13

14

### Parameters

15

16

**main() Parameters:**

17

- `args` (String[]): Command line arguments for standalone object browser

18

19

**inspect() Parameters:**

20

- `objectUnderInspection` (Object): Any object to inspect - can be Groovy objects, Java objects, collections, etc.

21

22

### Returns

23

24

- **main()**: void - Launches standalone object browser application

25

- **inspect()**: void - Opens object inspector window for the specified object

26

27

## Table Components

28

29

### Interactive Cell Editors

30

31

```groovy { .api }

32

class ButtonOrTextEditor extends AbstractCellEditor implements TableCellEditor {

33

// Table cell editor that can display buttons or editable text

34

}

35

36

class ButtonOrDefaultRenderer extends DefaultTableCellRenderer {

37

// Table cell renderer for button or default text display

38

}

39

```

40

41

These components provide interactive table cells in the object inspector for:

42

- Expandable object properties

43

- Editable values where appropriate

44

- Button-triggered actions for complex objects

45

46

## Usage Examples

47

48

### Basic Object Inspection

49

50

```groovy

51

def myObject = [name: 'John', age: 30, items: ['a', 'b', 'c']]

52

groovy.console.ui.ObjectBrowser.inspect(myObject)

53

54

// Or using legacy API

55

groovy.inspect.swingui.ObjectBrowser.inspect(myObject)

56

```

57

58

### Standalone Object Browser

59

60

```groovy

61

// Launch standalone object browser

62

groovy.console.ui.ObjectBrowser.main([] as String[])

63

```

64

65

### Inspecting Complex Objects

66

67

```groovy

68

class Person {

69

String name

70

int age

71

List<String> hobbies

72

Map<String, Object> metadata

73

74

def greet() { "Hello, I'm $name" }

75

}

76

77

def person = new Person(

78

name: 'Alice',

79

age: 25,

80

hobbies: ['reading', 'coding', 'hiking'],

81

metadata: [location: 'NYC', active: true]

82

)

83

84

// Inspect the complex object

85

groovy.console.ui.ObjectBrowser.inspect(person)

86

```

87

88

### Inspecting Collections

89

90

```groovy

91

def complexList = [

92

[name: 'Item 1', value: 100],

93

[name: 'Item 2', value: 200, nested: [a: 1, b: 2]],

94

new Date(),

95

42,

96

'Hello World'

97

]

98

99

groovy.console.ui.ObjectBrowser.inspect(complexList)

100

```

101

102

### Inspecting Java Objects

103

104

```groovy

105

import java.util.concurrent.ConcurrentHashMap

106

107

def javaMap = new ConcurrentHashMap()

108

javaMap.put('key1', 'value1')

109

javaMap.put('key2', [subkey: 'subvalue'])

110

111

groovy.console.ui.ObjectBrowser.inspect(javaMap)

112

```

113

114

## Integration with Console

115

116

The Object Inspector integrates seamlessly with the main Console:

117

118

### Console Integration Methods

119

120

From the Console, access object inspection via:

121

- **inspectLast()** method - Inspects the result of the last executed expression

122

- **inspectVariables()** method - Inspects all variables in the current binding

123

- Menu options for object inspection

124

125

### Variable Inspection

126

127

```groovy

128

// In console, after running a script:

129

def result = someComplexOperation()

130

// Then use: console.inspectLast() to inspect 'result'

131

```

132

133

## Object Inspector Features

134

135

### Property Browsing

136

137

The Object Inspector displays:

138

- **Properties**: All accessible properties with their values

139

- **Methods**: Available methods (non-executable in browser)

140

- **Fields**: Public and accessible fields

141

- **Type Information**: Class hierarchy and type details

142

143

### Interactive Features

144

145

- **Expandable Trees**: Navigate nested object structures

146

- **Value Editing**: Modify simple property values where possible

147

- **Search and Filter**: Find specific properties or methods

148

- **Export Options**: Save inspection results

149

150

### Supported Object Types

151

152

The inspector handles:

153

- **Groovy Objects**: Full property and method introspection

154

- **Java Objects**: Reflection-based property access

155

- **Collections**: Lists, Maps, Sets with element browsing

156

- **Arrays**: Multi-dimensional array exploration

157

- **Primitive Wrappers**: Integer, String, Boolean, etc.

158

- **Custom Classes**: User-defined classes and their properties

159

160

## Legacy API

161

162

The same object inspection functionality is available in the legacy package:

163

164

```groovy

165

// Legacy imports (same API as groovy.console.ui)

166

import groovy.inspect.swingui.ObjectBrowser

167

import groovy.inspect.swingui.ButtonOrTextEditor

168

import groovy.inspect.swingui.ButtonOrDefaultRenderer

169

```

170

171

## Advanced Inspection

172

173

### Deep Object Analysis

174

175

The inspector provides:

176

- **Circular Reference Detection**: Handles self-referencing objects safely

177

- **Lazy Loading**: Loads complex nested objects on demand

178

- **Memory-Safe Browsing**: Avoids loading entire large collections

179

- **Type Hierarchy Display**: Shows inheritance chains and implemented interfaces

180

181

### Debugging Integration

182

183

Use with debugging:

184

- Inspect exception objects to understand error states

185

- Browse stack trace elements and their properties

186

- Examine thread states and concurrent objects

187

- Analyze performance-related object metrics

188

189

### Customization

190

191

The object browser supports:

192

- Custom renderers for specific object types

193

- Configurable display depth for nested objects

194

- Filtered views to show only relevant properties

195

- Export formats for external analysis