org.eclipse.mat.internal.snapshot

## Class SnapshotQueryContext

- java.lang.Object
- - org.eclipse.mat.query.registry.QueryContextImpl
  - - org.eclipse.mat.internal.snapshot.SnapshotQueryContext

All Implemented Interfaces:
  IQueryContext

    public class SnapshotQueryContext
    extends QueryContextImpl

### Constructor Summary

Constructors
Constructor and Description
`SnapshotQueryContext(ISnapshot snapshot)`

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `available(Class<?> type, Argument.Advice advice)` Is this type of data available from the context?
`boolean` `converts(Class<?> type, Argument.Advice advice)` Does the context have a converter for data of this type?
`String` `convertToString(Class<?> type, Argument.Advice advice, Object value)` Convert the value to a string.
`Object` `convertToValue(Class<?> type, Argument.Advice advice, String value)` Convert the String to the value based on the type and advice.
`Object` `get(Class<?> type, Argument.Advice advice)` Get this type of data from the context.
`ContextDerivedData` `getContextDerivedData()` For example, retained size derived data.
`String` `getPrefix()` The prefix for files generated from snapshot
`File` `getPrimaryFile()` The main file for the snapshot
`String` `mapToExternalIdentifier(int objectId)` Map an id to a readable form.
`int` `mapToObjectId(String externalIdentifier)` Map readable form to internal id.
`Object` `parse(Class<?> type, Argument.Advice advice, String[] args, ParsePosition pos)` Consume the special data.
`boolean` `parses(Class<?> type, Argument.Advice advice)` Is special parsing required to get an object of the required type?

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

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

### Constructor Detail

#### SnapshotQueryContext

    public SnapshotQueryContext(ISnapshot snapshot)

### Method Detail

#### getPrimaryFile

    public File getPrimaryFile()

Description copied from interface: `IQueryContext`
The main file for the snapshot

Returns:
  the dump

#### getPrefix

    public String getPrefix()

Description copied from interface: `IQueryContext`
The prefix for files generated from snapshot

Returns:
  the prefix

#### mapToExternalIdentifier

    public String mapToExternalIdentifier(int objectId)
                                   throws SnapshotException

Description copied from interface: `IQueryContext`
Map an id to a readable form. For example the hex-address with 0x as a prefix. Reverse of `IQueryContext.mapToObjectId(java.lang.String)`

Parameters:
  `objectId` - The 0-based internal identifier used within MAT.
Returns:
  readable external version
Throws:
  `SnapshotException` - if the objectId does not match to a valid object.
See Also:
  `IQueryContext.mapToObjectId(java.lang.String)`

#### mapToObjectId

    public int mapToObjectId(String externalIdentifier)
                      throws SnapshotException

Description copied from interface: `IQueryContext`
Map readable form to internal id. Reverse of `IQueryContext.mapToExternalIdentifier(int)`.

Parameters:
  `externalIdentifier` - as provided by `IQueryContext.mapToExternalIdentifier(int)`.
Returns:
  the object id
Throws:
  `SnapshotException` - if the external identifier does not match a known object in the snapshot.

#### available

    public boolean available(Class<?> type,
                             Argument.Advice advice)

Description copied from interface: `IQueryContext`
Is this type of data available from the context?

Specified by:
  `available` in interface `IQueryContext`
Overrides:
  `available` in class `QueryContextImpl`
Parameters:
  `type` - the type the data should be converted to
  `advice` - advice such as from the query as to how the value should be converted.
Returns:
  true if available.

#### get

    public Object get(Class<?> type,
                      Argument.Advice advice)

Description copied from interface: `IQueryContext`
Get this type of data from the context.

Specified by:
  `get` in interface `IQueryContext`
Overrides:
  `get` in class `QueryContextImpl`
Parameters:
  `type` - the type the data should be converted to
  `advice` - advice such as from the query as to how the value should be converted.
Returns:
  the object of the right type

#### converts

    public boolean converts(Class<?> type,
                            Argument.Advice advice)

Description copied from interface: `IQueryContext`
Does the context have a converter for data of this type?

Specified by:
  `converts` in interface `IQueryContext`
Overrides:
  `converts` in class `QueryContextImpl`
Parameters:
  `type` - The Java type of an argument to be supplied with data from this context.
  `advice` - Further details about the argument to be supplied with data.
Returns:
  true if available and convertible

#### convertToString

    public String convertToString(Class<?> type,
                                  Argument.Advice advice,
                                  Object value)
                           throws SnapshotException

Description copied from interface: `IQueryContext`
Convert the value to a string. For example the converter might be String.valueOf(Integer)

Specified by:
  `convertToString` in interface `IQueryContext`
Overrides:
  `convertToString` in class `QueryContextImpl`
Parameters:
  `type` - The Java type of the argument.
  `advice` - Further details about the argument.
  `value` - The value of the argument held in the context.
Returns:
  the value converted to a String
Throws:
  `SnapshotException` - If there is a problem with the conversion such as the value is not a valid object ID.

#### convertToValue

    public Object convertToValue(Class<?> type,
                                 Argument.Advice advice,
                                 String value)
                          throws SnapshotException

Description copied from interface: `IQueryContext`
Convert the String to the value based on the type and advice.

Specified by:
  `convertToValue` in interface `IQueryContext`
Overrides:
  `convertToValue` in class `QueryContextImpl`
Parameters:
  `type` - The Java type of the argument
  `advice` - Further details about the argument.
  `value` - The readable string value
Returns:
  the String converted to a value suitable to be stored in the argument.
Throws:
  `SnapshotException` - if there is a problem with the conversion, such as an unknown object address.

#### parses

    public boolean parses(Class<?> type,
                          Argument.Advice advice)

Description copied from interface: `IQueryContext`
Is special parsing required to get an object of the required type?

Parameters:
  `type` - The Java type of the argument.
  `advice` - Further details about the argument.
Returns:
  true if special parsing is needed, for example for a heap object or class object in the heap.

#### parse

    public Object parse(Class<?> type,
                        Argument.Advice advice,
                        String[] args,
                        ParsePosition pos)
                 throws SnapshotException

Description copied from interface: `IQueryContext`
Consume the special data. For example using the ArgumentParser for data from a query wizard.

Parameters:
  `type` - The Java type of the destination argument.
  `advice` - Further details about the argument.
  `args` - The source to be converted
  `pos` - Used to index through the array of Strings.
Returns:
  the result of parsing the data suitable given the type and advice
Throws:
  `SnapshotException` - If there is a problem in the parsing.

#### getContextDerivedData

    public ContextDerivedData getContextDerivedData()

Description copied from interface: `IQueryContext`
For example, retained size derived data.

Returns:
  the derived data