mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@27 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
4f07612cde
commit
3590d87c47
11 changed files with 84 additions and 106 deletions
|
@ -1,6 +0,0 @@
|
||||||
package org.zlibrary.model;
|
|
||||||
|
|
||||||
public abstract class ZLModelFactory {
|
|
||||||
public abstract ZLTextModel createModel();
|
|
||||||
public abstract ZLTextParagraph createParagraph();
|
|
||||||
}
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.zlibrary.model;
|
package org.zlibrary.model;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ZLTextModel {
|
public interface ZLTextModel {
|
||||||
public enum Kind {
|
public enum Kind {
|
||||||
PLAIN_TEXT_MODEL,
|
PLAIN_TEXT_MODEL,
|
||||||
|
@ -17,7 +15,7 @@ public interface ZLTextModel {
|
||||||
|
|
||||||
void addControl(byte textKind, boolean isStart);
|
void addControl(byte textKind, boolean isStart);
|
||||||
void addText(String text);
|
void addText(String text);
|
||||||
void addText(List<String> text);
|
void addText(StringBuffer text);
|
||||||
|
|
||||||
String dump();
|
String dump();
|
||||||
}
|
}
|
||||||
|
|
29
src/org/zlibrary/model/impl/ZLModelFactory.java
Normal file
29
src/org/zlibrary/model/impl/ZLModelFactory.java
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package org.zlibrary.model.impl;
|
||||||
|
|
||||||
|
import org.zlibrary.model.ZLTextModel;
|
||||||
|
import org.zlibrary.model.ZLTextParagraph;
|
||||||
|
import org.zlibrary.model.entry.ZLTextControlEntry;
|
||||||
|
import org.zlibrary.model.entry.ZLTextControlEntryPool;
|
||||||
|
import org.zlibrary.model.entry.ZLTextEntry;
|
||||||
|
|
||||||
|
public class ZLModelFactory {
|
||||||
|
public ZLTextModel createModel() {
|
||||||
|
return new ZLTextModelImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZLTextParagraph createParagraph() {
|
||||||
|
return new ZLTextParagraphImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZLTextControlEntry createControlEntry(byte kind, boolean isStart) {
|
||||||
|
return new ZLTextControlEntryImpl(kind, isStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZLTextEntry createTextEntry(String text) {
|
||||||
|
return new ZLTextEntryImpl(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZLTextControlEntryPool createControlEntryPool() {
|
||||||
|
return new ZLTextControlEntryPoolImpl();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,15 +0,0 @@
|
||||||
package org.zlibrary.model.impl;
|
|
||||||
|
|
||||||
import org.zlibrary.model.ZLTextModel;
|
|
||||||
import org.zlibrary.model.ZLTextParagraph;
|
|
||||||
import org.zlibrary.model.ZLModelFactory;
|
|
||||||
|
|
||||||
public class ZLModelFactoryImpl extends ZLModelFactory {
|
|
||||||
public ZLTextModel createModel() {
|
|
||||||
return new ZLTextModelImpl();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZLTextParagraph createParagraph() {
|
|
||||||
return new ZLTextParagraphImpl();
|
|
||||||
}
|
|
||||||
}
|
|
21
src/org/zlibrary/model/impl/ZLTextControlEntryImpl.java
Normal file
21
src/org/zlibrary/model/impl/ZLTextControlEntryImpl.java
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package org.zlibrary.model.impl;
|
||||||
|
|
||||||
|
import org.zlibrary.model.entry.ZLTextControlEntry;
|
||||||
|
|
||||||
|
class ZLTextControlEntryImpl implements ZLTextControlEntry {
|
||||||
|
private byte myKind;
|
||||||
|
private boolean myStart;
|
||||||
|
|
||||||
|
ZLTextControlEntryImpl(byte kind, boolean isStart) {
|
||||||
|
myKind = kind;
|
||||||
|
myStart = isStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getKind() {
|
||||||
|
return myKind;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStart() {
|
||||||
|
return myStart;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.zlibrary.model.impl.entry;
|
package org.zlibrary.model.impl;
|
||||||
|
|
||||||
import org.zlibrary.model.entry.ZLTextParagraphEntry;
|
import org.zlibrary.model.entry.ZLTextParagraphEntry;
|
||||||
import org.zlibrary.model.entry.ZLTextControlEntryPool;
|
import org.zlibrary.model.entry.ZLTextControlEntryPool;
|
||||||
|
@ -6,12 +6,12 @@ import org.zlibrary.model.entry.ZLTextControlEntryPool;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class ZLTextControlEntryPoolImpl implements ZLTextControlEntryPool {
|
class ZLTextControlEntryPoolImpl implements ZLTextControlEntryPool {
|
||||||
public static ZLTextControlEntryPoolImpl myPool;
|
public static ZLTextControlEntryPoolImpl myPool;
|
||||||
private Map<Byte, ZLTextParagraphEntry> myStartEntries;
|
private Map<Byte, ZLTextParagraphEntry> myStartEntries;
|
||||||
private Map<Byte, ZLTextParagraphEntry> myEndEntries;
|
private Map<Byte, ZLTextParagraphEntry> myEndEntries;
|
||||||
|
|
||||||
public ZLTextControlEntryPoolImpl() {
|
ZLTextControlEntryPoolImpl() {
|
||||||
myStartEntries = new HashMap<Byte, ZLTextParagraphEntry>();
|
myStartEntries = new HashMap<Byte, ZLTextParagraphEntry>();
|
||||||
myEndEntries = new HashMap<Byte, ZLTextParagraphEntry>();
|
myEndEntries = new HashMap<Byte, ZLTextParagraphEntry>();
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,5 @@ public class ZLTextControlEntryPoolImpl implements ZLTextControlEntryPool {
|
||||||
entry = new ZLTextControlEntryImpl(kind, isStart);
|
entry = new ZLTextControlEntryImpl(kind, isStart);
|
||||||
entries.put(kind, entry);
|
entries.put(kind, entry);
|
||||||
return entry;
|
return entry;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
20
src/org/zlibrary/model/impl/ZLTextEntryImpl.java
Normal file
20
src/org/zlibrary/model/impl/ZLTextEntryImpl.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package org.zlibrary.model.impl;
|
||||||
|
|
||||||
|
import org.zlibrary.model.entry.ZLTextEntry;
|
||||||
|
|
||||||
|
class ZLTextEntryImpl implements ZLTextEntry {
|
||||||
|
private String myData;
|
||||||
|
|
||||||
|
ZLTextEntryImpl(String data) {
|
||||||
|
myData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDataLength() {
|
||||||
|
return myData.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getData() {
|
||||||
|
return myData;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,18 +2,14 @@ package org.zlibrary.model.impl;
|
||||||
|
|
||||||
import org.zlibrary.model.ZLTextModel;
|
import org.zlibrary.model.ZLTextModel;
|
||||||
import org.zlibrary.model.ZLTextParagraph;
|
import org.zlibrary.model.ZLTextParagraph;
|
||||||
import org.zlibrary.model.impl.entry.ZLTextEntryImpl;
|
|
||||||
import org.zlibrary.model.impl.entry.ZLTextControlEntryPoolImpl;
|
|
||||||
import org.zlibrary.model.entry.ZLTextParagraphEntry;
|
import org.zlibrary.model.entry.ZLTextParagraphEntry;
|
||||||
import org.zlibrary.model.entry.ZLTextEntry;
|
import org.zlibrary.model.entry.ZLTextEntry;
|
||||||
import org.zlibrary.model.entry.ZLTextControlEntry;
|
import org.zlibrary.model.entry.ZLTextControlEntry;
|
||||||
import org.zlibrary.model.entry.ZLTextControlEntryPool;
|
import org.zlibrary.model.entry.ZLTextControlEntryPool;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
public class ZLTextModelImpl implements ZLTextModel {
|
class ZLTextModelImpl implements ZLTextModel {
|
||||||
private List<ZLTextParagraph> myParagraphs = new LinkedList<ZLTextParagraph>();
|
private LinkedList<ZLTextParagraph> myParagraphs = new LinkedList<ZLTextParagraph>();
|
||||||
private ZLTextControlEntryPool myEntryPool = new ZLTextControlEntryPoolImpl();
|
private ZLTextControlEntryPool myEntryPool = new ZLTextControlEntryPoolImpl();
|
||||||
|
|
||||||
public Kind getKind() {
|
public Kind getKind() {
|
||||||
|
@ -33,19 +29,16 @@ public class ZLTextModelImpl implements ZLTextModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addControl(byte textKind, boolean isStart) {
|
public void addControl(byte textKind, boolean isStart) {
|
||||||
myParagraphs.get(myParagraphs.size()-1).addEntry(myEntryPool.getControlEntry(textKind, isStart));
|
myParagraphs.getLast().addEntry(myEntryPool.getControlEntry(textKind, isStart));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addText(String text) {
|
public void addText(String text) {
|
||||||
myParagraphs.get(myParagraphs.size()-1).addEntry(new ZLTextEntryImpl(text));
|
myParagraphs.getLast().addEntry(new ZLTextEntryImpl(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addText(List<String> text) {
|
public void addText(StringBuffer text) {
|
||||||
ZLTextParagraph paragraph = myParagraphs.get(myParagraphs.size()-1);
|
ZLTextParagraph paragraph = myParagraphs.getLast();
|
||||||
StringBuilder sb = new StringBuilder();
|
paragraph.addEntry(new ZLTextEntryImpl(text.toString()));
|
||||||
for (String str: text)
|
|
||||||
sb.append(str);
|
|
||||||
paragraph.addEntry(new ZLTextEntryImpl(sb.toString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String dump() {
|
public String dump() {
|
||||||
|
|
|
@ -8,17 +8,11 @@ import java.util.List;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
class ZLTextParagraphImpl implements ZLTextParagraph {
|
||||||
* User: 465
|
|
||||||
* Date: 06.10.2007
|
|
||||||
* Time: 12:05:51
|
|
||||||
* To change this template use File | Settings | File Templates.
|
|
||||||
*/
|
|
||||||
public class ZLTextParagraphImpl implements ZLTextParagraph {
|
|
||||||
private List<ZLTextParagraphEntry> myEntries;
|
private List<ZLTextParagraphEntry> myEntries;
|
||||||
|
|
||||||
public ZLTextParagraphImpl() {
|
ZLTextParagraphImpl() {
|
||||||
myEntries = new LinkedList<ZLTextParagraphEntry>();
|
myEntries = new LinkedList<ZLTextParagraphEntry>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package org.zlibrary.model.impl.entry;
|
|
||||||
|
|
||||||
import org.zlibrary.model.entry.ZLTextControlEntry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: 465
|
|
||||||
* Date: 06.10.2007
|
|
||||||
* Time: 11:35:04
|
|
||||||
* To change this template use File | Settings | File Templates.
|
|
||||||
*/
|
|
||||||
public class ZLTextControlEntryImpl implements ZLTextControlEntry {
|
|
||||||
private byte myKind;
|
|
||||||
private boolean myStart;
|
|
||||||
|
|
||||||
public ZLTextControlEntryImpl(byte kind, boolean isStart) {
|
|
||||||
myKind = kind;
|
|
||||||
myStart = isStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getKind() {
|
|
||||||
return myKind;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isStart() {
|
|
||||||
return myStart;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package org.zlibrary.model.impl.entry;
|
|
||||||
|
|
||||||
import org.zlibrary.model.entry.ZLTextEntry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: 465
|
|
||||||
* Date: 06.10.2007
|
|
||||||
* Time: 11:29:13
|
|
||||||
* To change this template use File | Settings | File Templates.
|
|
||||||
*/
|
|
||||||
public class ZLTextEntryImpl implements ZLTextEntry {
|
|
||||||
private String myData;
|
|
||||||
|
|
||||||
public ZLTextEntryImpl(String data) {
|
|
||||||
myData = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDataLength() {
|
|
||||||
return myData.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getData() {
|
|
||||||
return myData;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue