1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 02:39:23 +02:00

renaming: UrlInfo -> UrlInfoWithDate

This commit is contained in:
Nikolay Pultsin 2011-04-15 20:05:24 +01:00
parent 9cb85dc4e0
commit a22632af7e
12 changed files with 45 additions and 45 deletions

View file

@ -239,8 +239,8 @@ public class AddCustomCatalogActivity extends Activity {
setErrorByKey("invalidUrl");
return;
}
final HashMap<String,UrlInfo> infos = new HashMap<String,UrlInfo>();
infos.put(INetworkLink.URL_MAIN, new UrlInfo(textUrl));
final HashMap<String,UrlInfoWithDate> infos = new HashMap<String,UrlInfoWithDate>();
infos.put(INetworkLink.URL_MAIN, new UrlInfoWithDate(textUrl));
myLink = new OPDSCustomLink(
ICustomNetworkLink.INVALID_ID, siteName, null, null, infos
);

View file

@ -71,7 +71,7 @@ public class NetworkLibraryActivity extends NetworkBaseActivity {
uri.getHost(),
intent.getStringExtra(ADD_CATALOG_TITLE_KEY),
intent.getStringExtra(ADD_CATALOG_SUMMARY_KEY),
(HashMap<String,UrlInfo>)intent.getSerializableExtra(ADD_CATALOG_URLS_MAP_KEY)
(HashMap<String,UrlInfoWithDate>)intent.getSerializableExtra(ADD_CATALOG_URLS_MAP_KEY)
);
}

View file

@ -30,7 +30,7 @@ import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
import org.geometerplus.fbreader.network.ICustomNetworkLink;
import org.geometerplus.fbreader.network.NetworkDatabase;
import org.geometerplus.fbreader.network.UrlInfo;
import org.geometerplus.fbreader.network.UrlInfoWithDate;
import org.geometerplus.android.util.SQLiteUtil;
@ -77,7 +77,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
@Override
protected void loadCustomLinks(ICustomLinksHandler handler) {
final Cursor cursor = myDatabase.rawQuery("SELECT link_id,title,site_name,summary FROM Links", null);
final HashMap<String,UrlInfo> linksMap = new HashMap<String,UrlInfo>();
final HashMap<String,UrlInfoWithDate> linksMap = new HashMap<String,UrlInfoWithDate>();
while (cursor.moveToNext()) {
final int id = cursor.getInt(0);
final String title = cursor.getString(1);
@ -89,7 +89,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
while (linksCursor.moveToNext()) {
linksMap.put(
linksCursor.getString(0),
new UrlInfo(
new UrlInfoWithDate(
linksCursor.getString(1),
SQLiteUtil.getDate(linksCursor, 2)
)
@ -134,7 +134,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
SQLiteUtil.bindString(statement, 3, link.getSummary());
final long id;
final HashMap<String,UrlInfo> linksMap = new HashMap<String,UrlInfo>();
final HashMap<String,UrlInfoWithDate> linksMap = new HashMap<String,UrlInfoWithDate>();
if (statement == myInsertCustomLinkStatement) {
id = statement.executeInsert();
@ -148,7 +148,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
while (linksCursor.moveToNext()) {
linksMap.put(
linksCursor.getString(0),
new UrlInfo(
new UrlInfoWithDate(
linksCursor.getString(1),
SQLiteUtil.getDate(linksCursor, 2)
)
@ -158,8 +158,8 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
}
for (String key : link.getUrlKeys()) {
final UrlInfo info = link.getUrlInfo(key);
final UrlInfo dbInfo = linksMap.remove(key);
final UrlInfoWithDate info = link.getUrlInfo(key);
final UrlInfoWithDate dbInfo = linksMap.remove(key);
final SQLiteStatement urlStatement;
if (dbInfo == null) {
if (myInsertCustomLinkUrlStatement == null) {

View file

@ -29,7 +29,7 @@ public abstract class AbstractNetworkLink implements INetworkLink, Basket {
protected String myTitle;
protected String mySummary;
protected final String myLanguage;
protected final TreeMap<String,UrlInfo> myInfos;
protected final TreeMap<String,UrlInfoWithDate> myInfos;
private ZLStringListOption myBooksInBasketOption;
@ -42,12 +42,12 @@ public abstract class AbstractNetworkLink implements INetworkLink, Basket {
* @param language language of the catalog. If <code>null</code> we assume this catalog is multilanguage.
* @param infos map contains URL infos with their identifiers; must always contain one URL with <code>URL_MAIN</code> identifier
*/
public AbstractNetworkLink(String siteName, String title, String summary, String language, Map<String,UrlInfo> infos) {
public AbstractNetworkLink(String siteName, String title, String summary, String language, Map<String,UrlInfoWithDate> infos) {
mySiteName = siteName;
myTitle = title;
mySummary = summary;
myLanguage = language != null ? language : "multi";
myInfos = new TreeMap<String,UrlInfo>(infos);
myInfos = new TreeMap<String,UrlInfoWithDate>(infos);
}
public final String getSiteName() {
@ -66,13 +66,13 @@ public abstract class AbstractNetworkLink implements INetworkLink, Basket {
return myLanguage;
}
public final HashMap<String,UrlInfo> urlInfoMap() {
return new HashMap<String,UrlInfo>(myInfos);
public final HashMap<String,UrlInfoWithDate> urlInfoMap() {
return new HashMap<String,UrlInfoWithDate>(myInfos);
}
public final UrlInfo getUrlInfo(String urlKey) {
final UrlInfo info = myInfos.get(urlKey);
return info != null ? info : UrlInfo.NULL;
public final UrlInfoWithDate getUrlInfo(String urlKey) {
final UrlInfoWithDate info = myInfos.get(urlKey);
return info != null ? info : UrlInfoWithDate.NULL;
}
public final Set<String> getUrlKeys() {

View file

@ -33,7 +33,7 @@ public interface ICustomNetworkLink extends INetworkLink {
void setTitle(String title);
void setSummary(String summary);
HashMap<String,UrlInfo> urlInfoMap();
HashMap<String,UrlInfoWithDate> urlInfoMap();
void setUrl(String urlKey, String url);
void removeUrl(String urlKey);

View file

@ -40,7 +40,7 @@ public interface INetworkLink {
String getTitle();
String getSummary();
UrlInfo getUrlInfo(String urlKey);
UrlInfoWithDate getUrlInfo(String urlKey);
Set<String> getUrlKeys();
/**

View file

@ -35,7 +35,7 @@ public abstract class NetworkDatabase {
protected abstract void executeAsATransaction(Runnable actions);
public interface ICustomLinksHandler {
void handleCustomLinkData(int id, String siteName, String title, String summary, Map<String,UrlInfo> infos);
void handleCustomLinkData(int id, String siteName, String title, String summary, Map<String,UrlInfoWithDate> infos);
}
protected abstract void loadCustomLinks(ICustomLinksHandler handler);

View file

@ -179,7 +179,7 @@ public class NetworkLibrary {
db.loadCustomLinks(
new NetworkDatabase.ICustomLinksHandler() {
public void handleCustomLinkData(int id, String siteName,
String title, String summary, Map<String,UrlInfo> infos) {
String title, String summary, Map<String,UrlInfoWithDate> infos) {
if (title != null &&
siteName != null &&
infos.get(INetworkLink.URL_MAIN) != null) {

View file

@ -24,20 +24,20 @@ import java.io.Serializable;
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
public final class UrlInfo implements Serializable {
public final class UrlInfoWithDate implements Serializable {
private static final long serialVersionUID = -893514485257787222L;
public static final UrlInfo NULL = new UrlInfo(null, null);
public static final UrlInfoWithDate NULL = new UrlInfoWithDate(null, null);
public final String URL;
public final Date Updated;
public UrlInfo(String url, Date updated) {
public UrlInfoWithDate(String url, Date updated) {
URL = url;
Updated = updated;
}
public UrlInfo(String url) {
public UrlInfoWithDate(String url) {
this(url, new Date());
}
@ -46,11 +46,11 @@ public final class UrlInfo implements Serializable {
if (o == this) {
return true;
}
if (!(o instanceof UrlInfo)) {
if (!(o instanceof UrlInfoWithDate)) {
return false;
}
final UrlInfo info = (UrlInfo)o;
final UrlInfoWithDate info = (UrlInfoWithDate)o;
return ZLMiscUtil.equals(URL, info.URL) && ZLMiscUtil.equals(Updated, info.Updated);
}

View file

@ -31,7 +31,7 @@ import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
import org.geometerplus.fbreader.network.ICustomNetworkLink;
import org.geometerplus.fbreader.network.NetworkException;
import org.geometerplus.fbreader.network.UrlInfo;
import org.geometerplus.fbreader.network.UrlInfoWithDate;
public class OPDSCustomLink extends OPDSNetworkLink implements ICustomNetworkLink {
private int myId;
@ -45,7 +45,7 @@ public class OPDSCustomLink extends OPDSNetworkLink implements ICustomNetworkLin
return siteName;
}
public OPDSCustomLink(int id, String siteName, String title, String summary, Map<String,UrlInfo> infos) {
public OPDSCustomLink(int id, String siteName, String title, String summary, Map<String,UrlInfoWithDate> infos) {
super(removeWWWPrefix(siteName), title, summary, null, infos, false);
myId = id;
}
@ -82,12 +82,12 @@ public class OPDSCustomLink extends OPDSNetworkLink implements ICustomNetworkLin
}
public final void setUrl(String urlKey, String url) {
myInfos.put(urlKey, new UrlInfo(url, new Date()));
myInfos.put(urlKey, new UrlInfoWithDate(url, new Date()));
myHasChanges = true;
}
public final void removeUrl(String urlKey) {
final UrlInfo oldUrl = myInfos.remove(urlKey);
final UrlInfoWithDate oldUrl = myInfos.remove(urlKey);
myHasChanges = myHasChanges || oldUrl != null;
}

View file

@ -30,7 +30,7 @@ import org.geometerplus.zlibrary.core.xml.ZLStringMap;
import org.geometerplus.fbreader.network.INetworkLink;
import org.geometerplus.fbreader.network.NetworkLibrary;
import org.geometerplus.fbreader.network.NetworkCatalogItem;
import org.geometerplus.fbreader.network.UrlInfo;
import org.geometerplus.fbreader.network.UrlInfoWithDate;
import org.geometerplus.fbreader.network.atom.ATOMLink;
import org.geometerplus.fbreader.network.atom.ATOMUpdated;
import org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager;
@ -99,7 +99,7 @@ class OPDSLinkXMLReader extends OPDSXMLReader implements OPDSConstants, MimeType
final String summary = entry.Content;
final String language = entry.DCLanguage;
final HashMap<String,UrlInfo> infos = new HashMap<String,UrlInfo>();
final HashMap<String,UrlInfoWithDate> infos = new HashMap<String,UrlInfoWithDate>();
final HashMap<String,NetworkCatalogItem.Accessibility> urlConditions =
new HashMap<String,NetworkCatalogItem.Accessibility>();
for (ATOMLink link: entry.Links) {
@ -108,35 +108,35 @@ class OPDSLinkXMLReader extends OPDSXMLReader implements OPDSConstants, MimeType
final String rel = link.getRel();
if (rel == REL_IMAGE_THUMBNAIL || rel == REL_THUMBNAIL) {
if (type == MIME_IMAGE_PNG || type == MIME_IMAGE_JPEG) {
infos.put(INetworkLink.URL_ICON, new UrlInfo(href));
infos.put(INetworkLink.URL_ICON, new UrlInfoWithDate(href));
}
} else if ((rel != null && rel.startsWith(REL_IMAGE_PREFIX)) || rel == REL_COVER) {
if (infos.get(INetworkLink.URL_ICON) == null &&
(type == MIME_IMAGE_PNG || type == MIME_IMAGE_JPEG)) {
infos.put(INetworkLink.URL_ICON, new UrlInfo(href));
infos.put(INetworkLink.URL_ICON, new UrlInfoWithDate(href));
}
} else if (rel == null) {
if (type == MIME_APP_ATOM) {
infos.put(INetworkLink.URL_MAIN, new UrlInfo(href));
infos.put(INetworkLink.URL_MAIN, new UrlInfoWithDate(href));
}
} else if (rel == "search") {
if (type == MIME_APP_ATOM) {
final OpenSearchDescription descr = OpenSearchDescription.createDefault(href);
if (descr.isValid()) {
// TODO: May be do not use '%s'??? Use Description instead??? (this needs to rewrite SEARCH engine logic a little)
infos.put(INetworkLink.URL_SEARCH, new UrlInfo(descr.makeQuery("%s")));
infos.put(INetworkLink.URL_SEARCH, new UrlInfoWithDate(descr.makeQuery("%s")));
}
}
} else if (rel == REL_LINK_SIGN_IN) {
infos.put(INetworkLink.URL_SIGN_IN, new UrlInfo(href));
infos.put(INetworkLink.URL_SIGN_IN, new UrlInfoWithDate(href));
} else if (rel == REL_LINK_SIGN_OUT) {
infos.put(INetworkLink.URL_SIGN_OUT, new UrlInfo(href));
infos.put(INetworkLink.URL_SIGN_OUT, new UrlInfoWithDate(href));
} else if (rel == REL_LINK_SIGN_UP) {
infos.put(INetworkLink.URL_SIGN_UP, new UrlInfo(href));
infos.put(INetworkLink.URL_SIGN_UP, new UrlInfoWithDate(href));
} else if (rel == REL_LINK_TOPUP) {
infos.put(INetworkLink.URL_TOPUP, new UrlInfo(href));
infos.put(INetworkLink.URL_TOPUP, new UrlInfoWithDate(href));
} else if (rel == REL_LINK_RECOVER_PASSWORD) {
infos.put(INetworkLink.URL_RECOVER_PASSWORD, new UrlInfo(href));
infos.put(INetworkLink.URL_RECOVER_PASSWORD, new UrlInfoWithDate(href));
} else if (rel == REL_CONDITION_NEVER) {
urlConditions.put(href, NetworkCatalogItem.Accessibility.NEVER);
} else if (rel == REL_CONDITION_SIGNED_IN) {
@ -166,7 +166,7 @@ class OPDSLinkXMLReader extends OPDSXMLReader implements OPDSConstants, MimeType
String title,
String summary,
String language,
Map<String,UrlInfo> infos,
Map<String,UrlInfoWithDate> infos,
HashMap<String,NetworkCatalogItem.Accessibility> urlConditions,
String sslCertificate
) {

View file

@ -44,7 +44,7 @@ public class OPDSNetworkLink extends AbstractNetworkLink {
private final boolean myHasStableIdentifiers;
OPDSNetworkLink(String siteName, String title, String summary, String language,
Map<String,UrlInfo> infos, boolean hasStableIdentifiers) {
Map<String,UrlInfoWithDate> infos, boolean hasStableIdentifiers) {
super(siteName, title, summary, language, infos);
myHasStableIdentifiers = hasStableIdentifiers;
}