mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
code cleanup
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@1067 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
3f4a6e32d3
commit
0ce3269bca
10 changed files with 32 additions and 77 deletions
|
@ -121,7 +121,7 @@ public abstract class ZLTreeAdapter extends BaseAdapter implements AdapterView.O
|
|||
final int index = indexByPosition(position + 1, myTree) - 1;
|
||||
ZLTree item = myItems[index];
|
||||
if (item == null) {
|
||||
item = myTree.getTree(index + 1);
|
||||
item = myTree.getTreeByParagraphNumber(index + 1);
|
||||
myItems[index] = item;
|
||||
}
|
||||
return item;
|
||||
|
|
|
@ -352,7 +352,7 @@ public class BookReader {
|
|||
public final void setReference(int contentsParagraphNumber, ZLTextWritableModel textModel, int referenceNumber) {
|
||||
final TOCTree contentsTree = Model.TOCTree;
|
||||
if (contentsParagraphNumber < contentsTree.getSize()) {
|
||||
contentsTree.getTree(contentsParagraphNumber).setReference(
|
||||
contentsTree.getTreeByParagraphNumber(contentsParagraphNumber).setReference(
|
||||
textModel, referenceNumber
|
||||
);
|
||||
}
|
||||
|
|
|
@ -77,15 +77,8 @@ public class NetworkBookItem extends NetworkLibraryItem {
|
|||
Language = language;
|
||||
Date = date;
|
||||
Price = price;
|
||||
|
||||
List<AuthorData> authors2 = new LinkedList<AuthorData>();
|
||||
authors2.addAll(authors);
|
||||
Authors = Collections.unmodifiableList(authors2);
|
||||
|
||||
List<String> tags2 = new LinkedList<String>();
|
||||
tags2.addAll(tags);
|
||||
Tags = Collections.unmodifiableList(tags2);
|
||||
|
||||
Authors = new LinkedList<AuthorData>(authors);
|
||||
Tags = new LinkedList<String>(tags);
|
||||
SeriesTitle = seriesTitle;
|
||||
IndexInSeries = indexInSeries;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class NetworkLibrary {
|
|||
}
|
||||
|
||||
private void makeUpToDate() {
|
||||
final List<FBTree> toRemove = new LinkedList<FBTree>();
|
||||
final LinkedList<FBTree> toRemove = new LinkedList<FBTree>();
|
||||
|
||||
Iterator<FBTree> nodeIterator = myRootTree.iterator();
|
||||
FBTree currentNode = null;
|
||||
|
|
|
@ -37,14 +37,14 @@ public class ATOMCategory extends ATOMCommonAttributes {
|
|||
}
|
||||
|
||||
public final String getTerm() {
|
||||
return Attributes.get(TERM);
|
||||
return getAttribute(TERM);
|
||||
}
|
||||
|
||||
public final String getScheme() {
|
||||
return Attributes.get(SCHEME);
|
||||
return getAttribute(SCHEME);
|
||||
}
|
||||
|
||||
public final String getLabel() {
|
||||
return Attributes.get(LABEL);
|
||||
return getAttribute(LABEL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ abstract class ATOMCommonAttributes {
|
|||
public static final String XML_BASE = "xml:base";
|
||||
public static final String XML_LANG = "xml:lang";
|
||||
|
||||
public final Map<String, String> Attributes = new TreeMap<String, String>();
|
||||
private TreeMap<String, String> myAttributes = null;
|
||||
|
||||
public void readAttributes(Map<String, String> source) {
|
||||
readAttribute(XML_BASE, source);
|
||||
|
@ -36,15 +36,25 @@ abstract class ATOMCommonAttributes {
|
|||
protected final void readAttribute(String name, Map<String, String> source) {
|
||||
String value = source.get(name);
|
||||
if (value != null) {
|
||||
Attributes.put(name, value);
|
||||
if (myAttributes == null) {
|
||||
myAttributes = new TreeMap<String, String>();
|
||||
}
|
||||
myAttributes.put(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
public final String getAttribute(String name) {
|
||||
if (myAttributes == null) {
|
||||
return null;
|
||||
}
|
||||
return myAttributes.get(name);
|
||||
}
|
||||
|
||||
public final String getLang() {
|
||||
return Attributes.get(XML_LANG);
|
||||
return getAttribute(XML_LANG);
|
||||
}
|
||||
|
||||
public final String getBase() {
|
||||
return Attributes.get(XML_BASE);
|
||||
return getAttribute(XML_BASE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,10 +41,10 @@ public class ATOMGenerator extends ATOMCommonAttributes {
|
|||
}
|
||||
|
||||
public final String getUri() {
|
||||
return Attributes.get(URI);
|
||||
return getAttribute(URI);
|
||||
}
|
||||
|
||||
public final String getVersion() {
|
||||
return Attributes.get(VERSION);
|
||||
return getAttribute(VERSION);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,26 +43,26 @@ public class ATOMLink extends ATOMCommonAttributes {
|
|||
}
|
||||
|
||||
public final String getHref() {
|
||||
return Attributes.get(HREF);
|
||||
return getAttribute(HREF);
|
||||
}
|
||||
|
||||
public final String getRel() {
|
||||
return Attributes.get(REL);
|
||||
return getAttribute(REL);
|
||||
}
|
||||
|
||||
public final String getType() {
|
||||
return Attributes.get(TYPE);
|
||||
return getAttribute(TYPE);
|
||||
}
|
||||
|
||||
public final String getHrefLang() {
|
||||
return Attributes.get(HREFLANG);
|
||||
return getAttribute(HREFLANG);
|
||||
}
|
||||
|
||||
public final String getTitle() {
|
||||
return Attributes.get(TITLE);
|
||||
return getAttribute(TITLE);
|
||||
}
|
||||
|
||||
public final String getLength() {
|
||||
return Attributes.get(LENGTH);
|
||||
return getAttribute(LENGTH);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Geometer Plus <contact@geometerplus.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.zlibrary.core.network;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
public abstract class ZLNetworkRequest {
|
||||
|
||||
public final String Url;
|
||||
public String ErrorMessage;
|
||||
|
||||
private String myUserName;
|
||||
private String myPassword;
|
||||
private boolean myRedirectionSupported;
|
||||
|
||||
protected ZLNetworkRequest(String url) {
|
||||
Url = url;
|
||||
}
|
||||
|
||||
public final void setRedirectionSupported(boolean supported) {
|
||||
myRedirectionSupported = supported;
|
||||
}
|
||||
|
||||
public final void setupAuthentication(String userName, String password) {
|
||||
myUserName = userName;
|
||||
myPassword = password;
|
||||
}
|
||||
|
||||
protected abstract boolean handleStream(InputStream stream);
|
||||
}
|
|
@ -60,7 +60,7 @@ public abstract class ZLTree<T extends ZLTree> implements Iterable<T> {
|
|||
return mySubTrees;
|
||||
}
|
||||
|
||||
public final T getTree(int index) {
|
||||
public final T getTreeByParagraphNumber(int index) {
|
||||
if ((index < 0) || (index >= mySize)) {
|
||||
// TODO: throw exception?
|
||||
return null;
|
||||
|
@ -73,7 +73,7 @@ public abstract class ZLTree<T extends ZLTree> implements Iterable<T> {
|
|||
if (subtree.mySize <= index) {
|
||||
index -= subtree.mySize;
|
||||
} else {
|
||||
return (T)subtree.getTree(index);
|
||||
return (T)subtree.getTreeByParagraphNumber(index);
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("That's impossible!!!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue