mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@106 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
1b9bcd7ea2
commit
4b833c39d8
3 changed files with 128 additions and 0 deletions
43
src/org/zlibrary/core/resources/ZLResource.java
Normal file
43
src/org/zlibrary/core/resources/ZLResource.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
package org.zlibrary.core.resources;
|
||||
|
||||
abstract public class ZLResource {
|
||||
private String myName;
|
||||
|
||||
public static ZLResource resource(String key) {
|
||||
return null;//todo
|
||||
}
|
||||
|
||||
public static ZLResource resource(ZLResourceKey key) {
|
||||
return resource(key.Name);
|
||||
}
|
||||
|
||||
protected ZLResource(String name) {
|
||||
this.myName = name;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return myName;
|
||||
}
|
||||
abstract public boolean hasValue();
|
||||
|
||||
abstract public String value();
|
||||
|
||||
public ZLResource getResource(ZLResourceKey key) {
|
||||
return getResource(key.Name);
|
||||
}
|
||||
|
||||
abstract public ZLResource getResource(String key);
|
||||
}
|
||||
/*const ZLResource &ZLResource::operator [] (const ZLResourceKey &key) const {
|
||||
return (*this)[key.Name];
|
||||
}
|
||||
|
||||
const ZLResource &ZLResource::resource(const std::string &key) {
|
||||
ZLTreeResource::buildTree();
|
||||
if (ZLTreeResource::ourRoot.isNull()) {
|
||||
return ZLMissingResource::instance();
|
||||
}
|
||||
return (*ZLTreeResource::ourRoot)[key];
|
||||
}
|
||||
|
||||
*/
|
11
src/org/zlibrary/core/resources/ZLResourceKey.java
Normal file
11
src/org/zlibrary/core/resources/ZLResourceKey.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package org.zlibrary.core.resources;
|
||||
|
||||
public class ZLResourceKey {
|
||||
public String Name;
|
||||
|
||||
public ZLResourceKey() {}
|
||||
|
||||
public ZLResourceKey(String name) {
|
||||
Name = name;
|
||||
}
|
||||
}
|
74
src/org/zlibrary/core/resources/ZLTreeResource.java
Normal file
74
src/org/zlibrary/core/resources/ZLTreeResource.java
Normal file
|
@ -0,0 +1,74 @@
|
|||
package org.zlibrary.core.resources;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ZLTreeResource {
|
||||
public static ZLTreeResource ourRoot;
|
||||
|
||||
/*public static void buildTree() {
|
||||
|
||||
}
|
||||
public static void loadData(String language) {
|
||||
String filePath = ZLibrary.FileNameDelimiter + "resources" + ZLibrary.FileNameDelimiter + language + ".xml";
|
||||
new ZLResourceTreeReader(ourRoot).readDocument(ZLApplication.ZLibraryDirectory() + filePath);
|
||||
new ZLResourceTreeReader(ourRoot).readDocument(ZLApplication.ApplicationDirectory() + filePath);
|
||||
|
||||
}
|
||||
|
||||
private ZLTreeResource(String name);
|
||||
private ZLTreeResource(String name, String value);
|
||||
private void setValue(String value);
|
||||
private boolean hasValue();
|
||||
private String value();
|
||||
|
||||
public ZLResource &operator [] (String key);
|
||||
|
||||
private boolean myHasValue;
|
||||
private String myValue;
|
||||
private Map<String, ZLTreeResource> myChildren;*/
|
||||
}
|
||||
|
||||
/*void ZLTreeResource::loadData(const std::string &language) {
|
||||
std::string filePath = ZLibrary::FileNameDelimiter + "resources" + ZLibrary::FileNameDelimiter + language + ".xml";
|
||||
ZLResourceTreeReader(ourRoot).readDocument(ZLApplication::ZLibraryDirectory() + filePath);
|
||||
ZLResourceTreeReader(ourRoot).readDocument(ZLApplication::ApplicationDirectory() + filePath);
|
||||
}
|
||||
|
||||
void ZLTreeResource::buildTree() {
|
||||
if (ourRoot.isNull()) {
|
||||
ourRoot = new ZLTreeResource(std::string());
|
||||
loadData("en");
|
||||
const std::string language = ZLibrary::Language();
|
||||
if (language != "en") {
|
||||
loadData(language);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ZLTreeResource::ZLTreeResource(const std::string &name) : ZLResource(name), myHasValue(false) {
|
||||
}
|
||||
|
||||
ZLTreeResource::ZLTreeResource(const std::string &name, const std::string &value) : ZLResource(name), myHasValue(true), myValue(value) {
|
||||
}
|
||||
|
||||
void ZLTreeResource::setValue(const std::string &value) {
|
||||
myHasValue = true;
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
bool ZLTreeResource::hasValue() const {
|
||||
return myHasValue;
|
||||
}
|
||||
|
||||
const std::string &ZLTreeResource::value() const {
|
||||
return myHasValue ? myValue : ZLMissingResource::ourValue;
|
||||
}
|
||||
|
||||
const ZLResource &ZLTreeResource::operator [] (const std::string &key) const {
|
||||
std::map<std::string,shared_ptr<ZLTreeResource> >::const_iterator it = myChildren.find(key);
|
||||
if (it != myChildren.end()) {
|
||||
return *it->second;
|
||||
} else {
|
||||
return ZLMissingResource::instance();
|
||||
}
|
||||
}*/
|
Loading…
Add table
Add a link
Reference in a new issue