KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > sps > common > RecordMetadata


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package sync4j.syncclient.sps.common;
20
21 import java.util.Vector JavaDoc;
22
23 /**
24  * This class create RecordMetadata
25  *
26  * @author Fabio Maggi @ Funambol
27  * $Id: RecordMetadata.java,v 1.3 2005/01/19 11:18:36 fabius Exp $
28  */

29 public class RecordMetadata {
30
31     //-------------------------------------------------------------- Private data
32

33     private FieldMetadata[] fieldMetadata;
34
35     //------------------------------------------------------------- Constructors
36

37     public RecordMetadata(FieldMetadata[] fieldMetadata) {
38         this.fieldMetadata = fieldMetadata;
39     }
40
41     //----------------------------------------------------------- Public methods
42

43     /**
44      * @return fieldMetadata
45      **/

46     public FieldMetadata[] getFieldMetadata() {
47         return this.fieldMetadata;
48     }
49
50     /**
51      * @param searchFunction
52      * @return record position about field with set searchFunction
53      **/

54     public Vector JavaDoc getRecordFieldPosition(String JavaDoc searchFunction) {
55
56
57         String JavaDoc function = null;
58         Vector JavaDoc positions = null;
59
60
61         positions = new Vector JavaDoc();
62
63         for (int i=0; i < this.getFieldMetadata().length; i++) {
64
65             function = (String JavaDoc) this.getFieldMetadata()[i].getAttributes().get("function");
66
67             if (function.equals(searchFunction)) {
68                 positions.addElement(new Integer JavaDoc(i + 1));
69             }
70
71         }
72
73         return positions;
74
75     }
76
77 }
Popular Tags