// $Id: StructureComponentRegistry.java,v 1.1 2006/05/20 17:02:06 Sasha Buzko Exp $ // // Copyright (c) 2000-2002 San Diego Supercomputer Center (SDSC), // a facility operated jointly by the University of California, // San Diego (UCSD) and General Atomics, San Diego, California, USA. // // Users and possessors of this source code are hereby granted a // nonexclusive, royalty-free copyright and design patent license to // use this code in individual software. License is not granted for // commercial resale, in whole or in part, without prior written // permission from SDSC. This source is provided "AS IS" without express // or implied warranty of any kind. // // For further information, please see: http://mbt.sdsc.edu // // History: // $Log: StructureComponentRegistry.java,v $ // Revision 1.1 2006/05/20 17:02:06 Sasha Buzko // Updated version // // Revision 1.1 2006/04/30 20:14:05 Sasha Buzko // New version of the app // // Revision 1.1 2006/04/15 19:42:27 Sasha Buzko // Initial commit // // Revision 1.1 2005/11/13 04:35:26 Administrator // *** empty log message *** // // Revision 1.5 2003/07/21 20:48:48 moreland // Added Fragment StructureComponent object. // // Revision 1.4 2003/04/03 22:37:09 moreland // Added Chain and Bond classes. // // Revision 1.3 2003/01/13 23:41:24 moreland // Commented out debug/print statements. // // Revision 1.2 2002/12/16 06:25:53 moreland // Changed code to support differentiation of Conformation into Coil, Helix, // Strand, and Turn sub-class types (at Eliot Clingman's suggestion). // // Revision 1.1 2002/10/24 17:54:01 moreland // Provides implementation for the improved Structure API/implementation. // // Revision 1.1.1.1 2002/07/16 18:00:15 moreland // Imported sources // // Revision 1.0 2002/06/10 23:38:39 moreland // package edu.sdsc.mbt; import java.util.Enumeration; import java.util.Hashtable; /** * A class used to register StructureComponent types and * their relationships (much like a database schema defines tables and * their relational links). *
* Each StructureComponent is like a table in a database. * Each StructureComponent type is like a table ID in a database. * Each StructureComponent relation is like a relational link * between tables in a database. *
* A set of public static final String variables whos names begin * with "TYPE_" are defined to enable users (eg: StructureLoader, Structure, * etc) to perform very fast StructureComponent runtime type comparisions by * simply comparing object references (ie: not the actual String values). *
* Since each StructureComponent type value is simply the fully qualified * String name of the class, the type values may also be used *
* @author John L. Moreland */ public class StructureComponentRegistry implements java.io.Serializable { // The StructureComponent types. private static Hashtable types = new Hashtable(); // The StructureComponent relations. private static Hashtable relations = new Hashtable(); // // TYPE_ field values // /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_STRUCTURE = null; /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_CHAIN; /** * Secondary structure conformation for a Coil. * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_COIL; /** * Secondary structure conformation for a Helix. * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_HELIX; /** * Secondary structure conformation for a Strand. * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_STRAND; /** * Secondary structure conformation for a Turn. * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_TURN; /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_RESIDUE; /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_FRAGMENT; /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_ATOM; /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_BOND; /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_MODEL = null; /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_ACTIVE_SITE = null; /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_POLYMER = null; /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_NONPOLYMER = null; /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_DISULPHIDE = null; /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached type. */ public static final String TYPE_SALT_BRIDGE = null; // // RELATION_ field values // /** * This is a static convenience field provided so that user code does * not have to create a local variable name to store a cached relation. */ public static final String RELATION_CONFORMATION_ATOMS; // Since this is a static class, do initialization in a static block: static { // // Add the well-known StructureComponent types. // // addType( TYPE_STRUCTURE = Structure.getClassName() ); addType( TYPE_ATOM = Atom.getClassName() ); addType( TYPE_BOND = Bond.getClassName() ); addType( TYPE_RESIDUE = Residue.getClassName() ); addType( TYPE_FRAGMENT = Fragment.getClassName() ); addType( TYPE_CHAIN = Chain.getClassName() ); addType( TYPE_COIL = Coil.getClassName() ); addType( TYPE_HELIX = Helix.getClassName() ); addType( TYPE_STRAND = Strand.getClassName() ); addType( TYPE_TURN = Turn.getClassName() ); // Add other StructureComponent types as they're implemented... // addType( TYPE_MODEL = Model.getClassName() ); // addType( TYPE_SALT_BRIDGE = SaltBridge.getClassName() ); // addType( TYPE_DISULPHIDE = Disulphide.getClassName() ); // addType( TYPE_NON_POLYMER = NonPolymer.getClassName() ); // addType( TYPE_POLYMER = Polymer.getClassName() ); // addType( TYPE_ACTIVE_SITE = ActiveSite.getClassName() ); // // Add the well-known StructureComponent relations. // StructureComponentRelation relation; addRelation( relation = new Relation_Conformation_Atom() ); RELATION_CONFORMATION_ATOMS = relation.getName(); // Add other StructureComponent relations as they're implemented... } // // Type registration methods // /** * Return the number of registered StructureComponent types. */ public static int getTypeCount() { return types.size(); } /** * Register a new StructureComponent type. */ public static void addType( String name ) { // System.err.println( "StructureComponentRegistry.addType: name = " + name ); types.put( name, name ); } /** * Un-register an existing StructureComponent type. */ public static void removeType( String name ) { types.remove( name ); } /** * Get an existing StructureComponent type name for the given String. * Note that while the "name" parameter may contain the same characters, * the returned String object is the actual registered String instance. * This enables fast "==" comparisons throughout the toolkit. * This method is also handy to check whether a type is registered, * since a "null" value is returned if it is not registered. */ public static String getTypeName( String name ) { return (String) types.get( name ); } /** * Return an Enumeration of String values for all registered * StructureComponent types. */ public static Enumeration getTypeNames( ) { return types.keys( ); } // // Relation registration methods // /** * Return the number of registered StructureComponent relations. */ public static int getRelationCount() { return relations.size(); } /** * Register a new StructureComponent relation. */ public static void addRelation( StructureComponentRelation relation ) { relations.put( relation.getName(), relation ); } /** * Get an existing StructureComponent relation. */ public static StructureComponentRelation getRelation( String name ) { return (StructureComponentRelation) relations.get( name ); } /** * Un-register an existing StructureComponent relation. */ public static void removeRelation( String name ) { relations.remove( name ); } /** * Return an Enumeration of String values for all registered * StructureComponent relations. */ public static Enumeration getRelationNames( ) { return relations.keys( ); } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { out.defaultWriteObject(); } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { in.defaultReadObject(); } }