| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us"> |
| <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| |
| <meta name="generator" content="DITA-OT" /><meta name="DC.type" content="reference" /> |
| <meta name="DC.title" content="Property Accessors" /> |
| <meta name="abstract" content="" /> |
| <meta name="description" content="" /> |
| <meta name="DC.relation" scheme="URI" content="../reference/oqlsyntax.html" /> |
| <meta name="copyright" content="Copyright (c) 2008, 2023 SAP AG and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ 2008 2023" type="primary" /> |
| <meta name="DC.rights.owner" content="Copyright (c) 2008, 2023 SAP AG and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ 2008 2023" type="primary" /> |
| <meta name="DC.format" content="XHTML" /> |
| <meta name="DC.identifier" content="propertyaccessors" /> |
| <meta name="DC.language" content="en-us" /> |
| <link rel="stylesheet" type="text/css" href="../styles/commonltr.css" /> |
| <title>Property Accessors</title> |
| </head> |
| <body id="propertyaccessors"> |
| |
| <h1 class="title topictitle1" id="ariaid-title1">Property Accessors</h1> |
| |
| |
| |
| |
| <div class="body refbody"><p class="shortdesc"></p> |
| |
| <div class="section"><h2 class="title sectiontitle">Accessing fields of the heap object</h2> |
| |
| <p class="p"> Properties of heap objects are accessed using a simple dot |
| notation:</p> |
| |
| <p class="p"> [ <alias>. ] <field> . <field>. |
| <field> |
| </p> |
| |
| <p class="p"> |
| An |
| <strong class="ph b">alias</strong> |
| can be defined in the |
| <a class="xref" href="oqlsyntaxfrom.html">FROM Clause</a> |
| to identify the current object, i.e. row in the SQL |
| analogy, on which the OQL statement operates. Without |
| alias, the field is assumed to be one of the fields of |
| the current object. |
| <strong class="ph b">Fields</strong> |
| are attributes of the Java objects in the heap dump. Use |
| <a class="xref" href="tipsandtricks.html#oqlcompletion">OQL autocompletion</a> |
| or the |
| <span class="keyword cmdname">Object Inspector</span> |
| to find out about the available fields of an object. |
| </p> |
| |
| </div> |
| |
| <div class="section"><h2 class="title sectiontitle">Accessing Java Bean properties</h2> |
| |
| <p class="p">[ <alias>. ] @<attribute> ...</p> |
| |
| <p class="p"> |
| Using the @ symbol, OQL accesses attributes of the |
| underlying Java objects used by Memory Analyzer to represent |
| objects in the heap dump. The attributes are resolved via |
| Bean Introspection. Use |
| <a class="xref" href="tipsandtricks.html#oqlcompletion">OQL autocompletion</a> |
| to find the common beans names. |
| The following table lists some |
| commonly used Java attributes. |
| </p> |
| |
| <table cellpadding="4" cellspacing="0" summary="" id="propertyaccessors__javabean_prop" border="1" class="simpletable"><col style="width:22.22222222222222%" /><col style="width:22.22222222222222%" /><col style="width:22.22222222222222%" /><col style="width:33.33333333333333%" /><thead></thead><tbody><tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Any heap object</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#method.summary">IObject</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#getObjectId()">objectId</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">id of snapshot object</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#getObjectAddress()">objectAddress</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">address of snapshot object</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry">class</td> |
| |
| <td style="vertical-align:top;" class="stentry">Java class of this object as a Memory Analyzer object</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#getClazz()">clazz</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">IClass of this object. See also classof(object).</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#getOutboundReferences()">outboundReferences</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">The outbound references as a list of |
| <a class="xref" href="../doc/org/eclipse/mat/snapshot/model/NamedReference.html">NamedReference</a> objects |
| from this object: the type as IClass of this object; the fields; the array entries. |
| This is retrieved from the heap dump, not an index, so could contain references |
| to unindexed objects. |
| </td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#getUsedHeapSize()">usedHeapSize</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">shallow heap size</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#getRetainedHeapSize()">retainedHeapSize</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">retained heap size</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#getTechnicalName()">technicalName</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">the technical name (a combination of the class name and the object address)</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#getClassSpecificName()" target="_blank">classSpecificName</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">the value from a name resolver, if available, for example a readable value of a String</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#getDisplayName()">displayName</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">display name, a combination of the technical name and the class specific name</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#getSnapshot()">snapshot</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">the snapshot containing this object. An alternative to <code class="ph codeph">${snapshot}</code></td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Class object</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IClass.html#method.summary">IClass</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IClass.html#getClassLoaderId()">classLoaderId</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">id of the class loader</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Any array</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IArray.html#method.summary">IArray</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IArray.html#getLength()">length</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">length of the array</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Primitive array</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IPrimitiveArray.html#method.summary">IPrimitiveArray</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IPrimitiveArray.html#getValueArray()">valueArray</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">the values in the array</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Reference array</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObjectArray.html#method.summary">IObjectArray</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObjectArray.html#getReferenceArray()">referenceArray</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">the objects in the array (as long values, the addresses of the objects) |
| Access a particular element using get() and convert to an object using OBJECTS. |
| </td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Class loader object</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IClassLoader.html#method.summary">IClassLoader</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IClassLoader.html#getClassLoaderId()">definedClasses</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">the classes defined by the class loader</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Object Reference</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/ObjectReference.html#method.summary">ObjectReference</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/ObjectReference.html#getObject()">object</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">The IObject which the reference points to</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/ObjectReference.html#getObjectId()">objectId</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">The id of the IObject which the reference points to. This will fail for unindexed objects.</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/ObjectReference.html#getObjectAddress()">objectAddress</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">The address of the IObject which the reference points to. This works for unindexed objects.</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Named Reference extends ObjectReference</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/NamedReference.html#method.summary">NamedReference</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/NamedReference.html#getName()">name</a></td> |
| |
| <td style="vertical-align:top;" class="stentry">The field name or array index in the form <code class="ph codeph">[12357]</code> which describes the reference.</td> |
| |
| </tr> |
| </tbody></table> |
| |
| </div> |
| |
| <div class="section"><h2 class="title sectiontitle">Calling Java methods</h2> |
| |
| <pre class="pre codeblock"><code>[ <alias> . ] @<method>( [ <expression>, <expression> ] ) ...</code></pre> |
| <p class="p"> |
| Adding ( ) forces OQL to interpret this as a Java method |
| call. The call is executed via reflection. |
| The code is executed inside Memory Analyzer on the objects in the snapshot |
| representing the heap dump. Code from the Java program which generated the dump is not |
| available and is not executed. |
| The following table lists some |
| common Java methods on the underlying Java objects used by Memory Analyzer to represent |
| objects in the heap dump. |
| </p> |
| |
| <table cellpadding="4" cellspacing="0" summary="" id="propertyaccessors__method_prop" border="1" class="simpletable"><col style="width:22.22222222222222%" /><col style="width:22.22222222222222%" /><col style="width:22.22222222222222%" /><col style="width:33.33333333333333%" /><thead></thead><tbody><tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">${snapshot}</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/ISnapshot.html#method.summary">ISnapshot</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code><a class="xref" href="../doc/org/eclipse/mat/snapshot/ISnapshot.html#getClasses()">getClasses()</a></code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry">a collection of all classes</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code><a class="xref" href="../doc/org/eclipse/mat/snapshot/ISnapshot.html#getClassesByName(java.util.regex.Pattern,%20boolean)">getClassesByName(String name, boolean includeSubClasses)</a></code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry">a collection of classes</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Class object</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IClass.html#method.summary">IClass</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IClass.html#hasSuperClass()">hasSuperClass()</a></code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| result is true if the class has a super class |
| </td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> </td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IClass.html#isArrayType()">isArrayType()</a></code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| the result is true if the class is an array type |
| </td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Any heap object</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#method.summary">IObject</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IObject.html#getObjectAddress()">getObjectAddress()</a></code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| The address of a snapshot object as a long integer |
| </td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Primitive array</td> |
| |
| <td style="vertical-align:top;" class="stentry"><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IPrimitiveArray.html#method.summary">IPrimitiveArray</a></td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code><a class="xref" href="../doc/org/eclipse/mat/snapshot/model/IPrimitiveArray.html#getValueAt(int)">getValueAt(int index)</a></code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry">a value from the array</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry">Java primitive array, Java object array or Java list (returned from reflection)</td> |
| |
| <td style="vertical-align:top;" class="stentry">[] or List</td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code>get(int index)</code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry">a value from the array or list</td> |
| |
| </tr> |
| </tbody></table> |
| |
| </div> |
| |
| <div class="section"><h2 class="title sectiontitle">Array Access</h2> |
| |
| <p class="p">Memory Analyzer 1.3 or later allows direct array style access of |
| primitive arrays and objects arrays from the snapshot, and Java arrays and Java Lists |
| obtained from reflective method calls. The notation is <code class="ph codeph">[index]</code>. |
| The index is a zero-based integer. If the array is null or the index is out of range |
| then the result is null. |
| </p> |
| |
| <p class="p">Memory Analyzer 1.4 or later allows array range access as well using the notation |
| <code class="ph codeph">[index1:index2]</code> where index1 and index2 are inclusive. If the values |
| are negative then they are treated as indexing from the end of the array, so -1 |
| means the last entry. This means the whole array can be accessed as a list as |
| <code class="ph codeph">[0:-1]</code>. |
| </p> |
| |
| </div> |
| |
| <div class="section"><h2 class="title sectiontitle">Reading values from primitive arrays (from the heap dump)</h2> |
| |
| <pre class="pre codeblock"><code>SELECT s[2] FROM int[] s WHERE (s.@length > 2)</code></pre> |
| <p class="p">This method is for Memory Analyzer 1.3 or later.</p> |
| |
| <pre class="pre codeblock"><code>SELECT s.getValueAt(2) FROM int[] s WHERE (s.@length > 2)</code></pre> |
| <p class="p">This method is for all versions of Memory Analyzer. |
| This reads the value of the element at index 2 from all int[] arrays which have at least 3 elements. |
| </p> |
| |
| </div> |
| |
| <div class="section"><h2 class="title sectiontitle">Reading objects from object arrays (from the heap dump)</h2> |
| |
| <pre class="pre codeblock"><code>SELECT s[2] FROM java.lang.Object[] s WHERE (s.@length > 2)</code></pre> |
| <p class="p">This method is for Memory Analyzer 1.3 or later. |
| <code class="ph codeph">s[2]</code>is an IObject so fields and Java bean properties can be accessed</p> |
| |
| <pre class="pre codeblock"><code>SELECT OBJECTS s[2] FROM java.lang.Object[] s</code></pre> |
| <p class="p">This method is for Memory Analyzer 1.3 or later. |
| The <span class="keyword">OBJECTS</span> converts the object to give a tree view rather than |
| table result. We do not need the <span class="keyword">WHERE</span> clause as out of range |
| accesses return null and the <span class="keyword">OBJECTS</span> skips nulls.</p> |
| |
| <pre class="pre codeblock"><code>SELECT OBJECTS s.@referenceArray.get(2) FROM java.lang.Object[] s WHERE (s.@length > 2)</code></pre> |
| <p class="p">This method is for Memory Analyzer 1.1 or later. |
| This reads as a long address the element at index 2 from all Object[] arrays which have at least 3 elements and |
| converts them into objects. |
| </p> |
| |
| <pre class="pre codeblock"><code>SELECT OBJECTS s.getReferenceArray(2,1) FROM java.lang.Object[] s WHERE (s.@length > 2)</code></pre> |
| <p class="p">This method is for Memory Analyzer 1.1 or later. |
| This reads as an array of long[] 1 element starting at index 2 from all Object[] arrays which have at least 3 elements and |
| converts the contents of those arrays into objects. |
| </p> |
| |
| </div> |
| |
| <div class="section"><h2 class="title sectiontitle">Reading from Java arrays (Memory Analyzer internal objects)</h2> |
| |
| <pre class="pre codeblock"><code>SELECT s.@GCRoots[2] FROM OBJECTS ${snapshot} s</code></pre> |
| <p class="p">This method is for Memory Analyzer 1.3 or later.</p> |
| |
| <pre class="pre codeblock"><code>SELECT s.get(2) FROM OBJECTS ${snapshot} s WHERE s.@GCRoots.@length > 2</code></pre> |
| <p class="p">This method is for all versions of Memory Analyzer.</p> |
| |
| </div> |
| |
| <div class="section"><h2 class="title sectiontitle">Reading from Java Lists (Memory Analyzer internal objects)</h2> |
| |
| <pre class="pre codeblock"><code>SELECT s.@GCRoots.subList(1,3)[1] FROM OBJECTS ${snapshot} s</code></pre> |
| <p class="p">This method is for Memory Analyzer 1.3 or later.</p> |
| |
| <pre class="pre codeblock"><code>SELECT s.@GCRoots.subList(1,3).get(1) FROM OBJECTS ${snapshot} s</code></pre> |
| <p class="p">This method is for all versions of Memory Analyzer.</p> |
| |
| </div> |
| |
| <div class="section"><h2 class="title sectiontitle">Reading subarrays</h2> |
| |
| <pre class="pre codeblock"><code>SELECT s, s.count, s.offset, s.value[s.offset], |
| s.value[s.offset:((s.offset + s.count) - 1)], |
| s.value[s.offset:((s.offset + 0) - 1)], |
| s.value[0:-1].subList(s.offset,(s.offset + 0)), |
| s.value[s.offset:-1].subList(0,s.count) |
| FROM java.lang.String s</code></pre> |
| <p class="p">This method is for Memory Analyzer 1.4 or later.</p> |
| |
| <p class="p">This shows how the whole array can be converted to a list using <code class="ph codeph">[0:-1]</code> and |
| that how using array range <code class="ph codeph">[offset:offset+count-1]</code> gives perhaps unexpected results |
| when <code class="ph codeph">offset=0</code> and <code class="ph codeph">count=0</code> as instead of an empty list it gives the whole array. |
| Using <code class="ph codeph">subList(offset,offet+count)</code> once the whole array has been converted to a list |
| gives the expected result. |
| </p> |
| |
| </div> |
| |
| <div class="section"><h2 class="title sectiontitle">Collection access</h2> |
| |
| <pre class="pre codeblock"><code>SELECT a[0] FROM java.util.ArrayList a</code></pre> |
| <p class="p">Many of the standard collections classes are well known by Memory Analyzer. |
| The <a class="xref" href="../tasks/analyzingjavacollectionusage.html">collection queries</a> |
| allow analysis of lists, sets, queues, deques and maps. |
| This access is extended to OQL so if the collection queries work with a particular |
| collection or map then so does OQL. |
| </p> |
| |
| <div class="note"><span class="notetitle">Note:</span> Collection and map access is still experimental and subject to change.</div> |
| |
| <pre class="pre codeblock"><code>SELECT a[0:-1] FROM java.util.ArrayList a</code></pre> |
| <p class="p">If the array access syntax is used on a collection (list,set, queue, deque) object |
| then particular elements of the collection can be extracted. If subarray syntax |
| is used then that part of collection is converted to a list ready for further processing</p> |
| |
| <pre class="pre codeblock"><code>SELECT h[0].@key, h[0].@value FROM java.util.HashMap h</code></pre> |
| <p class="p">If the array access syntax is used on a map then the map is converted to a list of |
| map entries. These can then be examined using the bean access syntax to retrieve the key |
| <code class="ph codeph">h[0].@key</code> or value <code class="ph codeph">h[0].@value</code>. |
| See <a class="xref" href="https://wiki.eclipse.org/MemoryAnalyzer/OQL#Map_processing">Wiki OQL Map processing</a> |
| for more details of OQL with maps and collections.</p> |
| |
| </div> |
| |
| <div class="section"><h2 class="title sectiontitle">Built-in OQL functions</h2> |
| |
| <pre class="pre codeblock"><code><function>( <parameter> )</code></pre> |
| <p class="p">Built-in functions.</p> |
| |
| <table cellpadding="4" cellspacing="0" summary="" id="propertyaccessors__oql_functions" border="1" class="simpletable"><col style="width:40%" /><col style="width:60%" /><thead></thead><tbody><tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code>toHex( number )</code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry">Print the number as hexadecimal</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code>toString( object )</code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| Returns the value of an object, e.g. the content |
| of a String etc. |
| </td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code>dominators( object )</code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| The objects immediately dominated by the object |
| </td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code>outbounds( object )</code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry">outbound referrer</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code>inbounds( object )</code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry">inbound referrer</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code>classof( object )</code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry">the class of the current object</td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code>dominatorof( object )</code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| the immediate dominator, -1 if none |
| </td> |
| |
| </tr> |
| <tr class="strow"> |
| <td style="vertical-align:top;" class="stentry"> |
| <pre class="pre codeblock"><code>eval( expression )</code></pre> |
| </td> |
| |
| <td style="vertical-align:top;" class="stentry"> |
| (Experimental in Memory Analyzer 1.4 or later) evaluates the argument and returns it. |
| Could be useful to allow array/method access to the result of a sub-select or |
| expression. |
| </td> |
| |
| </tr> |
| </tbody></table> |
| |
| |
| </div> |
| |
| </div> |
| |
| <div class="related-links"> |
| <div class="familylinks"> |
| <div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../reference/oqlsyntax.html">OQL Syntax</a></div> |
| </div> |
| </div></body> |
| </html> |