KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > store > excelconvert > Header


1 /*
2  * Created on Aug 15, 2005
3  */

4 package com.openedit.store.excelconvert;
5
6 import java.util.HashMap JavaDoc;
7 import java.util.Iterator JavaDoc;
8 import java.util.Map JavaDoc;
9
10 public class Header
11 {
12     protected Map JavaDoc fieldHeaderNames;
13
14     public Map JavaDoc getHeaderNames()
15     {
16         if (fieldHeaderNames == null)
17         {
18             fieldHeaderNames = new HashMap JavaDoc();
19         }
20         return fieldHeaderNames;
21     }
22     public void setHeaders(String JavaDoc[] inHeaders)
23     {
24         for (int i = 0; i < inHeaders.length; i++)
25         {
26             Integer JavaDoc integer = new Integer JavaDoc(i);
27             getHeaderNames().put(integer,inHeaders[i]);
28         }
29     }
30
31     public int getIndex(String JavaDoc inName)
32     {
33         Map JavaDoc headerNames = getHeaderNames();
34         for (Iterator JavaDoc iter = headerNames.keySet().iterator(); iter.hasNext();)
35         {
36             Integer JavaDoc index = (Integer JavaDoc)iter.next();
37             String JavaDoc name = (String JavaDoc) headerNames.get(index);
38             if ( name.equals(inName))
39             {
40                 return index.intValue();
41             }
42         }
43         return -1;
44     }
45     public String JavaDoc getColumn(int inIndex)
46     {
47         String JavaDoc name = (String JavaDoc)getHeaderNames().get(new Integer JavaDoc(inIndex));
48         if ( name != null)
49         {
50             return name;
51         }
52         return null;
53     }
54     public int getSize()
55     {
56         return getHeaderNames().size();
57     }
58     public void addCol(int inCol, String JavaDoc inStringCellValue)
59     {
60         Integer JavaDoc integer = new Integer JavaDoc(inCol);
61         getHeaderNames().put(integer,inStringCellValue);
62         
63     }
64
65 }
66
Popular Tags