Package x3
Class X3FileSystem
java.lang.Object
x3.X3FileSystem
- Direct Known Subclasses:
X3D3FileSystem
,X3PBFileSystem
public abstract class X3FileSystem
extends java.lang.Object
Interface for dealing with the two slightly different X3 file systems
(even though we're hoping to fade one out asap).
- Author:
- Doug Gillespie
-
Field Summary
Fields Modifier and Type Field Description static int
X3_D3X3A
static int
X3_PAMBUOY
static int
X3_UNKNOWN
-
Constructor Summary
Constructors Constructor Description X3FileSystem()
-
Method Summary
Modifier and Type Method Description org.w3c.dom.Document
convertStringToDocument(java.lang.String xmlStr)
Generate an xml documnet from a string.abstract org.w3c.dom.Document
createX3HeaderXML(int blockLength, int sampleRate, int nChannels)
Create an XML document with header information.abstract X3FileHeader
decodeFileHeader(java.lang.String xmlData)
Called just after the first few bytes of the file have been read in order to identify the file type.org.w3c.dom.Node[]
getNodeArray(org.w3c.dom.NodeList nodeList)
java.util.ArrayList<org.w3c.dom.Node>
getNodeArrayList(org.w3c.dom.Node[] nodeArray)
java.util.ArrayList<org.w3c.dom.Node>
getNodesOfName(java.util.ArrayList<org.w3c.dom.Node> nodes, java.lang.String name)
java.util.ArrayList<org.w3c.dom.Node>
getNodesWithAttributes(java.util.ArrayList<org.w3c.dom.Node> nodes, java.util.HashMap<java.lang.String,java.lang.String> attributes)
java.util.ArrayList<org.w3c.dom.Node>
getNodesWithChildren(java.util.ArrayList<org.w3c.dom.Node> nodes, java.util.HashMap<java.lang.String,java.lang.String> children)
static int
getX3Type(java.io.DataInputStream dataInputStream)
Work out which type of file it is.static int
getX3Type(java.io.File x3File)
Work out which type of file it is.java.lang.String
getXMLDataText(org.w3c.dom.Document doc, int indenting)
Convert an XML Document into a stringabstract java.lang.String
readFileHeader(java.io.DataInputStream dis)
abstract X3FrameHeader
readFrameHeader(java.io.DataInputStream dis, X3FileHeader x3FileHeader, X3FrameHeader exHeader)
Read a frame header from the input stream.
-
Field Details
-
X3_UNKNOWN
public static final int X3_UNKNOWN- See Also:
- Constant Field Values
-
X3_PAMBUOY
public static final int X3_PAMBUOY- See Also:
- Constant Field Values
-
X3_D3X3A
public static final int X3_D3X3A- See Also:
- Constant Field Values
-
-
Constructor Details
-
X3FileSystem
public X3FileSystem()
-
-
Method Details
-
getX3Type
public static int getX3Type(java.io.File x3File)Work out which type of file it is.- Parameters:
x3File
- x3File- Returns:
- file type 0 = unknown, 1 = Decimus format, 2 = Marks D3 format.
-
getX3Type
public static int getX3Type(java.io.DataInputStream dataInputStream)Work out which type of file it is.- Parameters:
dataInputStream
-- Returns:
- file type 0 = unknown, 1 = Decimus format, 2 = Marks D3 format.
-
convertStringToDocument
public org.w3c.dom.Document convertStringToDocument(java.lang.String xmlStr)Generate an xml documnet from a string.- Parameters:
xmlStr
- xml string.- Returns:
- xml document
-
readFileHeader
public abstract java.lang.String readFileHeader(java.io.DataInputStream dis) throws java.io.IOException- Throws:
java.io.IOException
-
decodeFileHeader
Called just after the first few bytes of the file have been read in order to identify the file type. All files should start with a valid header, so read it now.- Parameters:
dis
- data input stream- Returns:
- a valid file header structure, or null in the event of failure.
-
readFrameHeader
public abstract X3FrameHeader readFrameHeader(java.io.DataInputStream dis, X3FileHeader x3FileHeader, X3FrameHeader exHeader) throws java.io.IOExceptionRead a frame header from the input stream.- Parameters:
dis
- data input streamx3FileHeader
- file header so data can be extracted if format data is spread incorrectly between file and block headers .exHeader
- Existing frame header which can be reused or will be created if null.- Returns:
- a frame header structure.
- Throws:
java.io.IOException
-
createX3HeaderXML
public abstract org.w3c.dom.Document createX3HeaderXML(int blockLength, int sampleRate, int nChannels)Create an XML document with header information.- Parameters:
blockLength
- block length used throughout filesampleRate
- sample ratenChannels
- number o channels- Returns:
- XML document to go at front of file.
-
getXMLDataText
public java.lang.String getXMLDataText(org.w3c.dom.Document doc, int indenting)Convert an XML Document into a string- Parameters:
doc
- XML Documentindenting
- level of indenting- Returns:
- the XML data as a single String.
-
getNodeArray
public org.w3c.dom.Node[] getNodeArray(org.w3c.dom.NodeList nodeList)- Parameters:
nodeList
-- Returns:
- nodeList as Node[]
-
getNodeArrayList
public java.util.ArrayList<org.w3c.dom.Node> getNodeArrayList(org.w3c.dom.Node[] nodeArray)- Parameters:
nodeArray
-- Returns:
- nodeArray as ArrayList
-
getNodesOfName
public java.util.ArrayList<org.w3c.dom.Node> getNodesOfName(java.util.ArrayList<org.w3c.dom.Node> nodes, java.lang.String name)- Parameters:
nodes
- - ArrayList of nodes to look through for one with specific namename
- - name to match- Returns:
- a copy of "nodes" without ones that are not named name
-
getNodesWithAttributes
public java.util.ArrayList<org.w3c.dom.Node> getNodesWithAttributes(java.util.ArrayList<org.w3c.dom.Node> nodes, java.util.HashMap<java.lang.String,java.lang.String> attributes)- Parameters:
nodes
- - ArrayList of nodes to look through for attributesattributes
- - a HashMap ofattributeVAlue can be null if it is not required to be equal to anything - Returns:
- a copy of "nodes" without ones that don't match
-
getNodesWithChildren
public java.util.ArrayList<org.w3c.dom.Node> getNodesWithChildren(java.util.ArrayList<org.w3c.dom.Node> nodes, java.util.HashMap<java.lang.String,java.lang.String> children)- Parameters:
nodes
- - ArrayList of nodes to look through for child nodeschildren
- - a HashMap ofchildVAlue can be null if it is not required to be equal to anything - Returns:
- a copy of "nodes" without ones that don't match
-