1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-06 03:50:19 +02:00

code formatting style has been fixed

This commit is contained in:
Alexander Turkin 2012-09-11 00:37:58 +04:00
parent 5680ad3353
commit a8cdc40ca5
2 changed files with 68 additions and 68 deletions

View file

@ -25,15 +25,15 @@ import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.zlibrary.core.util.*;
public class ZLFileImage extends ZLSingleImage {
public static final String SCHEME = "imagefile";
public static final String SCHEME = "imagefile";
public static final String ENCODING_NONE = "";
public static final String ENCODING_HEX = "hex";
public static final String ENCODING_BASE64 = "base64";
public static final String ENCODING_NONE = "";
public static final String ENCODING_HEX = "hex";
public static final String ENCODING_BASE64 = "base64";
public static ZLFileImage byUrlPath(String urlPath) {
try {
final String[] data = urlPath.split("\000");
public static ZLFileImage byUrlPath(String urlPath) {
try {
final String[] data = urlPath.split("\000");
int count = Integer.parseInt(data[2]);
int[] offsets = new int[count];
int[] lengths = new int[count];
@ -41,21 +41,21 @@ public class ZLFileImage extends ZLSingleImage {
offsets[i] = Integer.parseInt(data[3 + i]);
lengths[i] = Integer.parseInt(data[3 + count + i]);
}
return new ZLFileImage(
MimeType.IMAGE_AUTO,
ZLFile.createFileByPath(data[0]),
data[1],
offsets,
lengths
);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
return new ZLFileImage(
MimeType.IMAGE_AUTO,
ZLFile.createFileByPath(data[0]),
data[1],
offsets,
lengths
);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private final ZLFile myFile;
private final String myEncoding;
private final ZLFile myFile;
private final String myEncoding;
private final int[] myOffsets;
private final int[] myLengths;
@ -70,12 +70,12 @@ public class ZLFileImage extends ZLSingleImage {
myOffsets = offsets;
myLengths = lengths;
}
public ZLFileImage(String mimeType, ZLFile file, String encoding, int offset, int length) {
this(MimeType.get(mimeType), file, encoding, offset, length);
}
public ZLFileImage(MimeType mimeType, ZLFile file, String encoding, int offset, int length) {
public ZLFileImage(String mimeType, ZLFile file, String encoding, int offset, int length) {
this(MimeType.get(mimeType), file, encoding, offset, length);
}
public ZLFileImage(MimeType mimeType, ZLFile file, String encoding, int offset, int length) {
super(mimeType);
myFile = file;
myEncoding = encoding != null ? encoding : ENCODING_NONE;
@ -83,13 +83,13 @@ public class ZLFileImage extends ZLSingleImage {
myLengths = new int[1];
myOffsets[0] = offset;
myLengths[0] = length;
}
}
public ZLFileImage(MimeType mimeType, ZLFile file) {
this(mimeType, file, ENCODING_NONE, 0, (int)file.size());
}
public ZLFileImage(MimeType mimeType, ZLFile file) {
this(mimeType, file, ENCODING_NONE, 0, (int)file.size());
}
public String getURI() {
public String getURI() {
String result = SCHEME + "://" + myFile.getPath() + "\000" + myEncoding + "\000" + myOffsets.length;
for (int offset : myOffsets) {
result += "\000" + offset;
@ -98,11 +98,11 @@ public class ZLFileImage extends ZLSingleImage {
result += "\000" + length;
}
return result;
}
}
@Override
public InputStream inputStream() {
try {
@Override
public InputStream inputStream() {
try {
final InputStream stream;
if (myOffsets.length == 1) {
final int offset = myOffsets[0];
@ -118,18 +118,18 @@ public class ZLFileImage extends ZLSingleImage {
stream = new MergedInputStream(streams);
}
if (ENCODING_NONE.equals(myEncoding)) {
return stream;
} else if (ENCODING_HEX.equals(myEncoding)) {
return new HexInputStream(stream);
} else if (ENCODING_BASE64.equals(myEncoding)) {
return new Base64InputStream(stream);
} else {
System.err.println("unsupported encoding: " + myEncoding);
return null;
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
return stream;
} else if (ENCODING_HEX.equals(myEncoding)) {
return new HexInputStream(stream);
} else if (ENCODING_BASE64.equals(myEncoding)) {
return new Base64InputStream(stream);
} else {
System.err.println("unsupported encoding: " + myEncoding);
return null;
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}

View file

@ -27,14 +27,14 @@ public class MergedInputStream extends InputStream {
private InputStream myCurrentStream;
private int myCurrentStreamNumber;
public MergedInputStream(InputStream[] streams) throws IOException {
public MergedInputStream(InputStream[] streams) throws IOException {
myStreams = streams;
myCurrentStream = streams[0];
myCurrentStreamNumber = 0;
}
@Override
public int read() throws IOException {
}
@Override
public int read() throws IOException {
int readed = -1;
boolean streamIsAvailable = true;
while (readed == -1 && streamIsAvailable) {
@ -44,10 +44,10 @@ public class MergedInputStream extends InputStream {
}
}
return readed;
}
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
@Override
public int read(byte[] b, int off, int len) throws IOException {
int bytesToRead = len;
int bytesReaded = 0;
boolean streamIsAvailable = true;
@ -63,10 +63,10 @@ public class MergedInputStream extends InputStream {
}
}
return bytesReaded == 0 ? -1 : bytesReaded;
}
}
@Override
public long skip(long n) throws IOException {
@Override
public long skip(long n) throws IOException {
long skipped = myCurrentStream.skip(n);
boolean streamIsAvailable = true;
while (skipped < n && streamIsAvailable) {
@ -76,25 +76,25 @@ public class MergedInputStream extends InputStream {
}
}
return skipped;
}
}
@Override
public int available() throws IOException {
@Override
public int available() throws IOException {
int total = 0;
for (int i = myCurrentStreamNumber; i < myStreams.length; ++i) {
for (int i = myCurrentStreamNumber; i < myStreams.length; ++i) {
total += myStreams[i].available();
}
return total;
}
}
@Override
public void reset() throws IOException {
@Override
public void reset() throws IOException {
myCurrentStream = myStreams[0];
myCurrentStreamNumber = 0;
for (InputStream stream : myStreams) {
stream.reset();
}
}
}
private boolean nextStream() {
if (myCurrentStreamNumber + 1 >= myStreams.length) {