Class XMLUtil

java.lang.Object
org.csstudio.opibuilder.persistence.XMLUtil

public class XMLUtil extends Object
The utility class for XML related operation.
  • Field Details

    • XML_HEADER

      public static final String XML_HEADER
      See Also:
    • XMLTAG_DISPLAY

      public static String XMLTAG_DISPLAY
    • XMLTAG_WIDGET

      public static String XMLTAG_WIDGET
    • XMLTAG_CONNECTION

      public static String XMLTAG_CONNECTION
    • WIDGET_TAGS

      public static Set<String> WIDGET_TAGS
    • XMLATTR_TYPEID

      public static String XMLATTR_TYPEID
    • XMLATTR_PROPID

      public static String XMLATTR_PROPID
    • XMLATTR_VERSION

      public static String XMLATTR_VERSION
    • XMLTAG_WIDGET_UID

      public static String XMLTAG_WIDGET_UID
    • XMLTAG_OPI_FILE

      public static String XMLTAG_OPI_FILE
  • Constructor Details

    • XMLUtil

      public XMLUtil()
  • Method Details

    • widgetToXMLElement

      public static org.jdom2.Element widgetToXMLElement(AbstractWidgetModel widgetModel)
      Flatten a widget to XML element.
      Parameters:
      widgetModel - model of the widget
      Returns:
      the XML element
    • widgetToXMLString

      public static String widgetToXMLString(AbstractWidgetModel widgetModel, boolean prettyFormat)
      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 widget
      out - output stream
      prettyFormat - true if in pretty format
      Throws:
      IOException
    • XMLStringToWidget

      public static AbstractWidgetModel XMLStringToWidget(String xmlString) throws Exception
      Convert an XML String to widget model
      Parameters:
      xmlString -
      Returns:
      the widget model
      Throws:
      Exception
    • XMLElementToWidget

      public static AbstractWidgetModel XMLElementToWidget(org.jdom2.Element element) throws Exception
      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 - . The DisplayModel to 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 - . The DisplayModel to 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

      public static void fillLinkingContainers(AbstractContainerModel container) throws Exception
      Fill all LinkingContainers under the model.
      Parameters:
      container - LinkingContainer to be filled.
      Throws:
      Exception
    • fillLinkingContainer

      public static void fillLinkingContainer(AbstractLinkingContainerModel container) throws Exception
      Load opi file attached to LinkingContainer widget.
      Parameters:
      container - LinkingContainer to be filled.
      Throws:
      Exception
    • findClosestWidgetUid

      public static String findClosestWidgetUid(InputStream in, int offset) throws IOException
      Return the wuid of the closest widget to offset char position in input stream
      Parameters:
      in - the OPI file input stream
      offset - the character offset
      Returns:
      String wuid
      Throws:
      IOException