/** * * C O P Y R I G H T N O T I C E * Copyright (c) 2001 by: * * The MicroArray Gene Expression Database group (MGED) * * Rosetta Inpharmatics * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation files * (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * * @author $Author: rhubley $ * @version $Revision: 1.6 $ * */ package org.biomage.tools.generate_dtd; import java.io.FileWriter; import java.util.Map; import java.util.TreeMap; import java.util.Vector; import org.biomage.tools.generate_classes.CreateFile; import org.biomage.tools.generate_classes.CreateMAGEFile; import org.biomage.tools.generate_classes.XMIParseHelpers; import org.biomage.tools.helpers.StringOutputHelpers; import org.w3c.dom.*; /** * Description: * Class that is resposible for generating a DTD file * for the classes represented by the list of class nodes * passed into the constructor. * */ public class WriteDTDMageElement extends WriteDTDElement { /** * Description: * For outputting the MAGE-OM element to the file. */ StringBuffer mageML = null; /** * Description: * Map that specifies the order of the packages. Population of the map * comes from a the parameter packageOrdering resource. */ Map packageOrder = new TreeMap(); /** * Description: * Method to read the XML configuration for the ordering of the packages. * *

* @param packageOrdering: the XML configuration element. *

*/ protected void setPackageOrder( Element packageOrdering ) throws Exception { NodeList elements = packageOrdering.getElementsByTagName("package"); for (int i = 0; i < elements.getLength(); i++) { packageOrder.put(((Element) elements.item(i)).getAttribute("name") + "_package", new Integer(i)); } } /** * Description: * Constructor for the DTD file generator. * *

* @param createFile: the class to write to the DTD. *

*/ protected WriteDTDMageElement( CreateFile createFile ) throws Exception { super(createFile); } /** * Description: * Creates the element declaration for the top-level model. *

* @param packageOrdering: the XML configuration element for package ordering information. *

*/ protected void createXMLStrings() throws Exception { // get the packages in a dependable order Vector ordered = createFile.getAssociationInfo(); // Now create the element for the MAGE object mageML = new StringBuffer("" + StringOutputHelpers.NEWLINE); // and now the ATTLIST mageML.append("" + StringOutputHelpers.NEWLINE + StringOutputHelpers.NEWLINE); } /** * Description: * Method to write out the body. * *

* @param write: the writer to use. *

*/ protected void writeBody( FileWriter writer ) throws Exception { String comment = "MAGE-ML" + StringOutputHelpers.NEWLINE + StringOutputHelpers.NEWLINE + "The top-level element that contains the packages. Each of the package " + "elements contain the lists of independent elements in that package."; StringOutputHelpers.writeDTDComment(writer, comment, null, true, true); writer.write(mageML.toString()); } }