Class DefaultTraceObjectSchema

java.lang.Object
ghidra.trace.model.target.schema.DefaultTraceObjectSchema
All Implemented Interfaces:
TraceObjectSchema, Comparable<DefaultTraceObjectSchema>

public class DefaultTraceObjectSchema extends Object implements TraceObjectSchema, Comparable<DefaultTraceObjectSchema>
The "type descriptor" of a TraceObject.

These are typically loaded from XML anymore. See XmlSchemaContext. It typically consists of a list of expected attributes and their respective schemas, some of which may be primitive; and the schema of elements, if this is a container. It is a bit more flexible than that, but that is the usual case. A schema may also specify one or more interfaces it supports. An interface typically requires certain attributes, but also implies some debugger-related behavior should be available via the target's command set. See TraceObjectInterface and its derivatives for information about each interface.

  • Method Details

    • getContext

      public SchemaContext getContext()
      Description copied from interface: TraceObjectSchema
      Get the context of which this schema is a member

      All schema names are resolved in this same context

      Specified by:
      getContext in interface TraceObjectSchema
      Returns:
      the context
    • getName

      public TraceObjectSchema.SchemaName getName()
      Description copied from interface: TraceObjectSchema
      Get the name of this schema
      Specified by:
      getName in interface TraceObjectSchema
      Returns:
      the name
    • getType

      public Class<?> getType()
      Description copied from interface: TraceObjectSchema
      Get the Java class that best represents this type.

      Note that this is either a primitive, or TraceObject. Even though an object implementation is necessarily a sub-type of TraceObject, for any object schema, this return TraceObject. Information about a "sub-type" of object is communicated via interfaces, element schemas, and attribute schemas.

      Specified by:
      getType in interface TraceObjectSchema
      Returns:
      the Java class for this type
    • getInterfaces

      public Set<Class<? extends TraceObjectInterface>> getInterfaces()
      Description copied from interface: TraceObjectSchema
      Get the minimum interfaces supported by a conforming object
      Specified by:
      getInterfaces in interface TraceObjectSchema
      Returns:
      the set of required interfaces
    • isCanonicalContainer

      public boolean isCanonicalContainer()
      Description copied from interface: TraceObjectSchema
      Check if this object is the canonical container for its elements

      This is generally in reference to the default type of this object's elements. For example, if elements of this object are all expected to support the "Process" interface, then this is the canonical Process container. Any Process ought to have a (canonical) path in this container. Any other path referring to such a Process ought to be a link.

      NOTE: the concept of links is still in incubation, as some native debugging APIs seem to have made it difficult to detect object identity. Additionally, it's possible a caller's first encounter with an object is not via its canonical path, and it may be difficult to assign a path having only the native-API-given object in hand.

      Specified by:
      isCanonicalContainer in interface TraceObjectSchema
      Returns:
      true if this is a canonical container, false otherwise
    • getElementSchemas

      public Map<String,TraceObjectSchema.SchemaName> getElementSchemas()
      Description copied from interface: TraceObjectSchema
      Get the map of element indices to named schemas

      It is uncommon for this map to be populated, since the elements of a given container are typically uniform in type. Nevertheless, there can be restrictions imposed on -- and information provided for -- specific indices.

      Specified by:
      getElementSchemas in interface TraceObjectSchema
      Returns:
      the map
    • getDefaultElementSchema

      public TraceObjectSchema.SchemaName getDefaultElementSchema()
      Description copied from interface: TraceObjectSchema
      Get the default schema for elements

      Since elements of a given container are typically uniform in type, this is the primary means of specifying element schemas.

      Specified by:
      getDefaultElementSchema in interface TraceObjectSchema
      Returns:
      the default named schema
    • getAttributeSchemas

      public Map<String,TraceObjectSchema.AttributeSchema> getAttributeSchemas()
      Description copied from interface: TraceObjectSchema
      Get the map of attribute names to named schemas

      The returned map will include aliases. To determine whether or not an attribute key is an alias, check whether the entry's key matches the name of the attribute (see TraceObjectSchema.AttributeSchema.getName()). It is possible the schema's name is empty, i.e., the default schema. This indicates an alias to a key that was not named in the schema. Use TraceObjectSchema.getAttributeAliases() to determine the name of that key.

      Specified by:
      getAttributeSchemas in interface TraceObjectSchema
      Returns:
      the map
    • getAttributeAliases

      public Map<String,String> getAttributeAliases()
      Description copied from interface: TraceObjectSchema
      Get the map of attribute name aliases

      The returned map must provide the direct alias names. For any given key, the client need only query the map once to determine the name of the attribute to which the alias refers. Consequently, the map also cannot indicate a cycle.

      An aliased attribute takes the value of its target implicitly.

      Specified by:
      getAttributeAliases in interface TraceObjectSchema
      Returns:
      the map
    • getDefaultAttributeSchema

      public TraceObjectSchema.AttributeSchema getDefaultAttributeSchema()
      Description copied from interface: TraceObjectSchema
      Get the default schema for attributes

      Since the expected attributes and their respective schemas are generally enumerated, this most commonly returns TraceObjectSchema.AttributeSchema.DEFAULT_ANY, to allow unrestricted use of additional attributes, or TraceObjectSchema.AttributeSchema.DEFAULT_VOID, to forbid any additional attributes.

      Specified by:
      getDefaultAttributeSchema in interface TraceObjectSchema
      Returns:
      the default attribute schema
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      protected void toString(StringBuilder sb)
    • equals

      public boolean equals(Object obj)

      Generally speaking, object identity is sufficient for checking equality in production; however, this method is provided for testing equality between an actual and expected schema. Furthermore, this tests more for "content equality" than it does schema equivalence. In particular, if the two entries being compared come from different contexts, then, even though they may refer to child schemas by the same name, those child schemas may not be equivalent. This test will consider them "equal," even though they specify different overall schemas. Testing for true equivalence has too many nuances to consider here: What if they come from different contexts? What if they refer to different schemas, but those schemas are equivalent? etc.

      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(DefaultTraceObjectSchema o)
      Specified by:
      compareTo in interface Comparable<DefaultTraceObjectSchema>