Class XMLUtil
java.lang.Object
org.csstudio.opibuilder.persistence.XMLUtil
The utility class for XML related operation.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfillDisplayModelFromInputStream(InputStream inputStream, DisplayModel displayModel) Fill the DisplayModel from an OPI file inputstream.static voidfillDisplayModelFromInputStream(InputStream inputStream, DisplayModel displayModel, Display display) Fill the DisplayModel from an OPI file inputstreamstatic voidfillDisplayModelFromInputStream(InputStream inputStream, DisplayModel displayModel, Display display, MacrosInput macrosInput_) Fill the DisplayModel from an OPI file inputstreamstatic voidLoad opi file attached to LinkingContainer widget.static voidfillLinkingContainers(AbstractContainerModel container) Fill all LinkingContainers under the model.static AbstractWidgetModelfillWidgets(org.jdom2.Element element, DisplayModel displayModel) Convert XML Element to a widget model.static AbstractWidgetModelfillWidgetsFromXMLString(String xmlString, DisplayModel displayModel) Convert XML String to a widget model.static StringfindClosestWidgetUid(InputStream in, int offset) Return the wuid of the closest widget to offset char position in input streamstatic voidwidgetToOutputStream(AbstractWidgetModel widgetModel, OutputStream out, boolean prettyFormat) Write widget to an output stream.static org.jdom2.ElementwidgetToXMLElement(AbstractWidgetModel widgetModel) Flatten a widget to XML element.static StringwidgetToXMLString(AbstractWidgetModel widgetModel, boolean prettyFormat) Flatten a widget to XML String.static AbstractWidgetModelXMLElementToWidget(org.jdom2.Element element) Convert an XML element to widget.static AbstractWidgetModelXMLElementToWidget(org.jdom2.Element element, DisplayModel displayModel) Construct widget model from XML element.static AbstractWidgetModelXMLStringToWidget(String xmlString) Convert an XML String to widget model
-
Field Details
-
XML_HEADER
- See Also:
-
XMLTAG_DISPLAY
-
XMLTAG_WIDGET
-
XMLTAG_CONNECTION
-
WIDGET_TAGS
-
XMLATTR_TYPEID
-
XMLATTR_PROPID
-
XMLATTR_VERSION
-
XMLTAG_WIDGET_UID
-
XMLTAG_OPI_FILE
-
-
Constructor Details
-
XMLUtil
public XMLUtil()
-
-
Method Details
-
widgetToXMLElement
Flatten a widget to XML element.- Parameters:
widgetModel- model of the widget- Returns:
- the XML element
-
widgetToXMLString
Flatten a widget to XML String.- Parameters:
widgetModel- model of the widget.prettyFormat- true if the string is in pretty format- Returns:
- the XML String
-
widgetToOutputStream
public static void widgetToOutputStream(AbstractWidgetModel widgetModel, OutputStream out, boolean prettyFormat) throws IOException Write widget to an output stream.- Parameters:
widgetModel- model of the widgetout- output streamprettyFormat- true if in pretty format- Throws:
IOException
-
XMLStringToWidget
Convert an XML String to widget model- Parameters:
xmlString-- Returns:
- the widget model
- Throws:
Exception
-
XMLElementToWidget
Convert an XML element to widget.- Parameters:
element- the element- Returns:
- model of the widget.
- Throws:
Exception
-
fillDisplayModelFromInputStream
public static void fillDisplayModelFromInputStream(InputStream inputStream, DisplayModel displayModel, Display display) throws Exception Fill the DisplayModel from an OPI file inputstream- Parameters:
inputStream- the inputstream will be closed in this method before return.displayModel- . TheDisplayModelto be filled.display- the display in UI Thread.- Throws:
Exception
-
fillDisplayModelFromInputStream
public static void fillDisplayModelFromInputStream(InputStream inputStream, DisplayModel displayModel, Display display, MacrosInput macrosInput_) throws Exception Fill the DisplayModel from an OPI file inputstream- Parameters:
inputStream- the inputstream will be closed in this method before return.displayModel- . TheDisplayModelto be filled.display- the display in UI Thread.- Throws:
Exception
-
fillDisplayModelFromInputStream
public static void fillDisplayModelFromInputStream(InputStream inputStream, DisplayModel displayModel) throws Exception Fill the DisplayModel from an OPI file inputstream. In RAP, it must be called in UI Thread.- Parameters:
inputStream- the inputstream will be closed in this method before return.displayModel-- Throws:
Exception
-
XMLElementToWidget
public static AbstractWidgetModel XMLElementToWidget(org.jdom2.Element element, DisplayModel displayModel) throws Exception Construct widget model from XML element. Sometimes it includes filling LinkingContainer and/or construct Connection model between widgets.- Parameters:
element-displayModel- the root display model. If root of the element is a display, use this display model as root model instead of creating a new one. If this is null, a new one will be created.- Returns:
- the root widget model
- Throws:
Exception
-
fillWidgetsFromXMLString
public static AbstractWidgetModel fillWidgetsFromXMLString(String xmlString, DisplayModel displayModel) throws Exception Convert XML String to a widget model.- Parameters:
xmlString-displayModel- the root display model. If root of the element is a display, use this display model as root model instead of creating a new one. If this is null, a new one will be created.- Throws:
Exception
-
fillWidgets
public static AbstractWidgetModel fillWidgets(org.jdom2.Element element, DisplayModel displayModel) throws Exception Convert XML Element to a widget model.- Parameters:
element-displayModel- the root display model. If root of the element is a display, use this display model as root model instead of creating a new one. If this is null, a new one will be created.- Throws:
Exception
-
fillLinkingContainers
Fill all LinkingContainers under the model.- Parameters:
container- LinkingContainer to be filled.- Throws:
Exception
-
fillLinkingContainer
Load opi file attached to LinkingContainer widget.- Parameters:
container- LinkingContainer to be filled.- Throws:
Exception
-
findClosestWidgetUid
Return the wuid of the closest widget to offset char position in input stream- Parameters:
in- the OPI file input streamoffset- the character offset- Returns:
- String wuid
- Throws:
IOException
-