001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021 022 023package org.biojava.bio.symbol; 024 025import org.biojava.bio.Annotatable; 026import org.biojava.bio.Annotation; 027import org.biojava.utils.AbstractChangeable; 028import org.biojava.utils.ChangeForwarder; 029import org.biojava.utils.ChangeSupport; 030import org.biojava.utils.ChangeType; 031 032/** 033 * The base-class for Symbol implementations. 034 * 035 * @author Matthew Pocock 036 * @since 1.1 037 */ 038public abstract class AbstractSymbol 039 extends 040 AbstractChangeable 041 implements 042 Symbol 043{ 044 protected transient ChangeForwarder annotationForwarder = null; 045 046 protected ChangeSupport getChangeSupport(ChangeType changeType) { 047 ChangeSupport changeSupport = super.getChangeSupport(changeType); 048 049 if( 050 (Annotatable.ANNOTATION.isMatchingType(changeType)) && 051 (annotationForwarder == null) 052 ) { 053 annotationForwarder = 054 new ChangeForwarder.Retyper(this, changeSupport, Annotatable.ANNOTATION); 055 getAnnotation().addChangeListener(annotationForwarder, Annotation.PROPERTY); 056 } 057 058 return changeSupport; 059 } 060 061 public String toString() { 062 return getClass().getName() + ": " + getName(); 063 } 064}