View Javadoc

1   package org.opensync.tools;
2   
3   import java.io.FileNotFoundException;
4   import java.io.IOException;
5   import java.util.Hashtable;
6   import java.util.Vector;
7   
8   import org.xml.sax.SAXException;
9   
10  public class Theme {
11    protected String menuActionView,keyWord,idParentFile,label, idRightField, className ;
12    protected Parent parentFile;
13    protected Vector primaryKeys, primaryKeyElements ;
14    private Element elements[];
15    protected Hashtable childsTheme;
16  
17    // Perhaps, hasPlanning must be in SophiewebTheme
18    // and a Hashtable may be declared in SophiewebTheme
19    // to list all active features: associates a feature name with a boolean.
20    protected boolean hasPlanning=false;
21    protected Hashtable associations;
22  
23    /***
24     * Constructor
25     */
26  
27    public Theme () {}
28  
29    public Theme(String c, String i, String cl, String r,Parent p,String m) {
30      keyWord = c;
31      idParentFile = i;
32      idRightField = r;
33      className = cl;
34      parentFile = p;
35      menuActionView=m;
36  
37      if (menuActionView == null || menuActionView.equals("")){
38        menuActionView = "list";
39      }
40  
41      primaryKeys = new Vector();
42      primaryKeyElements = new Vector();
43      childsTheme = new Hashtable();
44      associations = new Hashtable();
45    }
46  
47    public void initLabels(String lang) throws IOException,FileNotFoundException,SAXException {
48      label = DicoReader.getLabelDicoByKey(lang,keyWord);
49      for (int i=0;i<elements.length;i++)
50        elements[i].initLabels(lang);
51    }
52  
53    // Methode set
54    public void setChildsTheme (String t, ElementLink elementsLink[]){
55      if( elementsLink!=null && elementsLink.length>0) childsTheme.put(t,elementsLink);
56    }
57  
58    public void setAssociations (String t, ElementAssociation elementAssociation){
59  
60          if (Utils.debug)
61            System.out.println("\nsetAssociations: "+ t + " "+elementAssociation.toString());
62          associations.put(t, elementAssociation);
63    }
64  
65    public void setThemeElements(Vector f) {
66      elements = new Element[f.size()];
67      f.toArray(elements);
68      f.clear();
69      }
70    public void setPrimaryKeys(Vector f) {
71      primaryKeys = (Vector)f.clone();
72      f.clear();
73      }
74    public void setPrimaryKeyElements(Vector f) {
75      primaryKeyElements = (Vector)f.clone();
76      f.clear();
77      }
78    public void setKeyWord(String s) {
79      keyWord = s;
80      }
81    public void setIdParentFile(String s) {
82      idParentFile = s;
83      }
84    public void setLabel(String s) {
85      label = s;
86      }
87    public void setIdRightField(String s) {
88      idRightField = s;
89      }
90    public void setParentFile(Parent s) {
91      parentFile = s;
92      }
93    public void setClassName(String s) {
94      className = s;
95      }
96     public void setHasPlanning(boolean b) {
97      hasPlanning = b;
98      }   
99     // Methode get
100   public boolean getHasPlanning() {
101     return(hasPlanning);
102     }  		
103   public String getKeyWord() {
104     return(keyWord);
105     }
106   public String getMenuActionView() {
107     return(menuActionView);
108     }
109   public String getIdParentFile() {
110     return(idParentFile);
111     }
112   public String getLabel() {
113     return(label);
114     }
115   public String getIdRightField() {
116     return(idRightField);
117     }
118   public String getClassName() {
119     return(className);
120     }
121   public Parent getParentFile() {
122     return(parentFile);
123     }
124   // Methode get from Element
125   public Element getThemeElementByKey(String k) {
126     for (int i=0;i<elements.length;i++)
127       if (elements[i].equalsByKeyWord(k)) return elements[i];
128     return null;
129     }
130   public Element getThemeElementByField(String k) {
131     for (int i=0;i<elements.length;i++)
132       if (elements[i].equalsByField(k)) return elements[i];
133     return null;
134     }
135   public Element[] getThemeElements() {
136     return elements;
137     }
138   public Vector getPrimaryKeys() {
139     return primaryKeys;
140   }
141   public Vector getPrimaryKeyElements() {
142     return primaryKeyElements;
143   }
144   public Hashtable getChildsTheme() {
145     return childsTheme;
146   }
147   public Hashtable getAssociations() {
148     return associations;
149   }
150   /*public ElementLink[] getLinkChildTheme(String t) {
151     if (childsTheme!=null && childsTheme.containsKey(t)) return (ElementLink[])childsTheme.get(t);
152     else return null;
153     }
154   */
155 }
156