/* File: StreamDescriptor.java * Copyright (C) 2002-2003 The University of Iowa * Created by: Jeremy Faden * Jessica Swanner * Edward E. West * * This file is part of the das2 library. * * das2 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.das2.stream; import org.das2.DasIOException; import org.das2.datum.DatumVector; import org.das2.util.IDLParser; import java.io.*; import org.xml.sax.InputSource; import org.xml.sax.SAXException; //import org.apache.xml.serialize.OutputFormat; //import org.apache.xml.serialize.XMLSerializer; import org.w3c.dom.*; import java.nio.ByteBuffer; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSOutput; import org.w3c.dom.ls.LSSerializer; import org.xml.sax.SAXParseException; /** Represents the global properties of the stream, that are accessible to * datasets within. * @author jbf */ public class StreamDescriptor implements SkeletonDescriptor, Cloneable { private Map properties = new HashMap(); private StreamXDescriptor xDescriptor; private ArrayList yDescriptors = new ArrayList(); private String compression; /** Creates a new instance of StreamProperties */ public StreamDescriptor(Element element) throws StreamException { if (element.getTagName().equals("stream")) { processElement(element); } else { processLegacyElement(element); } } private void processElement(Element element) throws StreamException { compression = element.getAttribute("compression"); NodeList list = element.getElementsByTagName("properties"); if (list.getLength() != 0) { Element propertiesElement = (Element)list.item(0); Map m = StreamTool.processPropertiesElement(propertiesElement); properties.putAll(m); } } private void processLegacyElement(Element element) throws StreamException { NodeList children= element.getChildNodes(); for (int i=0; i= capacity) { return array; } else { String[] temp = new String[capacity]; System.arraycopy(array, 0, temp, 0, array.length); return temp; } } /** Getter for property compression. * @return Value of property compression. * */ public String getCompression() { return compression; } /** Setter for property compression. * @param compression New value of property compression. * */ public void setCompression(String compression) { this.compression = compression; } public Element getDOMElement(Document document) { Element element = document.createElement("stream"); if (compression != null && !compression.equals("")) { element.setAttribute("compression", compression); } if (!properties.isEmpty()) { Element propertiesElement = StreamTool.processPropertiesMap( document, properties ); element.appendChild(propertiesElement); } return element; } public Object clone() { try { StreamDescriptor clone = (StreamDescriptor)super.clone(); clone.properties = new HashMap(this.properties); return clone; } catch (CloneNotSupportedException cnse) { throw new RuntimeException(cnse); } } @Override public String toString() { return "StreamDescriptor " + this.properties.size() + " properties"; } }