public class XmlJzCfgAnalyzer
extends java.lang.Object
XmlJzReader parse results.
https://vishia.org/Java/html/RWTrans/XmlJzReader.html
or see documentation on XmlJzCfgAnalyzer.CmdArgs.
| Modifier and Type | Class and Description |
|---|---|
static class |
XmlJzCfgAnalyzer.AttribRead |
private static class |
XmlJzCfgAnalyzer.CmdArgs |
(package private) static class |
XmlJzCfgAnalyzer.XmlStructureData |
(package private) static class |
XmlJzCfgAnalyzer.XmlStructureNode
This class is one node for one element to store the structure of a XML file via
XmlJzReader. |
| Modifier and Type | Field and Description |
|---|---|
(package private) java.util.TreeMap<java.lang.String,XmlJzCfgAnalyzer.XmlStructureData.CfgSubtreeType> |
allElementTypes
Contains one element for each tag name or node type.
|
(package private) XmlCfg |
cfgData |
(package private) XmlCfg |
cfgGiven |
(package private) XmlCfg |
cfgGiven1 |
private XmlJzCfgAnalyzer.CmdArgs |
cmdArgs |
(package private) int |
debugStopLineXmlInp |
(package private) java.io.File |
dirDbg |
(package private) LogMessage |
log |
static java.lang.String |
version
Version, License and History:
2025-12-15 Hartmut: bugfix of new stuff.
|
(package private) XmlJzCfgAnalyzer.XmlStructureData |
xmlStructData
The common structure data of the read XML file.
|
(package private) XmlJzCfgAnalyzer.XmlStructureNode |
xmlStructTree
Contains for each tag as key all occurrences of nodes with this tag.
|
| Constructor and Description |
|---|
XmlJzCfgAnalyzer() |
| Modifier and Type | Method and Description |
|---|---|
private void |
addWrNode(XmlNode wrCfgXmlNode,
XmlJzCfgAnalyzer.XmlStructureNode structNode,
int recursion)
Adds the node and recursively all sub nodes from
XmlJzCfgAnalyzer.XmlStructureNode
It is invoked after a XML file war read with XmlCfg#newCfgReadStruct() |
static int |
amain(XmlJzCfgAnalyzer.CmdArgs args)
Reads a XML file and writes its structure as cfg.xml to help creating a config for the XmlJzReader
|
(package private) void |
analyzeXml(XmlJzCfgAnalyzer.CmdArgs args)
Reads given XML file(s) and writes its structure as cfg.xml or cfg.txt to help creating a config for the XmlJzReader.
|
XmlCfg |
analyzeXmlFile(java.util.List<FileFunctions.FilePathnameExt> fIn)
Reads any XML file and stores the structure in the returned
XmlCfg. |
XmlCfg |
analyzeXmlStruct(java.io.File fXmlIn)
Reads and analyses any XML file and stores the structure in the
#XmlCfg. |
private void |
checkStructTree()
Checks the read XML structure tree.
|
private void |
fillNodesGivenForCheckSubtree(XmlCfg.XmlCfgNode node,
java.util.Map<java.lang.String,XmlCfg.XmlCfgNode> idxNodesGiven,
int recursion) |
static void |
main(java.lang.String[] sArgs) |
void |
mergeNode(XmlCfg.XmlCfgNode ndDst,
XmlJzCfgAnalyzer.XmlStructureNode ndSrc) |
static XmlCfg |
newCfgReadStruct()
Creates the configuration to read any xml file to store its structure especially in
XmlJzCfgAnalyzer.XmlStructureNode. |
XmlCfg |
readXmlStruct(java.io.File fXmlIn)
Compatible form
|
XmlCfg |
readXmlStructZip(java.io.File fIn,
java.lang.String sPathInZip)
Reads any XML file and stores the structure in the
#XmlCfg. |
private void |
resetCtNodesInStructTree() |
private void |
resetCtNodesInStructTree(XmlJzCfgAnalyzer.XmlStructureNode node,
int recursion) |
void |
setDebugStop(int line)
Only for internal debug.
|
void |
setDirDebug(java.io.File dir) |
static int |
smain(java.lang.String[] sArgs,
java.lang.Appendable logHelp,
java.lang.Appendable logError)
main gets the arguments as String,
but does not catch unexpected exceptions and does not System.exit(...), use it to execute in a Java environment.
|
private void |
storeCfgNode(XmlCfg.XmlCfgNode dst,
XmlJzCfgAnalyzer.XmlStructureNode src,
boolean bRoot,
int recursion)
Copy or add the content of the read
XmlJzCfgAnalyzer.XmlStructureData 'srx' to the XmlCfg 'dst'. |
private void |
storeInCfg(XmlJzReader xmlReader) |
void |
writeCfgTemplate(java.io.File wrCfg)
Writes the config file for the XmlJzReader with config file.
|
void |
writeCfgText(java.io.File fout)
Writes the config file for the XmlJzReader with config file.
|
void |
writeData(java.io.File fout) |
private void |
writeJavaClasses() |
private void |
wrSetAddContentAttrib(XmlJzCfgAnalyzer.XmlStructureNode structNode,
XmlNode wrCfgXmlNode) |
public static final java.lang.String version
XmlStructureNode#finishElement(XmlStructureNode),
set the XmlJzCfgAnalyzer.XmlStructureNode.ctTextInNode =0 on new call of XmlJzCfgAnalyzer.XmlStructureNode.addElement(String)
Now the XmlJzCfgAnalyzer.XmlStructureNode.ctText, 'TEXT-LIST' detection is correct.
checkStructTree() recognises given subtrees in cfgGiven.
#XXXreadNode(BufferedReader, String) etc. seems to be unnecessary.
XmlJzCfgAnalyzer.CmdArgs now. Not ready for all.
XmlCfg.
GenXmlCfgJavaData.
private XmlJzCfgAnalyzer.CmdArgs cmdArgs
java.io.File dirDbg
int debugStopLineXmlInp
LogMessage log
final XmlJzCfgAnalyzer.XmlStructureData xmlStructData
XmlJzCfgAnalyzer.XmlStructureNode xmlStructTree
XmlJzCfgAnalyzer.XmlStructureNode.addElement(String).java.util.TreeMap<java.lang.String,XmlJzCfgAnalyzer.XmlStructureData.CfgSubtreeType> allElementTypes
XmlJzCfgAnalyzer.XmlStructureData.CfgSubtreeType.occurrence of the element
contains only one instance of XmlJzCfgAnalyzer.XmlStructureNode if the node with this tag is only found in one constellation,
but maybe more as one time in the same parent.
XmlJzCfgAnalyzer.XmlStructureNode ia stored in XmlJzCfgAnalyzer.XmlStructureData.CfgSubtreeType.occurrence.
checkStructTree() checks, if the occurrences are substantial equal, (yet always),
then a 'SUBTREE' is created to prevent effort in the configuration,
respectively allow recursively using of a node type.XmlCfg cfgData
XmlCfg cfgGiven
XmlCfg cfgGiven1
public static void main(java.lang.String[] sArgs)
public static int smain(java.lang.String[] sArgs,
java.lang.Appendable logHelp,
java.lang.Appendable logError)
throws java.io.IOException
sArgs - java.io.IOExceptionjava.lang.Exception - if unexpected.public static int amain(XmlJzCfgAnalyzer.CmdArgs args)
args - pathfileIn.xml pathfileOutcfg.xmlpublic static XmlCfg newCfgReadStruct()
XmlJzCfgAnalyzer.XmlStructureNode.public void setDirDebug(java.io.File dir)
public void setDebugStop(int line)
line - void analyzeXml(XmlJzCfgAnalyzer.CmdArgs args) throws java.io.IOException
analyzeXmlFile(List).
XmlJzCfgAnalyzer.CmdArgs.fxOut is given, it calls writeCfgTemplate(File).
XmlJzCfgAnalyzer.CmdArgs.fWriteXmlConfigText
with the capability in XmlCfg: XmlCfg.writeToText(File, LogMessage).
args - from main invocation, also from any other Java call with this args as super class.
XmlJzCfgAnalyzer.CmdArgs.listfIn either zip with xml or xml file, more as one possible.
XmlJzCfgAnalyzer.CmdArgs.fdOut to write with writeData(File) currently not used and tested.
XmlJzCfgAnalyzer.CmdArgs.fWriteXmlConfigText to write the content of analysed configuration to a config.txt file
usable for XmlCfg.readCfgFile(File, LogMessage) later for parsing.
XmlJzCfgAnalyzer.CmdArgs.fxOut to write the content of analysed configuration to a config.xml file.
This is meanwhile (2025-12) no more recommended, use the textual config presentation.
It is usable for XmlJzReader#se later for parsing.
java.io.IOExceptionpublic XmlCfg analyzeXmlFile(java.util.List<FileFunctions.FilePathnameExt> fIn) throws java.io.IOException
XmlCfg.
The found configuration should be writtem out after them with XmlCfg.writeToText(File, LogMessage)
to use it to configure the XmlJzReader.setCfg(XmlCfg) with a proper configuration,
which reads the here created textual configuration file via
XmlCfg.readCfgFile(File, LogMessage) or XmlCfg.readFromJar(Class, String, LogMessage).
Whereby, for further usage, the configuration file and also the possible created Java classes
can be manual adapted before further usage.
XmlJzReader.readXml(File, Object)
due to the set config with newCfgReadStruct().
XmlJzCfgAnalyzer.XmlStructureNode.addElement(String) on a new node on 'XmlJzCfgAnalyzer.XmlStructureNode.setAttribute(String) on a attribute
XmlJzCfgAnalyzer.XmlStructureNode.addNamespace(String, String) on a 'xmlns:...' attribute
XmlJzCfgAnalyzer.XmlStructureNode.setTextOccurrence() on a text.
xmlStructData:
Note: renamed from readXmlStructZip(...)fXmlIn - The file, immediately the XML file or a zip file containing the XML file.pathInZip - null for reading immediately XML, else the path in the zip file to the XML file to read.java.io.IOExceptionpublic void writeCfgTemplate(java.io.File wrCfg)
wrCfg - the output file.public void writeCfgText(java.io.File fout)
wrCfg - the output file.private void resetCtNodesInStructTree()
private void resetCtNodesInStructTree(XmlJzCfgAnalyzer.XmlStructureNode node, int recursion)
private void writeJavaClasses()
throws java.nio.charset.IllegalCharsetNameException,
java.nio.charset.UnsupportedCharsetException
java.nio.charset.IllegalCharsetNameExceptionjava.nio.charset.UnsupportedCharsetExceptionprivate void wrSetAddContentAttrib(XmlJzCfgAnalyzer.XmlStructureNode structNode, XmlNode wrCfgXmlNode) throws XmlException
XmlExceptionprivate void addWrNode(XmlNode wrCfgXmlNode, XmlJzCfgAnalyzer.XmlStructureNode structNode, int recursion) throws XmlException
XmlJzCfgAnalyzer.XmlStructureNode
It is invoked after a XML file war read with XmlCfg#newCfgReadStruct()wrCfgXmlNode - The xml node for output to add.structNode - The node from the structure of the read XML file,recursion - decremented, exception on <=0XmlException - on XML error, IllegalArgumentException on recursion error.public XmlCfg analyzeXmlStruct(java.io.File fXmlIn) throws java.io.IOException
#XmlCfg.
Description see #analyzeXmlStructZip(File, String)
Note: compatible form calls analyzeXmlFile(List)fXmlIn - java.io.IOExceptionpublic XmlCfg readXmlStruct(java.io.File fXmlIn) throws java.io.IOException
fXmlIn - java.io.IOExceptionpublic XmlCfg readXmlStructZip(java.io.File fIn, java.lang.String sPathInZip) throws java.io.IOException
#XmlCfg.
Description see #analyzeXmlStructZip(File, String)
Note: compatible form calls analyzeXmlFile(List)fIn - zip filesPathInZip - null then fIn should be an XML file, else path of the XML file in the zipjava.io.IOExceptionprivate void checkStructTree()
allElementTypes.
That entries knows all XmlStructNode occurrences.
If a XmlStructNode is used in several constellations (more as one time found, different parent),
then an entry in cfgData XmlCfg.subtrees will be created to mark, it is an candidate for SUBTREE.
The SUBTREE in cfgData is then filled in storeInCfg(XmlJzReader).private final void fillNodesGivenForCheckSubtree(XmlCfg.XmlCfgNode node, java.util.Map<java.lang.String,XmlCfg.XmlCfgNode> idxNodesGiven, int recursion)
private void storeInCfg(XmlJzReader xmlReader)
private void storeCfgNode(XmlCfg.XmlCfgNode dst, XmlJzCfgAnalyzer.XmlStructureNode src, boolean bRoot, int recursion) throws java.text.ParseException
XmlJzCfgAnalyzer.XmlStructureData 'srx' to the XmlCfg 'dst'.
This can be a simple inner child node which is created with 'dst' in its parent,
or it can be also the first node of a XmlCfg.subtreesdst - the destination where info from 'src' are storedsrc - read data from evaluated XMLbRoot - true then ignore XmlJzCfgAnalyzer.XmlStructureNode.sSubtreenode because it is the name of the subtree itself,
and not the reference to a subtree.recursion - called recursively for all sub nodesjava.text.ParseExceptionpublic void mergeNode(XmlCfg.XmlCfgNode ndDst, XmlJzCfgAnalyzer.XmlStructureNode ndSrc)
public void writeData(java.io.File fout)
throws java.io.IOException
java.io.IOException