public class XMLMaterialManager extends Object
MaterialManager
.
It is also used to keep track of compact material data for the conversion to/from
compact descriptions.
To distinguish between XML and chemical "elements" in the code, I sometimes use the
term "node" to refer to an XML element.Modifier and Type | Field and Description |
---|---|
private org.jdom.Document |
currentDoc |
private HashMap<String,org.jdom.Element> |
elementMap |
private static String |
elementResource |
private static XMLMaterialManager |
elements |
private HashMap<String,org.jdom.Element> |
materialMap |
private static String |
materialResource |
private static XMLMaterialManager |
materials |
private static MaterialManager |
mgr |
private XMLMaterialManager |
parent |
Modifier | Constructor and Description |
---|---|
private |
XMLMaterialManager()
The default ctor should not be used.
|
|
XMLMaterialManager(org.jdom.Element materialsRoot)
Ctor for a manager with the given root XML node, probably pointing to the
materials section of a compact detector description.
|
private |
XMLMaterialManager(XMLMaterialManager p)
Ctor for XMLMaterialFactory with given parent and no initial material data.
|
Modifier and Type | Method and Description |
---|---|
void |
addMaterialElementRef(org.jdom.Element e)
Add a material element XML node to the lookup map.
|
void |
addMaterialRef(org.jdom.Element e)
Add a material XML node to the lookup map.
|
void |
clearMaterialMap() |
private org.jdom.Document |
cloneMaterialsRoot(org.jdom.Element e)
Create a new document from a materials section.
|
private static XMLMaterialManager |
createMaterialElements()
Create the static instance of the elements manager.
|
private static XMLMaterialManager |
createMaterials()
Create the static instance of the material manager.
|
private org.jdom.Element |
findMaterialElementXML(String elemName)
Find the XML node for the material or element called
elemName
in the current Document. |
org.jdom.Element |
findMaterialElementXML(String elemName,
org.jdom.Document d)
Find a chemical element in a document.
|
private org.jdom.Element |
findMaterialXML(String matName)
Find a material in the manager's document.
|
org.jdom.Element |
findMaterialXML(String matName,
org.jdom.Document d)
Find a material in an XML document.
|
org.jdom.Document |
getCurrentDocument()
Get the current XML document known by this manager.
|
static XMLMaterialManager |
getDefaultMaterialManager()
Get manager with default materials defined in the embedded resource file.
|
static XMLMaterialManager |
getElementsManager()
Get the manager with chemical element data.
|
Map<String,org.jdom.Element> |
getElementXMLMap()
Get the map of XML chemical element nodes known by this manager.
|
org.jdom.Element |
getMaterialElementXML(String elemName)
Find the XML node for a chemical element.
|
private static org.jdom.Element |
getMaterialsRoot(org.jdom.Document d)
Attempt to find the materials section in a document using two possible cases.
|
org.jdom.Element |
getMaterialXML(String matName)
Find the XML element for a material.
|
Map<String,org.jdom.Element> |
getMaterialXMLMap()
Get the map of XML material nodes known by this manager.
|
protected boolean |
hasParentManager()
Check if this object has a parent manager.
|
private void |
loadElementsFromResource()
Load the chemical elements data from the embedded resource file into this manager.
|
private void |
loadMaterialsFromResource(String resource)
Load materials from an embedded resource in the jar file.
|
private void |
loadMaterialsFromXML(org.jdom.Element materialsRoot)
Creates lcsim materials from an XML element pointing to a GDML materials section.
|
private void |
makeMaterialFromXML(org.jdom.Element matNode)
Create an lcsim Material from XML.
|
private void |
setCurrentDocument(org.jdom.Document d)
Set current document source.
|
void |
setMaterialsRoot(org.jdom.Element e)
Set the XML element containing the materials section for this manager.
|
static void |
setup()
Setup static material data.
|
private static final String elementResource
private static final String materialResource
private static MaterialManager mgr
private static XMLMaterialManager elements
private static XMLMaterialManager materials
private XMLMaterialManager parent
private org.jdom.Document currentDoc
public XMLMaterialManager(org.jdom.Element materialsRoot)
materialsRoot
- The XML element pointing to a materials section.private XMLMaterialManager()
private XMLMaterialManager(XMLMaterialManager p)
p
- The parent manager.public static void setup()
public static XMLMaterialManager getDefaultMaterialManager()
public static XMLMaterialManager getElementsManager()
public Map<String,org.jdom.Element> getMaterialXMLMap()
public Map<String,org.jdom.Element> getElementXMLMap()
public void addMaterialRef(org.jdom.Element e)
e
- The XML node to add.public void addMaterialElementRef(org.jdom.Element e)
e
- The XML ndoe to add.public org.jdom.Element getMaterialXML(String matName)
matName
or null if doesn't exist.public org.jdom.Element getMaterialElementXML(String elemName)
elemName
- The name of the chemical element.elemName
or null if doesn't exist.public org.jdom.Element findMaterialElementXML(String elemName, org.jdom.Document d)
elemName
.public org.jdom.Document getCurrentDocument()
public org.jdom.Element findMaterialXML(String matName, org.jdom.Document d)
matName
- The name of the material.d
- The document to search.matName
or null if not found.private static XMLMaterialManager createMaterialElements()
private static XMLMaterialManager createMaterials()
private void setCurrentDocument(org.jdom.Document d)
d
- The Document with a materials node as its child.protected boolean hasParentManager()
private static org.jdom.Element getMaterialsRoot(org.jdom.Document d)
d
- Document to search for materials element.private org.jdom.Element findMaterialElementXML(String elemName)
elemName
in the current Document.elemName
- The name attribute value of the node.elemName
or null if not found.org.jdom.JDOMException
private org.jdom.Element findMaterialXML(String matName)
matName
- The name of the material.matName
or null if not found.private org.jdom.Document cloneMaterialsRoot(org.jdom.Element e)
e
- The XML element of the materials section.public void setMaterialsRoot(org.jdom.Element e)
e
- The XML element pointing to a materials section.private void loadElementsFromResource()
private void loadMaterialsFromResource(String resource)
resource
- Resource location string.private void loadMaterialsFromXML(org.jdom.Element materialsRoot)
materialsRoot
- The GDML materials section.private void makeMaterialFromXML(org.jdom.Element matNode)
matNode
- The XML Element pointing to a material node.public void clearMaterialMap()
Copyright © 2016 Linear Collider Detector (LCD). All rights reserved.