flag for suppressing unresolved xmlId warnings
[vamsas.git] / src / uk / ac / vamsas / client / VorbaIdFactory.java
1 /*
2  * This file is part of the Vamsas Client version 0.1. 
3  * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, 
4  *  Andrew Waterhouse and Dominik Lindner.
5  * 
6  * Earlier versions have also been incorporated into Jalview version 2.4 
7  * since 2008, and TOPALi version 2 since 2007.
8  * 
9  * The Vamsas Client is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *  
14  * The Vamsas Client is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License for more details.
18  * 
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with the Vamsas Client.  If not, see <http://www.gnu.org/licenses/>.
21  */
22 package uk.ac.vamsas.client;
23
24 import java.util.Hashtable;
25 import java.util.Vector;
26
27 /**
28  * A VorbaIdFactory is constructed by an IClient instance. It guarantees that
29  * any new VorbaId objects are unique within the VAMSAS session.
30  * 
31  * @author jimp
32  */
33 public abstract class VorbaIdFactory implements IVorbaIdFactory {
34   /**
35    * hash of VorbaIds to Vobject.
36    */
37   protected Hashtable extantids = null;
38
39   /**
40    * hash of VorbaIds to persisted hash values
41    */
42   protected Hashtable extanthashv = null;
43
44   /**
45    * list of Vobjects added since last Document read.
46    */
47   protected Vector newobj = null;
48
49   /**
50    * flag indicating if unresolved references should be raised during UnMarshalling
51    */
52   protected boolean warnUnresolved;
53
54   /**
55    * construct a new id appropriate for this client in the vamsas session.
56    * 
57    * @return valid VorbaId for session, or null if VorbaIdFactory not configured
58    *         correctly.
59    */
60   public abstract VorbaId makeVorbaId(Vobject vobject);
61
62   /**
63    * internal method to access the protected VorbaId object constructor This
64    * shennanigan is to prevent casual generation of VorbaIds (which may destroy
65    * the integrity of a Vamsas Document!)
66    * 
67    * @param id
68    * @return new VorbaId object
69    */
70   protected VorbaId newId(String id) {
71     return VorbaId.newId(id);
72   }
73
74   /**
75    * Called by VorbaXmlBinder so the record of newly unmarshalled Vobject Ids is
76    * accessible to the Document's VorbaIdFactory instance.
77    * 
78    * @param idtable
79    */
80   protected void setNewIdHash(Hashtable idtable) {
81     extantids = idtable;
82   }
83
84   /*
85    * (non-Javadoc)
86    * 
87    * @see
88    * uk.ac.vamsas.client.IVorbaIdFactory#updateHashValue(uk.ac.vamsas.client
89    * .Vobject)
90    */
91   public void updateHashValue(Vobject vobject) {
92     if (vobject.isRegisterable())
93       extanthashv.put(vobject.getVorbaId(), new Vobjhash(vobject));
94   }
95
96   /**
97    * TODO: decide if these are needed.
98    * 
99    * @param sessionHandle
100    */
101   protected abstract void setSession(SessionHandle sessionhandle);
102
103   public abstract SessionHandle getSessionHandle();
104
105   protected abstract void setClient(ClientHandle appHandle);
106
107   public abstract ClientHandle getClientHandle();
108
109   protected abstract void setUser(UserHandle userHandle);
110
111   public abstract UserHandle getUserHandle();
112 }