added and tested simple document handling and update with test.ArchiveWriter.
[vamsas.git] / src / org / vamsas / objects / utils / AppDataReference.java
1 /**
2  * 
3  */
4 package org.vamsas.objects.utils;
5 import java.util.Vector;
6
7 import org.vamsas.objects.core.*;
8 /**
9  * Form, accessors and validation for ApplicationData references in
10  * vamsas document.
11  * TODO: LATER:extend XML Schema to properly validate against the same forms required by this class
12  * TODO: implement methods for searching appData structure for particular combinations of client and user data
13  * TODO: VAMSAS: URNS for appDatas are supposed to be unique, aren't they ?
14  */
15 public class AppDataReference {
16   static public Vector getAppDataReferences(VamsasDocument doc) {
17     if ((doc!=null) && (doc.getApplicationDataCount()>0)) {
18       Vector apdrefs = new Vector();
19       ApplicationData[] appdatas = doc.getApplicationData();
20       for (int q=0; q<appdatas.length; q++) {
21         String refstring=appdatas[q].getDataReference();
22         if (refstring!=null) 
23           apdrefs.add(refstring);
24         User users[] = appdatas[q].getUser();
25         
26         if (users!=null)
27           for (int u=0; u<users.length; u++)
28             refstring=users[u].getDataReference();
29             if (refstring!=null)
30               apdrefs.add(new String(refstring)); // avoid referencing.
31       }
32       if (apdrefs.size()>0)
33         return apdrefs;
34     }
35     return null;
36   }
37 }