// ĠCopyright Ġ 2 0 1 9 ĠAmazon . com , ĠInc . Ġor Ġits Ġaffiliates . ĠAll ĠRights ĠReserved . Ċ // ĠSPDX - License - Identifier : ĠApache - 2 . 0 Ċ Ċ package Ġsoftware . aws . tool k its . jetbrains . utils Ċ Ċ import Ġcom . intellij . configuration Store . deserialize And Load State Ċ import Ġcom . intellij . configuration Store . serialize State Into Ċ import Ġcom . intellij . openapi . components . Persistent State Component Ċ import Ġorg . intellij . lang . annotations . Language Ċ import Ġorg . j dom . Element Ċ import Ġorg . j dom . input . SAX Builder Ċ import Ġorg . j dom . output . XM LO ut put ter Ċ import Ġjava . io . ByteArray InputStream Ċ Ċ fun Ġxml Element (@ Language (" XML ") Ġstr : ĠString ): ĠElement Ġ{ ĊĠĠĠ Ġval Ġstream Ġ= ĠByteArrayInputStream ( str . toByteArray ()) ĊĠĠĠ Ġval Ġbuilder Ġ= ĠSAX Builder () ĊĠĠĠ Ġreturn Ġbuilder . build ( stream ). root Element Ċ } Ċ Ċ fun Ġserialize State ( root Tag : ĠString , Ġstate : ĠPersistent State Component < *> ): ĠString Ġ{ ĊĠĠĠ Ġval Ġelement Ġ= ĠElement ( root Tag ) ĊĠĠĠ Ġserialize State Into ( state , Ġelement ) ĊĠĠĠ Ġreturn ĠX M LO ut put ter (). output String ( element ) Ċ } Ċ Ċ fun Ġdeserialize State (@ Language (" XML ") Ġstr : ĠString , Ġstate : ĠPersistent State Component <* >) Ġ{ ĊĠĠĠ Ġdeserialize And Load State ( state , Ġxml Element ( str )) Ċ } Ċ