Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
Static Public Member Functions | List of all members
org.sleuthkit.autopsy.coreutils.XMLUtil Class Reference

Static Public Member Functions

static Document createDocument () throws ParserConfigurationException
 
static< T > Document loadDoc (Class< T > clazz, String xmlPath)
 
static< T > Document loadDoc (Class< T > clazz, String xmlPath, String xsdPath)
 
static< T > Document loadDocument (String docPath, Class< T > clazz, String schemaResourceName) throws IOException, ParserConfigurationException, SAXException
 
static Document loadDocument (String docPath) throws ParserConfigurationException, SAXException, IOException
 
static< T > boolean saveDoc (Class< T > clazz, String xmlPath, String encoding, final Document doc)
 
static void saveDocument (final Document doc, String encoding, String docPath) throws TransformerConfigurationException, FileNotFoundException, UnsupportedEncodingException, TransformerException, IOException
 
static< T > void validateDocument (final Document doc, Class< T > clazz, String schemaResourceName) throws SAXException, IOException
 
static< T > boolean xmlIsValid (DOMSource xmlfile, Class< T > clazz, String schemaFile)
 
static< T > boolean xmlIsValid (Document doc, Class< T > clazz, String type)
 

Detailed Description

XML Utilities

This class provides basic utilities for working with XML files, such as -Validating XML files against a given schema -Saving documents to disk -Loading documents from disk

Definition at line 56 of file XMLUtil.java.

Member Function Documentation

static Document org.sleuthkit.autopsy.coreutils.XMLUtil.createDocument ( ) throws ParserConfigurationException
static

Creates a W3C DOM.

Returns
The document object.
Exceptions
ParserConfigurationException

Definition at line 65 of file XMLUtil.java.

Referenced by org.sleuthkit.autopsy.casemodule.CaseMetadata.writeToFile().

static <T> Document org.sleuthkit.autopsy.coreutils.XMLUtil.loadDoc ( Class< T >  clazz,
String  xmlPath 
)
static

Loads XML files from disk

Parameters
clazzthe class this method is invoked from
xmlPaththe full path to the file to load

Definition at line 228 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.Logger.getLogger().

Referenced by org.sleuthkit.autopsy.coreutils.XMLUtil.loadDoc(), and org.sleuthkit.autopsy.externalresults.ExternalResultsXMLParser.parse().

static <T> Document org.sleuthkit.autopsy.coreutils.XMLUtil.loadDoc ( Class< T >  clazz,
String  xmlPath,
String  xsdPath 
)
static

Loads XML files from disk

Parameters
clazzthe class this method is invoked from
xmlPaththe full path to the file to load
xsdPaththe full path to the file to validate against

Definition at line 253 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.Logger.getLogger(), org.sleuthkit.autopsy.coreutils.XMLUtil.loadDoc(), and org.sleuthkit.autopsy.coreutils.XMLUtil.xmlIsValid().

static <T> Document org.sleuthkit.autopsy.coreutils.XMLUtil.loadDocument ( String  docPath,
Class< T >  clazz,
String  schemaResourceName 
) throws IOException, ParserConfigurationException, SAXException
static

Loads an XML document into a WC3 DOM and validates it using a schema packaged as a class resource.

Parameters
docPathThe full path to the XML document.
clazzThe class associated with the schema resource.
schemaResourceNameThe name of the schema resource.
Returns
The WC3 DOM document object.
Exceptions
IOException
ParserConfigurationException
SAXException

Definition at line 85 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.XMLUtil.validateDocument().

static Document org.sleuthkit.autopsy.coreutils.XMLUtil.loadDocument ( String  docPath) throws ParserConfigurationException, SAXException, IOException
static

Loads an XML document into a WC3 DOM.

Parameters
docPathThe full path to the XML document.
Returns
The WC3 DOM document object.
Exceptions
ParserConfigurationException
SAXException
IOException

Definition at line 102 of file XMLUtil.java.

static <T> boolean org.sleuthkit.autopsy.coreutils.XMLUtil.saveDoc ( Class< T >  clazz,
String  xmlPath,
String  encoding,
final Document  doc 
)
static

Saves XML files to disk

Parameters
clazzthe class this method is invoked from
xmlPaththe full path to save the XML to
encodingto encoding, such as "UTF-8", to encode the file with
docthe document to save

Definition at line 270 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.Logger.getLogger().

static void org.sleuthkit.autopsy.coreutils.XMLUtil.saveDocument ( final Document  doc,
String  encoding,
String  docPath 
) throws TransformerConfigurationException, FileNotFoundException, UnsupportedEncodingException, TransformerException, IOException
static

Saves a WC3 DOM by writing it to an XML document.

Parameters
docThe WC3 DOM document object.
docPathThe full path to the XML document.
encodingEncoding scheme to use for the XML document, e.g., "UTF-8."
Exceptions
TransformerConfigurationException
FileNotFoundException
UnsupportedEncodingException
TransformerException
IOException

Definition at line 142 of file XMLUtil.java.

static <T> void org.sleuthkit.autopsy.coreutils.XMLUtil.validateDocument ( final Document  doc,
Class< T >  clazz,
String  schemaResourceName 
) throws SAXException, IOException
static

Validates a WC3 DOM using a schema packaged as a class resource.

Parameters
doc
clazz
schemaResourceName
Exceptions
SAXException
IOException

Definition at line 119 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.PlatformUtil.extractResourceToUserConfigDir(), and org.sleuthkit.autopsy.coreutils.PlatformUtil.getUserConfigDirectory().

Referenced by org.sleuthkit.autopsy.coreutils.XMLUtil.loadDocument().

static <T> boolean org.sleuthkit.autopsy.coreutils.XMLUtil.xmlIsValid ( DOMSource  xmlfile,
Class< T >  clazz,
String  schemaFile 
)
static

Utility to validate XML files against pre-defined schema files.

The schema files are extracted automatically when this function is called, the XML being validated is not. Be sure the XML file is already extracted otherwise it will return false.

Parameters
xmlfileThe XML file to validate, in DOMSource format
clazzclass frm package to extract schema file from
schemaFileThe file name of the schema to validate against, must exist as a resource in the same package as where this function is being called.

For example usages, please see KeywordSearchListsXML, HashDbXML, or IngestModuleLoader.

Definition at line 177 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.PlatformUtil.extractResourceToUserConfigDir(), org.sleuthkit.autopsy.coreutils.Logger.getLogger(), and org.sleuthkit.autopsy.coreutils.PlatformUtil.getUserConfigDirectory().

Referenced by org.sleuthkit.autopsy.coreutils.XMLUtil.loadDoc(), and org.sleuthkit.autopsy.coreutils.XMLUtil.xmlIsValid().

static <T> boolean org.sleuthkit.autopsy.coreutils.XMLUtil.xmlIsValid ( Document  doc,
Class< T >  clazz,
String  type 
)
static

Evaluates XML files against an XSD.

The schema files are extracted automatically when this function is called, the XML being validated is not. Be sure the XML file is already extracted otherwise it will return false.

Parameters
docThe XML DOM to validate
clazzclass from package to extract schema from
typeThe file name of the schema to validate against, must exist as a resource in the same package as where this function is being called

For example usages, please see KeywordSearchListsXML, HashDbXML, or IngestModuleLoader.

Definition at line 216 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.XMLUtil.xmlIsValid().


The documentation for this class was generated from the following file:

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jan 2 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.