Adobe 27510753 Scripting Guide - Page 67

ReflectionInfo Object, Reflection object functions, ReflectionInfo object properties

Page 67 highlights

Adobe InDesign CS2 Scripting Guide Using ExtendScript Tools and Features 59 Reflection object functions find reflectionObj.find (name) Returns the ReflectionInfo object for the named property of the reflected object, or null if no such property exists. Use this method to get information about dynamic properties that have not yet been accessed, but that are known to exist. name The property for which to retrieve information. ➤ Examples This code determines the class name of an object: obj = new String ("hi"); obj.reflect.name; // => String This code gets a list of all methods: obj = new String ("hi"); obj.reflect.methods; //=> indexOf,slice,... obj.reflect.find ("indexOf"); // => the method info This code gets a list of properties: Math.reflect.properties; //=> PI,LOG10,... This code gets the data type of a property: Math.reflect.find ("PI").type; // => number ReflectionInfo Object This object contains information about a property, a method, or a method argument. l You can access ReflectionInfo objects in a Reflection object's properties and methods arrays, by name or index: obj = new String ("hi"); obj.reflect.methods[0]; obj.reflect.methods["indexOf"]; l You can access the ReflectionInfo objects for the arguments of a method in the arguments array of the ReflectionInfo object for the method, by index: obj.reflect.methods["indexOf"].arguments[0]; ReflectionInfo object properties arguments Array of For a reflected method, an array of ReflectionInfo objects describ- ReflectionInfo ing each method argument.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184

Adobe InDesign CS2 Scripting Guide
Using ExtendScript Tools and Features
59
Reflection object functions
find
reflectionObj
.find
(
name
)
Returns the
ReflectionInfo
object for the named property of the
reflected object, or
null
if no such property exists. Use this method
to get information about dynamic properties that have not yet been
accessed, but that are known to exist.
name
The property for which to retrieve information.
Examples
This code determines the class name of an object:
obj = new String ("hi");
obj.reflect.name; // => String
This code gets a list of all methods:
obj = new String ("hi");
obj.reflect.methods; //=> indexOf,slice,...
obj.reflect.find ("indexOf"); // => the method info
This code gets a list of properties:
Math.reflect.properties; //=> PI,LOG10,...
This code gets the data type of a property:
Math.reflect.find ("PI").type; // => number
ReflectionInfo Object
This object contains information about a property, a method, or a method argument.
You can access
ReflectionInfo
objects in a
Reflection
object’s
properties
and
methods
arrays,
by name or index:
obj = new String ("hi");
obj.reflect.methods[0];
obj.reflect.methods["indexOf"];
You can access the
ReflectionInfo
objects for the arguments of a method in the
arguments
array of
the
ReflectionInfo
object for the method, by index:
obj.reflect.methods["indexOf"].arguments[0];
ReflectionInfo object properties
arguments
Array of
ReflectionInfo
For a reflected method, an array of
ReflectionInfo
objects describ-
ing each method argument.
l
l