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 Description SnapshotQueryContext(ISnapshot snapshot)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanavailable(java.lang.Class<?> type, Argument.Advice advice)Is this type of data available from the context?booleanconverts(java.lang.Class<?> type, Argument.Advice advice)Does the context have a converter for data of this type?java.lang.StringconvertToString(java.lang.Class<?> type, Argument.Advice advice, java.lang.Object value)Convert the value to a string.java.lang.ObjectconvertToValue(java.lang.Class<?> type, Argument.Advice advice, java.lang.String value)Convert the String to the value based on the type and advice.java.lang.Objectget(java.lang.Class<?> type, Argument.Advice advice)Get this type of data from the context.ContextDerivedDatagetContextDerivedData()For example, retained size derived data.java.lang.StringgetPrefix()The prefix for files generated from snapshotjava.io.FilegetPrimaryFile()The main file for the snapshotjava.lang.StringmapToExternalIdentifier(int objectId)Map an id to a readable form.intmapToObjectId(java.lang.String externalIdentifier)Map readable form to internal id.java.lang.Objectparse(java.lang.Class<?> type, Argument.Advice advice, java.lang.String[] args, java.text.ParsePosition pos)Consume the special data.booleanparses(java.lang.Class<?> type, Argument.Advice advice)Is special parsing required to get an object of the required type?
-
-
-
Constructor Detail
-
SnapshotQueryContext
public SnapshotQueryContext(ISnapshot snapshot)
-
-
Method Detail
-
getPrimaryFile
public java.io.File getPrimaryFile()
Description copied from interface:IQueryContextThe main file for the snapshot- Returns:
- the dump
-
getPrefix
public java.lang.String getPrefix()
Description copied from interface:IQueryContextThe prefix for files generated from snapshot- Returns:
- the prefix
-
mapToExternalIdentifier
public java.lang.String mapToExternalIdentifier(int objectId) throws SnapshotExceptionDescription copied from interface:IQueryContextMap an id to a readable form. For example the hex-address with 0x as a prefix. Reverse ofIQueryContext.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(java.lang.String externalIdentifier) throws SnapshotExceptionDescription copied from interface:IQueryContextMap readable form to internal id. Reverse ofIQueryContext.mapToExternalIdentifier(int).- Parameters:
externalIdentifier- as provided byIQueryContext.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(java.lang.Class<?> type, Argument.Advice advice)Description copied from interface:IQueryContextIs this type of data available from the context?- Specified by:
availablein interfaceIQueryContext- Overrides:
availablein classQueryContextImpl- Parameters:
type- the type the data should be converted toadvice- advice such as from the query as to how the value should be converted.- Returns:
- true if available.
-
get
public java.lang.Object get(java.lang.Class<?> type, Argument.Advice advice)Description copied from interface:IQueryContextGet this type of data from the context.- Specified by:
getin interfaceIQueryContext- Overrides:
getin classQueryContextImpl- Parameters:
type- the type the data should be converted toadvice- 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(java.lang.Class<?> type, Argument.Advice advice)Description copied from interface:IQueryContextDoes the context have a converter for data of this type?- Specified by:
convertsin interfaceIQueryContext- Overrides:
convertsin classQueryContextImpl- 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 java.lang.String convertToString(java.lang.Class<?> type, Argument.Advice advice, java.lang.Object value) throws SnapshotExceptionDescription copied from interface:IQueryContextConvert the value to a string. For example the converter might be String.valueOf(Integer)- Specified by:
convertToStringin interfaceIQueryContext- Overrides:
convertToStringin classQueryContextImpl- 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 java.lang.Object convertToValue(java.lang.Class<?> type, Argument.Advice advice, java.lang.String value) throws SnapshotExceptionDescription copied from interface:IQueryContextConvert the String to the value based on the type and advice.- Specified by:
convertToValuein interfaceIQueryContext- Overrides:
convertToValuein classQueryContextImpl- Parameters:
type- The Java type of the argumentadvice- 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(java.lang.Class<?> type, Argument.Advice advice)Description copied from interface:IQueryContextIs 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 java.lang.Object parse(java.lang.Class<?> type, Argument.Advice advice, java.lang.String[] args, java.text.ParsePosition pos) throws SnapshotExceptionDescription copied from interface:IQueryContextConsume 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 convertedpos- 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:IQueryContextFor example, retained size derived data.- Returns:
- the derived data
-
-