Package org.eclipse.mat.snapshot.query

# Class SnapshotQuery

java.lang.Object
org.eclipse.mat.snapshot.query.SnapshotQuery

public class SnapshotQuery extends Object
This class provides possibility to lookup, inspect, parameterize and execute queries on a given heap dump.

NOTE: The queries delivered with Memory Analyzer and their expected parameters are not part of the API. Both names/identifiers and parameters may change.

Usage example:

     IResult result = SnapshotQuery.lookup("top_consumers_html", snapshot) //
                     .setArgument("objects", retained) //
                     .execute(listener);

## Method Summary

Modifier and Type
Method
Description
`IResult`
`execute(IProgressListener listener)`
Execute the query and return the result.
`List<? extends IArgumentDescriptor>`
`getArguments()`
Get the list of the query arguments.
`IAnnotatedObjectDescriptor`
`getDescriptor()`
Get a descriptor for the query.
`static SnapshotQuery`
`lookup(String name, ISnapshot snapshot)`
Factory method to create a query by name.
`static SnapshotQuery`
`parse(String commandLine, ISnapshot snapshot)`
Factory method to create a query by command line, i.e.
`RefinedResultBuilder`
`refine(IProgressListener listener)`
Execute the query and return a `RefinedResultBuilder` which allows for filtering, sorting and limiting of the result.
`SnapshotQuery`
`set(String name, Object value)`
Deprecated.
use setArgument() instead
`SnapshotQuery`
`setArgument(String name, Object value)`
Set the argument identified by `name`.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### lookup

public static SnapshotQuery lookup(String name, ISnapshot snapshot) throws SnapshotException
Factory method to create a query by name.

Throws:
  `SnapshotException`

### parse

public static SnapshotQuery parse(String commandLine, ISnapshot snapshot) throws SnapshotException
Factory method to create a query by command line, i.e. setting the arguments accordingly.

Throws:
  `SnapshotException`

### getDescriptor

public IAnnotatedObjectDescriptor getDescriptor()
Get a descriptor for the query. From it one can inspect the Name, Help, Icon, etc... for the query.

Returns:
  `IAnnotatedObjectDescriptor` a descriptor for the query
Since:
  1.0

### getArguments

public List<? extends IArgumentDescriptor> getArguments()
Get the list of the query arguments.

Returns:
  the list of `IArgumentDescriptor` describing the arguments which the query expects
Since:
  1.0

### setArgument

public SnapshotQuery setArgument(String name, Object value) throws SnapshotException
Set the argument identified by `name`. Heap objects can be provided as `int`, `Integer`, `int[]` or `IObject`.

Parameters:
  `name` - the name of the argument
  `value` - the new value of the argument
Returns:
  the modified SnapshotQuery object
Throws:
  `SnapshotException`
Since:
  1.0

### set

public SnapshotQuery set(String name, Object value) throws SnapshotException
Deprecated.
use setArgument() instead

Throws:
  `SnapshotException`

### execute

public IResult execute(IProgressListener listener) throws SnapshotException
Execute the query and return the result.

Throws:
  `SnapshotException`

### refine

public RefinedResultBuilder refine(IProgressListener listener) throws SnapshotException
Execute the query and return a `RefinedResultBuilder` which allows for filtering, sorting and limiting of the result.

Throws:
  `SnapshotException`