Class Template
java.lang.Object
com.ibm.j9ddr.corereaders.tdump.zebedee.util.Template
This class represents a single template as defined in a template xml file. A template
defines the layout of storage in memory (similar to a C struct) and the purpose of templates
is to define for each field, the name, offset in bytes, length, type, description etc.
The template classes have no dependencies on any of the other Zebedee classes and
so may be reused for other purposes. All it requires is that the user supplies an implementation
of ImageInputStream
so that the template classes can obtain the data for the fields in each structure.
The DTD for the XML description of a template type can be found here (in pretty html format) or here (in raw form). The XML is always verified and the first line must contain the following DTD declaration: <!DOCTYPE type SYSTEM "file://template.dtd"> (the reference to template.dtd is automatically intercepted).
Templates are created using the factory method getTemplate rather than being instantiated directly so only one persistent instance is created for a given name.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the TemplateField with the given name.Returns aList
of the fields in the Template in their original order.int
Returns the offset in bytes of the specified field within the template.static Template
getTemplate
(String templateFileName) Create a new Template from the given template file.int
length()
Returns the length in bytes of this templatestatic void
This method is mainly for regression testing.Returns the name of this template as specified by the top level element
-
Method Details
-
getTemplate
public static Template getTemplate(String templateFileName) throws FileNotFoundException, com.ibm.j9ddr.corereaders.tdump.zebedee.util.InvalidTemplateFile Create a new Template from the given template file.- Parameters:
templateFileName
- the name of the template file. This can be relative or absolute and must include the ".xml" (if any). getResourceAsStream is used to locate the xml file so absolute pathnames are actually relative to this class's classpath.- Throws:
FileNotFoundException
- if the xml file could not be foundcom.ibm.j9ddr.corereaders.tdump.zebedee.util.InvalidTemplateFile
- if the xml is invalid in any way
-
templateName
Returns the name of this template as specified by the top level element -
getField
Returns the TemplateField with the given name.- Parameters:
name
- the name of the field- Throws:
NoSuchFieldException
- if there is no field with the given name
-
getFields
Returns aList
of the fields in the Template in their original order.- Returns:
- list the
List
of fields
-
getOffset
Returns the offset in bytes of the specified field within the template.- Parameters:
fieldName
- the name of the field- Returns:
- the offset of the field
- Throws:
NoSuchFieldException
- if there is no field with the given name
-
length
public int length()Returns the length in bytes of this template -
main
This method is mainly for regression testing. It prints a text version of the given template files just containing the field name, offset and length. It's much easier to do a diff on this format than the xml which I tend to fiddle with quite a lot!
-