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 */ 021package org.biojava.bio.seq.io.agave; 022import java.util.ArrayList; 023import java.util.Iterator; 024import java.util.List; 025 026/** 027 * xref 028 * @author Hanning Ni Doubletwist Inc 029 * @author Greg Cox 030*/ 031public class AGAVEXref { 032 private AGAVEDbId id ; 033 private List xrefs ; 034 private String rel ; 035 public void setDbId( AGAVEDbId id ) 036 { 037 this.id = id ; 038 } 039 public void addProp(AGAVEProperty prop) 040 { 041 if( xrefs == null ) 042 xrefs = new ArrayList(1) ; 043 xrefs.add( prop ); 044 } 045 public void setRel(String rel) 046 { 047 this.rel = rel ; 048 } 049 public String getRel() 050 { 051 return rel ; 052 } 053 public AGAVEDbId getDbId() 054 { 055 return id ; 056 } 057 public Iterator getXrefProps() 058 { 059 return xrefs.iterator() ; 060 } 061 062 /** return the agave xml representation of this instance **/ 063 public String toString(String indent, String indent_unit) 064 { 065 StringBuffer tmp = new StringBuffer(); 066 tmp.append(indent + "<xref"); 067 if( rel != rel ) 068 tmp.append(" relationship=\"" + rel + "\"") ; 069 tmp.append( ">" + "\n") ; 070 tmp.append( id.toString(indent + indent_unit, indent_unit) ) ; 071 Iterator it = xrefs.iterator() ; 072 while( it.hasNext() ) 073 { 074 tmp.append( ((AGAVEProperty)it.next()).toString(indent + indent_unit, indent_unit) ) ; 075 } 076 tmp.append(indent + "</xref>" + "\n" ); 077 return tmp.substring(0) ; 078 } 079 /** return the agave xml representation of this instance **/ 080 public String toString() 081 { 082 StringBuffer tmp = new StringBuffer(); 083 tmp.append( "<xref"); 084 if( rel != rel ) 085 tmp.append(" relationship=\"" + rel + "\"") ; 086 tmp.append( ">" + "\n") ; 087 tmp.append( id ) ; 088 Iterator it = xrefs.iterator() ; 089 while( it.hasNext() ) 090 { 091 tmp.append( it.next().toString() ) ; 092 } 093 tmp.append("</xref>" + "\n" ); 094 return tmp.toString() ; 095 } 096}