se.lth.immun.mzml.FileContent.scala Maven / Gradle / Ivy
package se.lth.immun.mzml
import se.lth.immun.xml.XmlReader
import se.lth.immun.xml.XmlWriter
import scala.collection.mutable.ArrayBuffer
object FileContent {
import MzML._
def fromFile(r:XmlReader) = {
var x = new FileContent
var e = r.top
r.next
while (r.in(e))
r.top.name match {
case CV_PARAM =>
x.cvParams += CvParam.fromFile(r)
case USER_PARAM =>
x.userParams += UserParam.fromFile(r)
case REFERENCEABLE_PARAM_GROUP_REF => {
x.paramGroupRefs += r.readAttribute(REF)
r.next
}
case _ => r.skipThis
}
x
}
}
class FileContent {
var cvParams = new ArrayBuffer[CvParam]
var userParams = new ArrayBuffer[UserParam]
var paramGroupRefs = new ArrayBuffer[String]
def write(w:XmlWriter) = {
import MzML._
w.startElement(FILE_CONTENT)
for (x <- paramGroupRefs) ReferenceableParamGroupRef.write(w, x)
for (x <- cvParams) x.write(w)
for (x <- userParams) x.write(w)
w.endElement
}
}