[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/basic s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Mon Jan 24 17:02:34 MST 2005
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic
In directory www.crosswire.org:/tmp/cvs-serv22965/java/jsword/org/crosswire/jsword/book/basic
Modified Files:
DefaultBookMetaData.java AbstractBookMetaData.java
Added Files:
iso639.properties
Log Message:
Added language to the book installer tree.
--- NEW FILE: iso639.properties ---
# The following are iso639-2 and iso639-3 codes and their languages.
# These are derived from authoritative tables, but there were differences.
# I have also include some old codes (e.g. iw for hebrew)
# I have tried to account for the differences, but there may be mistakes.
ab=Abkhazian
abk=Abkhazian
ace=Achinese
ach=Acoli
ada=Adangme
aa=Afar
aar=Afar
afh=Afrihili
af=Afrikaans
afr=Afrikaans
afa=Afro-Asiatic (Other)
aka=Akan
akk=Akkadian
alb=Albanian
sq=Albanian
sqi=Albanian
ale=Aleut
alg=Algonquian languages
tut=Altaic (Other)
am=Amharic
amh=Amharic
apa=Apache languages
ar=Arabic
ara=Arabic
arc=Aramaic
arp=Arapaho
arn=Araucanian
arw=Arawak
arm=Armenian
hy=Armenian
hye=Armenian
art=Artificial (Other)
as=Assamese
asm=Assamese
ath=Athapascan languages
map=Austronesian (Other)
ava=Avaric
ave=Avestan
awa=Awadhi
ay=Aymara
aym=Aymara
az=Azerbaijani
aze=Azerbaijani
nah=Aztec
ban=Balinese
bat=Baltic (Other)
bal=Baluchi
bam=Bambara
bai=Bamileke languages
bad=Banda
bnt=Bantu (Other)
bas=Basa
ba=Bashkir
bak=Bashkir
baq=Basque
eu=Basque
eus=Basque
bej=Beja
bem=Bemba
ben=Bengali; Bangla
bn=Bengali; Bangla
ber=Berber (Other)
bho=Bhojpuri
bh=Bihari
bih=Bihari
bik=Bikol
bin=Bini
bi=Bislama
bis=Bislama
bra=Braj
br=Breton
bre=Breton
bug=Buginese
bg=Bulgarian
bul=Bulgarian
bua=Buriat
bur=Burmese
my=Burmese
mya=Burmese
be=Byelorussian
bel=Byelorussian
cad=Caddo
car=Carib
ca=Catalan
cat=Catalan
cau=Caucasian (Other)
ceb=Cebuano
cel=Celtic (Other)
cai=Central American Indian (Other)
chg=Chagatai
cha=Chamorro
che=Chechen
chr=Cherokee
chy=Cheyenne
chb=Chibcha
chi=Chinese
zh=Chinese
zho=Chinese
chn=Chinook jargon
cho=Choctaw
chu=Church Slavic
chv=Chuvash
cop=Coptic
cor=Cornish
co=Corsican
cos=Corsican
cre=Cree
mus=Creek
crp=Creoles and Pidgins (Other)
cpe=Creoles and Pidgins, English-based (Other)
cpf=Creoles and Pidgins, French-based (Other)
cpp=Creoles and Pidgins, Portuguese-based (Other)
hr=Croatian
cus=Cushitic (Other)
ces=Czech
cs=Czech
cze=Czech
dak=Dakota
da=Danish
del=Delaware
din=Dinka
div=Divehi
doi=Dogri
dra=Dravidian (Other)
dua=Duala
dut=Dutch
nl=Dutch
nla=Dutch
dum=Dutch, Middle (ca. 1050-1350)
dyu=Dyula
dz=Dzongkha/Bhutani
dzo=Dzongkha/Bhutani
efi=Efik
egy=Egyptian (Ancient)
eka=Ekajuk
elx=Elamite
en=English
eng=English
enm=English, Middle (ca. 1100-1500)
ang=English, Old (ca. 450-1100)
esk=Eskimo (Other)
eo=Esperanto
epo=Esperanto
est=Estonian
et=Estonian
ewe=Ewe
ewo=Ewondo
fan=Fang
fat=Fanti
fao=Faroese
fo=Faroese
fij=Fijian
fj=Fijian
fi=Finnish
fin=Finnish
fiu=Finno-Ugrian (Other)
fon=Fon
fr=French
fra=French
fre=French
frm=French, Middle (ca. 1400-1600)
fro=French, Old (842- ca. 1400)
fry=Frisian
fy=Frisian
ful=Fulah
gaa=Ga
gae=Gaelic (Scots)
gd=Gaelic (Scots)
gdh=Gaelic (Scots)
gl=Galician/Gallegan
glg=Galician/Gallegan
lug=Ganda
gay=Gayo
gez=Geez
geo=Georgian
ka=Georgian
kat=Georgian
de=German
deu=German
ger=German
gmh=German, Middle High (ca. 1050-1500)
goh=German, Old High (ca. 750-1050)
gem=Germanic (Other)
gil=Gilbertese
gon=Gondi
got=Gothic
grb=Grebo
grc=Greek, Ancient (to 1453)
el=Greek, Modern (1453-)
ell=Greek, Modern (1453-)
gre=Greek, Modern (1453-)
kal=Greenlandic
kl=Greenlandic
gn=Guarani
grn=Guarani
gu=Gujarati
guj=Gujarati
hai=Haida
ha=Hausa
hau=Hausa
haw=Hawaiian
he=Hebrew
heb=Hebrew
iw=Hebrew
her=Herero
hil=Hiligaynon
him=Himachali
hi=Hindi
hi=Hindi
hin=Hindi
hmo=Hiri Motu
hu=Hungarian
hun=Hungarian
hup=Hupa
iba=Iban
ice=Icelandic
is=Icelandic
isl=Icelandic
ibo=Igbo
ijo=Ijo
ilo=Iloko
inc=Indic (Other)
ine=Indo-European (Other)
id=Indonesian
in=Indonesian
ind=Indonesian
ia=Interlingua
ina=Interlingua
ie=Interlingue
ine=Interlingue
iku=Inuktitut
iu=Inuktitut
ik=Inupiak
ipk=Inupiak
ira=Iranian (Other)
ga=Irish
gai=Irish
iri=Irish
mga=Irish, Middle (900 - 1200)
sga=Irish, Old (to 900)
iro=Iroquoian languages
it=Italian
ita=Italian
ja=Japanese
jpn=Japanese
jav=Javanese
jaw=Javanese
jv=Javanese
jw=Javanese
jrb=Judeo-Arabic
jpr=Judeo-Persian
kab=Kabyle
kac=Kachin
kam=Kamba
kan=Kannada
kn=Kannada
kau=Kanuri
kaa=Kara-Kalpak
kar=Karen
kas=Kashmiri
ks=Kashmiri
kaw=Kawi
kaz=Kazakh
kk=Kazakh
kha=Khasi
khm=Khmer/Cambodian
km=Khmer/Cambodian
khi=Khoisan (Other)
kho=Khotanese
kik=Kikuyu
kin=Kinyarwanda
rw=Kinyarwanda
kir=Kirghiz
ky=Kirghiz
rn=Kirundi/Rundi
run=Kirundi/Rundi
kom=Komi
kon=Kongo
kok=Konkani
ko=Korean
kor=Korean
kpe=Kpelle
kro=Kru
kua=Kuanyama
kum=Kumyk
ku=Kurdish
kur=Kurdish
kru=Kurukh
kus=Kusaie
kut=Kutenai
lad=Ladino
lah=Lahnda
lam=Lamba
lao=Laothian
lo=Laothian
la=Latin
lat=Latin
lav=Latvian, Lettish
lv=Latvian, Lettish
ltz=Letzeburgesch
lez=Lezghian
lin=Lingala
ln=Lingala
lit=Lithuanian
lt=Lithuanian
loz=Lozi
lub=Luba-Katanga
lui=Luiseno
lun=Lunda
luo=Luo (Kenya and Tanzania)
mac=Macedonian
mak=Macedonian
mk=Macedonian
mad=Madurese
mag=Magahi
mai=Maithili
mak=Makasar
mg=Malagasy
mlg=Malagasy
may=Malay
ms=Malay
msa=Malay
mal=Malayalam
mlt=Maltese
mt=Maltese
ml=Malayalam
man=Mandingo
mni=Manipuri
mno=Manobo languages
max=Manx
mao=Maori
mi=Maori
mri=Maori
mar=Marathi
mr=Marathi
chm=Mari
mah=Marshall
mwr=Marwari
mas=Masai
myn=Mayan languages
men=Mende
mic=Micmac
min=Minangkabau
mis=Miscellaneous (Other)
moh=Mohawk
mo=Moldavian
mol=Moldavian
lol=Mongo
mn=Mongolian
mon=Mongolian
mkh=Mon-Kmer (Other)
mos=Mossi
mul=Multiple languages
mun=Munda languages
na=Nauru
nau=Nauru
nav=Navajo
nde=Ndebele, North
nbl=Ndebele, South
ndo=Ndongo
ne=Nepali
nep=Nepali
new=Newari
nic=Niger-Kordofanian (Other)
ssa=Nilo-Saharan (Other)
niu=Niuean
non=Norse, Old
nai=North American Indian (Other)
no=Norwegian
nor=Norwegian
nno=Norwegian (Nynorsk)
nub=Nubian languages
nym=Nyamwezi
nya=Nyanja
nyn=Nyankole
nyo=Nyoro
nzi=Nzima
oc=Occitan/Langue d'Oc (post 1500)
oci=Occitan/Langue d'Oc (post 1500)
oji=Ojibwa
or=Oriya
ori=Oriya
om=Oromo (Afan)
om=Oromo (Afan)
orm=Oromo (Afan)
osa=Osage
oss=Ossetic
oto=Otomian languages
pal=Pahlavi
pau=Palauan
pli=Pali
pam=Pampanga
pag=Pangasinan
pan=Panjabi
pap=Papiamento
paa=Papuan-Australian (Other)
ps=Pashto, Pushto
pus=Pashto, Pushto
fa=Persian
fas=Persian
per=Persian
peo=Persian, Old (ca 600 - 400 B.C.)
phn=Phoenician
pl=Polish
pol=Polish
pon=Ponape
por=Portuguese
pt=Portuguese
pra=Prakrit languages
pro=Provencal, Old (to 1500)
pa=Punjabi
pan=Punjabi
qu=Quechua
que=Quechua
raj=Rajasthani
rar=Rarotongan
rm=Rhaeto-Romance
roh=Rhaeto-Romance
roa=Romance (Other)
ro=Romanian
ron=Romanian
rum=Romanian
rom=Romany
ru=Russian
rus=Russian
sal=Salishan languages
sam=Samaritan Aramaic
smi=Sami languages
sm=Samoan
smo=Samoan
sad=Sandawe
sag=Sangho
sg=Sangho
sa=Sanskrit
san=Sanskrit
srd=Sardinian
sco=Scots
sel=Selkup
sem=Semitic (Other)
sr=Serbian
scr=Serbo-Croatian
sh=Serbo-Croatian
srr=Serer
sot=Sesotho/Sotho, Southern
st=Sesotho/Sotho, Southern
shn=Shan
sn=Shona
sna=Shona
sid=Sidamo
bla=Siksika
sd=Sindhi
snd=Sindhi
si=Sinhalese
sin=Sinhalese
sit=Sino-Tibetan (Other)
sio=Siouan languages
ss=Siswati/Siswant
ssw=Siswati/Siswant
sla=Slavic (Other)
sk=Slovak
slk=Slovak
slo=Slovak
sl=Slovenian
slv=Slovenian
sog=Sogdian
so=Somali
som=Somali
son=Songhai
wen=Sorbian languages
nso=Sotho, Northern
sai=South American Indian (Other)
es=Spanish
esl=Spanish
spa=Spanish
suk=Sukuma
sux=Sumerian
su=Sundanese
sun=Sundanese
sus=Susu
sw=Swahili
swa=Swahili
ssw=Swazi
sv=Swedish
sve=Swedish
swe=Swedish
syr=Syriac
tgl=Tagalog
tl=Tagalog
tah=Tahitian
tg=Tajik
tgk=Tajik
tmh=Tamashek
ta=Tamil
tam=Tamil
tat=Tatar
tt=Tatar
te=Telugu
tel=Telugu
ter=Tereno
th=Thai
tha=Thai
bo=Tibetan
bod=Tibetan
tib=Tibetan
tig=Tigre
ti=Tigrinya
tir=Tigrinya
tem=Timne
tiv=Tivi
tli=Tlingit
to=Tonga (Nyasa)
tog=Tonga (Nyasa)
ton=Tonga (Tonga Islands)
tru=Truk
tsi=Tsimshian
ts=Tsonga
tso=Tsonga
tn=Tswana/Setswana
tsn=Tswana/Setswana
tum=Tumbuka
tr=Turkish
tur=Turkish
ota=Turkish, Ottoman (1500 - 1928)
tk=Turkmen
tuk=Turkmen
tyv=Tuvinian
tw=Twi
twi=Twi
uga=Ugaritic
ug=Uighur
uig=Uighur
uk=Ukrainian
ukr=Ukrainian
umb=Umbundu
# should be und=Undetermined, but deliberately changing it
und=Other
ur=Urdu
urd=Urdu
uz=Uzbek
uzb=Uzbek
vai=Vai
ven=Venda
vi=Vietnamese
vie=Vietnamese
vo=Volapük
vol=Volapük
vot=Votic
wak=Wakashan languages
wal=Walamo
war=Waray
was=Washo
cy=Welsh
cym=Welsh
wel=Welsh
wo=Wolof
wol=Wolof
xh=Xhosa
xh=Xhosa
xho=Xhosa
sah=Yakut
yao=Yao
yap=Yap
ji=Yiddish
yi=Yiddish
yid=Yiddish
yo=Yoruba
yor=Yoruba
zap=Zapotec
zen=Zenaga
za=Zhuang
zha=Zhuang
zu=Zulu
zul=Zulu
zun=Zuni
# The following additions are specific to sword
bs=Bosnian
# the following two are wrong in Sword
po=Polish
ty=Tahitian
Index: DefaultBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic/DefaultBookMetaData.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** DefaultBookMetaData.java 9 Oct 2004 21:45:04 -0000 1.14
--- DefaultBookMetaData.java 25 Jan 2005 00:02:32 -0000 1.15
***************
*** 1,6 ****
package org.crosswire.jsword.book.basic;
- import java.util.LinkedHashMap;
- import java.util.Map;
import java.util.Properties;
--- 1,4 ----
***************
*** 50,58 ****
public DefaultBookMetaData(BookDriver driver, Book book, Properties prop)
{
! this.driver = driver;
! this.book = book;
!
! map.putAll(prop);
setName(prop.getProperty(BookMetaData.KEY_NAME));
setType(prop.getProperty(BookMetaData.KEY_TYPE));
--- 48,55 ----
public DefaultBookMetaData(BookDriver driver, Book book, Properties prop)
{
! setDriver(driver);
! setBook(book);
+ setProperties(prop);
setName(prop.getProperty(BookMetaData.KEY_NAME));
setType(prop.getProperty(BookMetaData.KEY_TYPE));
***************
*** 76,84 ****
public DefaultBookMetaData(BookDriver driver, Book book, String name, BookType type)
{
! this.driver = driver;
! this.book = book;
!
setName(name);
setType(type);
}
--- 73,81 ----
public DefaultBookMetaData(BookDriver driver, Book book, String name, BookType type)
{
! setDriver(driver);
! setBook(book);
setName(name);
setType(type);
+ setLanguage(null); // Default language
}
***************
*** 92,111 ****
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getBook()
- */
- public Book getBook()
- {
- return book;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getDriver()
- */
- public BookDriver getDriver()
- {
- return driver;
- }
-
- /* (non-Javadoc)
* @see org.crosswire.jsword.book.BookMetaData#getName()
*/
--- 89,92 ----
***************
*** 116,127 ****
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getLanguage()
- */
- public String getLanguage()
- {
- return language;
- }
-
- /* (non-Javadoc)
* @see org.crosswire.jsword.book.BookMetaData#getInitials()
*/
--- 97,100 ----
***************
*** 132,174 ****
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getProperties()
- */
- public Map getProperties()
- {
- return map;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getFullName()
- */
- public String getFullName()
- {
- StringBuffer buf = new StringBuffer(getName());
-
- if (driver != null)
- {
- buf.append(" (").append(getDriverName()).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return buf.toString();
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getFullName()
- */
- public String getOsisID()
- {
- return getType().toString() + '.' + getInitials();
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getDriverName()
- */
- public String getDriverName()
- {
- return driver.getDriverName();
- }
-
- /* (non-Javadoc)
* @see org.crosswire.jsword.book.BookMetaData#isLeftToRight()
*/
--- 105,108 ----
***************
*** 179,217 ****
}
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getIndexStatus()
- */
- public IndexStatus getIndexStatus()
- {
- return indexStatus;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#setIndexStatus(java.lang.String)
- */
- public void setIndexStatus(IndexStatus newValue)
- {
- IndexStatus oldValue = this.indexStatus;
- this.indexStatus = newValue;
- map.put(KEY_INDEXSTATUS, newValue);
- firePropertyChange(KEY_INDEXSTATUS, oldValue, newValue);
- }
-
- /**
- * @param book The book to set.
- */
- public void setBook(Book book)
- {
- this.book = book;
- }
-
- /**
- * @param driver The driver to set.
- */
- public void setDriver(BookDriver driver)
- {
- this.driver = driver;
- }
-
/**
* @param language The language to set.
--- 113,116 ----
***************
*** 219,232 ****
public void setLanguage(String language)
{
! if (language == null)
! {
! this.language = ""; //$NON-NLS-1$
! }
! else
! {
! this.language = language;
! }
!
! map.put(KEY_LANGUAGE, this.language);
}
--- 118,122 ----
public void setLanguage(String language)
{
! putProperty(KEY_LANGUAGE, getLanguage(initials, language));
}
***************
*** 255,259 ****
}
! map.put(KEY_INITIALS, this.initials);
}
--- 145,149 ----
}
! putProperty(KEY_INITIALS, this.initials);
}
***************
*** 268,272 ****
this.name = name;
! map.put(KEY_NAME, this.name);
setInitials(StringUtil.getInitials(name));
--- 158,162 ----
this.name = name;
! putProperty(KEY_NAME, this.name);
setInitials(StringUtil.getInitials(name));
***************
*** 284,288 ****
this.type = type;
! map.put(KEY_TYPE, type == null ? "" : type.toString()); //$NON-NLS-1$
}
--- 174,178 ----
this.type = type;
! putProperty(KEY_TYPE, type == null ? "" : type.toString()); //$NON-NLS-1$
}
***************
*** 301,367 ****
}
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj)
- {
- // Since this can not be null
- if (obj == null)
- {
- return false;
- }
-
- // We might consider checking for equality against all BookMetaDatas?
- // However currently we dont.
-
- // Check that that is the same as this
- // Don't use instanceof since that breaks inheritance
- if (!obj.getClass().equals(this.getClass()))
- {
- return false;
- }
-
- // The real bit ...
- BookMetaData that = (BookMetaData) obj;
-
- return getName().equals(that.getName());
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode()
- {
- return getName().hashCode();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString()
- {
- return getFullName();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(Object obj)
- {
- BookMetaData that = (BookMetaData) obj;
- return this.getName().compareTo(that.getName());
- }
-
- /**
- *
- */
- private Map map = new LinkedHashMap();
-
private BookType type;
! private Book book;
! private BookDriver driver;
! private String name = ""; //$NON-NLS-1$
! private String language = ""; //$NON-NLS-1$
! private String initials = ""; //$NON-NLS-1$
! private IndexStatus indexStatus = IndexStatus.UNDONE;
}
--- 191,196 ----
}
private BookType type;
! private String name;
! private String initials;
}
Index: AbstractBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic/AbstractBookMetaData.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** AbstractBookMetaData.java 9 Oct 2004 21:45:04 -0000 1.16
--- AbstractBookMetaData.java 25 Jan 2005 00:02:32 -0000 1.17
***************
*** 3,10 ****
--- 3,21 ----
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+ import java.util.LinkedHashMap;
+ import java.util.Locale;
+ import java.util.Map;
+ import java.util.MissingResourceException;
+ import java.util.ResourceBundle;
import javax.swing.event.EventListenerList;
+ import org.crosswire.common.util.CWClassLoader;
+ import org.crosswire.common.util.Logger;
+ import org.crosswire.common.util.StringUtil;
+ import org.crosswire.jsword.book.Book;
+ import org.crosswire.jsword.book.BookDriver;
import org.crosswire.jsword.book.BookMetaData;
+ import org.crosswire.jsword.book.IndexStatus;
/**
***************
*** 35,38 ****
--- 46,291 ----
{
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#getBook()
+ */
+ public Book getBook()
+ {
+ return book;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#getDriver()
+ */
+ public BookDriver getDriver()
+ {
+ return driver;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#getDriverName()
+ */
+ public String getDriverName()
+ {
+ if (getDriver() == null)
+ {
+ return null;
+ }
+
+ return getDriver().getDriverName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#getFullName()
+ */
+ public String getOsisID()
+ {
+ return getType().toString() + '.' + getInitials();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#getFullName()
+ */
+ public String getFullName()
+ {
+ if (fullName == null)
+ {
+ fullName = computeFullName();
+ }
+ return fullName;
+ }
+
+ /**
+ *
+ */
+ private String computeFullName()
+ {
+ StringBuffer buf = new StringBuffer(getName());
+
+ if (getDriver() != null)
+ {
+ buf.append(" (").append(getDriverName()).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return buf.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#getLanguage()
+ */
+ public String getLanguage()
+ {
+ return (String) getProperty(KEY_LANGUAGE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#getProperties()
+ */
+ public Map getProperties()
+ {
+ return prop;
+ }
+
+ /**
+ * @param newProperties
+ */
+ public void setProperties(Map newProperties)
+ {
+ prop = newProperties;
+ }
+
+ /**
+ * @param key
+ * @return the object found by the key
+ */
+ protected Object getProperty(String key)
+ {
+ return prop.get(key);
+ }
+
+ /**
+ * @param key
+ * @param value
+ */
+ protected void putProperty(String key, Object value)
+ {
+ prop.put(key, value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#getIndexStatus()
+ */
+ public IndexStatus getIndexStatus()
+ {
+ return indexStatus;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#setIndexStatus(java.lang.String)
+ */
+ public void setIndexStatus(IndexStatus newValue)
+ {
+ IndexStatus oldValue = this.indexStatus;
+ this.indexStatus = newValue;
+ prop.put(KEY_INDEXSTATUS, newValue);
+ firePropertyChange(KEY_INDEXSTATUS, oldValue, newValue);
+ }
+
+ /**
+ * @param book The book to set.
+ */
+ public void setBook(Book book)
+ {
+ this.book = book;
+ }
+
+ /**
+ * @param driver The driver to set.
+ */
+ public void setDriver(BookDriver driver)
+ {
+ this.driver = driver;
+ }
+
+
+ /**
+ * Get the language name from the language code. Note, this code does not support dialects.
+ * @param iso639Code
+ * @return the name of the language
+ */
+ protected String getLanguage(String ident, String iso639Code)
+ {
+ String lookup = iso639Code;
+ if (lookup == null || lookup.length() == 0)
+ {
+ log.warn("Book " + ident + " named " + getName() + " has no language specified. Assuming English."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return getLanguage(ident, DEFAULT_LANG_CODE);
+ }
+
+ if (lookup.indexOf('_') != -1)
+ {
+ String[] locale = StringUtil.split(lookup, '_');
+ return getLanguage(ident, locale[0]);
+ }
+
+ char firstLangChar = lookup.charAt(0);
+ // If the language begins w/ an x then it is "Undetermined"
+ // Also if it is not a 2 or 3 character code then it is not a valid
+ // iso639 code.
+ if (firstLangChar == 'x' || firstLangChar == 'X' || lookup.length() > 3)
+ {
+ return getLanguage(ident, UNKNOWN_LANG_CODE);
+ }
+
+ try
+ {
+ return languages.getString(lookup);
+ }
+ catch (MissingResourceException e)
+ {
+ log.error("Not a valid language code:" + iso639Code + " in book " + ident); //$NON-NLS-1$ //$NON-NLS-2$
+ return getLanguage(ident, UNKNOWN_LANG_CODE);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj)
+ {
+ // Since this can not be null
+ if (obj == null)
+ {
+ return false;
+ }
+
+ // We might consider checking for equality against all BookMetaDatas?
+ // However currently we dont.
+
+ // Check that that is the same as this
+ // Don't use instanceof since that breaks inheritance
+ if (!obj.getClass().equals(this.getClass()))
+ {
+ return false;
+ }
+
+ // The real bit ...
+ BookMetaData that = (BookMetaData) obj;
+
+ return getName().equals(that.getName());
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode()
+ {
+ return getName().hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object obj)
+ {
+ BookMetaData that = (BookMetaData) obj;
+ return this.getInitials().compareTo(that.getInitials());
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ if (displayName == null)
+ {
+ StringBuffer buf = new StringBuffer("["); //$NON-NLS-1$
+ buf.append(getInitials());
+ buf.append("] - "); //$NON-NLS-1$
+ buf.append(getFullName());
+ displayName = buf.toString();
+ }
+ return displayName;
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.book.BookMetaData#addPropertyChangeListener(java.beans.PropertyChangeListener)
*/
***************
*** 95,100 ****
--- 348,385 ----
/**
+ * The log stream
+ */
+ private static final Logger log = Logger.getLogger(AbstractBookMetaData.class);
+
+ private static final String DEFAULT_LANG_CODE = "en"; //$NON-NLS-1$
+ private static final String UNKNOWN_LANG_CODE = "und"; //$NON-NLS-1$
+
+ /**
* The list of property change listeners
*/
private transient EventListenerList listeners;
+
+ private static/*final*/ResourceBundle languages;
+ static
+ {
+ try
+ {
+ languages = ResourceBundle.getBundle("iso639", Locale.getDefault(), new CWClassLoader()); //$NON-NLS-1$;
+ }
+ catch (MissingResourceException e)
+ {
+ assert false;
+ }
+ }
+
+ /**
+ * The single key version of the properties
+ */
+ private Map prop = new LinkedHashMap();
+
+ private Book book;
+ private BookDriver driver;
+ private String fullName;
+ private String displayName;
+ private IndexStatus indexStatus = IndexStatus.UNDONE;
}
More information about the jsword-svn
mailing list