Query

Identifier:
org.eclipse.mat.api.query

Since:
0.7.0

Description:
The Memory Analyzer can be extended by Queries. Queries are pieces of Java Code that implement specific inspections on the heap dump. Depending on the input parameters, queries are shown in the Query Drop-Down menu and/or in the context menu of a heap object.

Configuration Markup:

<!ELEMENT extension (query)+>

<!ATTLIST extension

point CDATA #REQUIRED

id    CDATA #IMPLIED

name  CDATA #IMPLIED

>


<!ELEMENT query EMPTY>

<!ATTLIST query

impl CDATA #REQUIRED

>


Examples:

Following is an example of a query declaration:


   <extension point="org.eclipse.mat.report.query">
      <query impl="org.eclipse.mat.demo.DemoQuery"/>
   </extension>

This is the Java code.


@CommandName("DemoQuery")
public class org.eclipse.mat.demo.DemoQuery implements IQuery
{
    @Argument
    public ISnapshot snapshot;
    
    @Argument
    public boolean myflag;
    
    public IResult execute(IProgressListener listener) throws Exception
    {
        ...
    }
}

This is the translatable text in annotations.properties in the same package.


DemoQuery.name = Demonstration Query
DemoQuery.help = A sample query.
DemoQuery.myflag.help = A boolean flag to control the query.

API Information:
The value of the impl attribute must represent an implementor of org.eclipse.mat.query.IQuery. The public fields in the query can be tagged with the @Argument annotation so they can be filled in by the query wizard. Argument types include
ISnapshot
the snapshot
IHeapObjectArgument
one or more objects
int
a single object - when tagged with @Argument(advice = Advice.HEAP_OBJECT)
int[]
multiple objects - when tagged with @Argument(advice = Advice.HEAP_OBJECT)
boolean
a flag
Queries can be tagged with These annotations can also be held in an annotations.properties file for ease of translation.

Supplied Implementation:
The Memory Analyzer supplies a number of queries itself. Check out the org.eclipse.mat.inspections package for more samples.


Copyright (c) 2008, 2010 SAP AG and IBM Corporation.
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/