/** * * 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.7 $ * */ 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.CreatePackageFile; 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 WriteDTDPackageElement extends WriteDTDElement { /** * Description: * For outputting the MAGE-OM element to the file. */ protected StringBuffer packageElement = null; /** * Description: * Constructor for the DTD file generator. * *

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

*/ protected WriteDTDPackageElement( CreateFile createFile ) throws Exception { super(createFile); } /** * Description: * Creates the element declaration for the package. * *

* @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(); if (null != ordered && 0 < ordered.size()) { // Now create the element for the package object packageElement = new StringBuffer("" + StringOutputHelpers.NEWLINE + StringOutputHelpers.NEWLINE); } else { // Create an empty content list packageElement = new StringBuffer("" + StringOutputHelpers.NEWLINE + StringOutputHelpers.NEWLINE); } } /** * Description: * Method to write out entities. Packages write out * a brief comment. * *

* @param write: the writer to use. *

*/ protected void writeEntities( FileWriter writer ) throws Exception { String comment = createFile.getClassFileName() + StringOutputHelpers.NEWLINE + StringOutputHelpers.NEWLINE + "Entities for classes in this package."; StringOutputHelpers.writeDTDComment(writer, comment, null, true, true); } /** * Description: * Method to write out the body. * *

* @param write: the writer to use. *

*/ protected void writeBody( FileWriter writer ) throws Exception { if (null != packageElement) { String comment = createFile.getClassFileName() + StringOutputHelpers.NEWLINE + StringOutputHelpers.NEWLINE + createFile.getClassDoc(); StringOutputHelpers.writeDTDComment(writer, comment, null, true, true); writer.write(packageElement.toString()); } } }