/** * * 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.4 $ * */ package org.biomage.tools.generate_classes; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.TreeSet; import java.util.Set; import java.util.Vector; import org.biomage.tools.helpers.StringOutputHelpers; import org.w3c.dom.*; /** * Description: * Class that is resposible for generating a java file * for the class represented by the class node passed * into the constructor. * */ public class CreateMAGEFile extends CreateFile { private String id = null; /** * Description: * Constructor for the MAGE file generator. * * @param createPackageFileList: node representing the package lists class * to live in the MAGE class. */ protected CreateMAGEFile( Vector createPackageFileList, Element packageList ) throws Exception { super(); // Get the base information for the node headerInformation(); // add the associations associationInfo = associationAttrInformation(createPackageFileList, packageList); } /** * Description: * Obtains the information to generate the information for * the package and the declaration of the class. */ protected void headerInformation() throws Exception { try { // Obtain the class information className = "MAGEJava"; isAbstract = false; visibility = "public"; classDoc = "Top-level object that represents the model. Contains the packages."; // Progress indicator. StringOutputHelpers.writeOutput("\t" + className, 3); } catch ( Exception e ) { // for setting a break point for debugging purposes throw e; } } /** * Description: * Puts together the information on the class associations. * *
* @param createPackageFileList: the package classes to get the association * information. *
* *
* @return Vector of ClassAttrInformations *
* */ protected Vector associationAttrInformation( Vector createPackageFileList, Element packageOrder ) throws Exception { // Get the documentation for the MAGE-OM component and parse it for // the order information of the packages NodeList order = packageOrder.getElementsByTagName("package"); Vector associationInfo = new Vector(40); Map name2index = new HashMap(); for (int i = 0; i < order.getLength();i++) { associationInfo.add(null); name2index.put(((Element) order.item(i)).getAttribute("name") + "_package", new Integer(i)); } for (int i = 0; i < createPackageFileList.size();i++) { CreatePackageFile classFile = (CreatePackageFile) createPackageFileList.get(i); String name = classFile.getClassName(); IdentifierAttrInformation packageList = new IdentifierAttrInformation(classFile, false); packageImports.add(classFile.packageName + "." + name); associationInfo.set(((Integer) name2index.get(name)).intValue(), packageList); } return associationInfo; } /** * Description: * Returns what kind of model element this class is based on. * * @return returns that this represents the model itself */ public int getFileType() { return UML_MODEL; } }