KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > modules > translations > Language


1 /*
2  * Created on Dec 6, 2005
3  */

4 package com.openedit.modules.translations;
5
6 import java.util.Date JavaDoc;
7
8 import com.openedit.OpenEditException;
9 import com.openedit.page.Page;
10 import com.openedit.page.manage.PageManager;
11
12
13 public class Language
14 {
15     protected String JavaDoc fieldName; //friendly text
16
protected String JavaDoc fieldId; //locale
17
protected String JavaDoc fieldRootDirectory;
18     
19     protected PageManager fieldPageManager;
20     
21     public String JavaDoc getId()
22     {
23         return fieldId;
24     }
25     public void setId(String JavaDoc inId)
26     {
27         fieldId = inId;
28     }
29     public String JavaDoc getName()
30     {
31         return fieldName;
32     }
33     public void setName(String JavaDoc inName)
34     {
35         fieldName = inName;
36     }
37     public boolean isCurrent(String JavaDoc inPath) throws OpenEditException
38     {
39         Page trans = getPage(inPath);
40         Date JavaDoc here = trans.getLastModified();
41         if ( here.getTime() == 0)
42         {
43             return false;
44         }
45         Page rootLevel = getPageManager().getPage(inPath);
46         if ( rootLevel.getContentItem().getPath().equals(trans.getContentItem().getPath()))
47         {
48             return false; //this is the fallback directory
49
}
50         
51         Date JavaDoc current = rootLevel.getLastModified();
52         boolean ok = current.before(here) || current.equals(here); //if the root page is older than the now we are ok
53
return ok;
54     }
55     public Page getPage(String JavaDoc inPath) throws OpenEditException
56     {
57         return getPageManager().getPage(getRootDirectory() + inPath);
58     }
59     public PageManager getPageManager()
60     {
61         return fieldPageManager;
62     }
63     public void setPageManager(PageManager inPageManager)
64     {
65         fieldPageManager = inPageManager;
66     }
67     public String JavaDoc getRootDirectory()
68     {
69         return fieldRootDirectory;
70     }
71     public void setRootDirectory(String JavaDoc inRootDirectory)
72     {
73         fieldRootDirectory = inRootDirectory;
74     }
75     public String JavaDoc toString()
76     {
77         return getId() + " " + getName();
78     }
79 }
80
Popular Tags