Class DexpiXmlReader
java.lang.Object
neqsim.process.processmodel.DexpiXmlReader
Utility for reading DEXPI XML files and converting them into NeqSim process models.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map<String, EquipmentEnum> private static final org.apache.logging.log4j.Loggerprivate static final Map<String, EquipmentEnum> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddDexpiStream(ProcessSystem processSystem, Element element, Stream templateStream, String baseName) private static voidaddDexpiUnit(ProcessSystem processSystem, Element element, EquipmentEnum equipmentEnum, String baseName, String componentClass) private static voidaddPipingSegments(Document document, ProcessSystem processSystem, Stream templateStream) private static voidaddUnits(Document document, ProcessSystem processSystem, String tagName, Map<String, EquipmentEnum> equipmentMap, String nameAttribute) private static voidapplyNumericAttribute(Element element, String valueAttribute, String unitAttribute, BiConsumer<Double, String> consumer, String defaultUnit) private static voidapplyStreamMetadata(Element element, DexpiStream stream) private static StringattributeValue(Element element, String attributeName) private static SystemInterfaceprivate static StreamdirectChildElements(Element element, String tagName) private static StringensureUniqueName(ProcessSystem processSystem, String candidate) private static StringfindAttributeInAncestors(Node node, String attributeName) private static StringfirstNonEmpty(String... candidates) private static StringgetGenericAttribute(Element element, String attributeName) private static booleanstatic voidload(File file, ProcessSystem processSystem) Populates an existingProcessSystemwith units parsed from a DEXPI XML file.static voidload(File file, ProcessSystem processSystem, Stream templateStream) Populates an existingProcessSystemwith units parsed from a DEXPI XML file.static voidload(InputStream inputStream, ProcessSystem processSystem) Populates an existingProcessSystemwith units parsed from a DEXPI XML stream.static voidload(InputStream inputStream, ProcessSystem processSystem, Stream templateStream) Populates an existingProcessSystemwith units parsed from a DEXPI XML stream.private static DocumentparseDocument(InputStream inputStream) private static DoubleparseNumeric(String valueText) private static StringprependLineOrFluid(Element element, String baseName) static ProcessSystemReads the provided DEXPI XML file and returns a populatedProcessSystem.static ProcessSystemReads the provided DEXPI XML file and returns a populatedProcessSystemusing a templateStreamfor generated piping segments.static ProcessSystemread(InputStream inputStream) Reads the provided DEXPI XML stream and returns a populatedProcessSystem.static ProcessSystemread(InputStream inputStream, Stream templateStream) Reads the provided DEXPI XML stream and returns a populatedProcessSystemusing a templateStreamfor any generated piping segments.private static StreamtemplateOrDefault(Stream templateStream)
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger -
EQUIPMENT_CLASS_MAP
-
PIPING_COMPONENT_MAP
-
-
Constructor Details
-
DexpiXmlReader
private DexpiXmlReader()
-
-
Method Details
-
read
Reads the provided DEXPI XML file and returns a populatedProcessSystem.- Parameters:
file- DEXPI XML file- Returns:
- a process system populated with units found in the XML
- Throws:
IOException- if the file cannot be readDexpiXmlReaderException- if the file cannot be parsed
-
read
public static ProcessSystem read(File file, Stream templateStream) throws IOException, DexpiXmlReaderException Reads the provided DEXPI XML file and returns a populatedProcessSystemusing a templateStreamfor generated piping segments.- Parameters:
file- DEXPI XML filetemplateStream- stream providing default fluid, temperature, pressure, and flow rate for generated piping segments. Ifnull, a methane/ethane default is used.- Returns:
- a process system populated with units found in the XML
- Throws:
IOException- if the file cannot be readDexpiXmlReaderException- if the file cannot be parsed
-
read
public static ProcessSystem read(InputStream inputStream) throws IOException, DexpiXmlReaderException Reads the provided DEXPI XML stream and returns a populatedProcessSystem.- Parameters:
inputStream- stream containing DEXPI XML data- Returns:
- a process system populated with units found in the XML
- Throws:
IOException- if the stream cannot be readDexpiXmlReaderException- if the stream cannot be parsed
-
read
public static ProcessSystem read(InputStream inputStream, Stream templateStream) throws IOException, DexpiXmlReaderException Reads the provided DEXPI XML stream and returns a populatedProcessSystemusing a templateStreamfor any generated piping segments.- Parameters:
inputStream- stream containing DEXPI XML datatemplateStream- stream providing default fluid, temperature, pressure, and flow rate for generated piping segments. Ifnull, a methane/ethane default is used.- Returns:
- a process system populated with units found in the XML
- Throws:
IOException- if the stream cannot be readDexpiXmlReaderException- if the stream cannot be parsed
-
load
public static void load(File file, ProcessSystem processSystem) throws IOException, DexpiXmlReaderException Populates an existingProcessSystemwith units parsed from a DEXPI XML file.- Parameters:
file- XML file to parseprocessSystem- target process system- Throws:
IOException- if reading failsDexpiXmlReaderException- if the file cannot be parsed
-
load
public static void load(File file, ProcessSystem processSystem, Stream templateStream) throws IOException, DexpiXmlReaderException Populates an existingProcessSystemwith units parsed from a DEXPI XML file.- Parameters:
file- XML file to parseprocessSystem- target process systemtemplateStream- stream providing default fluid, temperature, pressure, and flow rate for generated piping segments. Ifnull, a methane/ethane default is used.- Throws:
IOException- if reading failsDexpiXmlReaderException- if the file cannot be parsed
-
load
public static void load(InputStream inputStream, ProcessSystem processSystem) throws IOException, DexpiXmlReaderException Populates an existingProcessSystemwith units parsed from a DEXPI XML stream.- Parameters:
inputStream- XML input streamprocessSystem- target process system- Throws:
IOException- if reading failsDexpiXmlReaderException- if the stream cannot be parsed
-
load
public static void load(InputStream inputStream, ProcessSystem processSystem, Stream templateStream) throws IOException, DexpiXmlReaderException Populates an existingProcessSystemwith units parsed from a DEXPI XML stream.- Parameters:
inputStream- XML input streamprocessSystem- target process systemtemplateStream- stream providing default fluid, temperature, pressure, and flow rate for generated piping segments. Ifnull, a methane/ethane default is used.- Throws:
IOException- if reading failsDexpiXmlReaderException- if the stream cannot be parsed
-
parseDocument
- Throws:
DexpiXmlReaderException
-
addUnits
private static void addUnits(Document document, ProcessSystem processSystem, String tagName, Map<String, EquipmentEnum> equipmentMap, String nameAttribute) -
addPipingSegments
private static void addPipingSegments(Document document, ProcessSystem processSystem, Stream templateStream) -
addDexpiStream
private static void addDexpiStream(ProcessSystem processSystem, Element element, Stream templateStream, String baseName) -
addDexpiUnit
private static void addDexpiUnit(ProcessSystem processSystem, Element element, EquipmentEnum equipmentEnum, String baseName, String componentClass) -
prependLineOrFluid
-
ensureUniqueName
-
templateOrDefault
-
createDefaultTemplateStream
-
createDefaultFluid
-
getGenericAttribute
-
attributeValue
-
applyStreamMetadata
-
applyNumericAttribute
-
parseNumeric
-
directChildElements
-
findAttributeInAncestors
-
firstNonEmpty
-
isBlank
-