Skip to content

Commit

Permalink
GH-79 nio object parser (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcorless authored May 8, 2023
1 parent 7e1721a commit ec88862
Show file tree
Hide file tree
Showing 532 changed files with 6,656 additions and 6,395 deletions.
8 changes: 4 additions & 4 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
## Supported Versions

| Version | Supported |
| ------- | ------------------ |
|---------|--------------------|
| 7.0.x | :white_check_mark: |
| < 6.3.2 | :x: |
| < 6.3.2 | :x: |

## Vulnerability Report

Currently now know threats or vulnernabilities in the library and dependencies.
Currently, no know threats or vulnerabilities in the library and dependencies.

This statement will be updated after each releaes to maven central.
This statement will be updated after each release to maven central.
Validated using Sonatype Lift
4 changes: 2 additions & 2 deletions core/core-awt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ publishing {
asNode().appendNode('url', 'https://github.com/pcorless/icepdf')
asNode().appendNode('scm')
.appendNode('connection', 'scm:git:https://github.com/pcorless/icepdf').parent()
.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt').parent()
.appendNode('url', 'https://www.apache.org/licenses/LICENSE-2.0.txt').parent()
.appendNode('tag', 'icepdf-' + version + '-maven')
asNode().appendNode('licenses').appendNode('license').with {
appendNode('name', 'Apache License, Version 2.0')
appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.html')
appendNode('url', 'https://www.apache.org/licenses/LICENSE-2.0.html')
appendNode('distribution', 'repo')
}
asNode().appendNode('issueManagement').with {
Expand Down
2 changes: 1 addition & 1 deletion core/core-awt/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.pcorless.icepdf</groupId>
Expand Down
5 changes: 0 additions & 5 deletions core/core-awt/src/main/java-templates/ProductInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,4 @@ public String getVersion(){
return info.toString();
}

public static void main(String[] args) {
ProductInfo app = new ProductInfo();
System.out.println( app.toString() );
}

}
2 changes: 1 addition & 1 deletion core/core-awt/src/main/java/org/icepdf/core/Memento.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ public interface Memento {
* Restore the state that was caputred when an instance of this object
* was created.
*/
public void restore();
void restore();
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ public interface SecurityCallback {
* @param document document being opened.
* @return received password.
*/
public String requestPassword(Document document);
String requestPassword(Document document);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
@SuppressWarnings("serial")
public class PageImageEvent extends PageInitializingEvent {

private int index;
private int total;
private long duration;
private final int index;
private final int total;
private final long duration;

/**
* Construct a new PageImageEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@SuppressWarnings("serial")
public class PageInitializingEvent extends java.util.EventObject {

private boolean interrupted;
private final boolean interrupted;

public PageInitializingEvent(Object source, boolean interrupted) {
super(source);
Expand Down
4 changes: 2 additions & 2 deletions core/core-awt/src/main/java/org/icepdf/core/io/BitStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class BitStream {
boolean readEOF;

// making value
private static final int masks[] = new int[32];
private static final int[] masks = new int[32];

static {
for (int i = 0; i < 32; i++) {
Expand Down Expand Up @@ -148,7 +148,7 @@ public int available() throws IOException {
return 1;
}

public void skipByte() throws IOException {
public void skipByte() {
bits_left = 0;
bits = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.icepdf.core.io;

import java.io.IOException;
import java.io.InputStream;

/**
Expand All @@ -35,9 +34,9 @@ public class ByteDoubleArrayInputStream extends InputStream {
* stream; element <code>buf[pos]</code> is
* the next byte to be read.
*/
protected byte buf[][];
protected final byte[][] buf;

protected int bufOffset[];
protected final int[] bufOffset;

/**
* The index of the next character to read from the input stream buffer.
Expand Down Expand Up @@ -89,7 +88,7 @@ public class ByteDoubleArrayInputStream extends InputStream {
*
* @param buf the input buffer.
*/
public ByteDoubleArrayInputStream(byte buf[][]) {
public ByteDoubleArrayInputStream(byte[][] buf) {
this.buf = buf;
this.pos = 0;
this.posIndex = 0;
Expand All @@ -116,13 +115,11 @@ public ByteDoubleArrayInputStream(byte buf[][]) {
public synchronized int read() {
float posOffset = bufOffset[posIndex] + pos;
if (posOffset < count) {
if (posOffset < bufOffset[posIndex] + buf[posIndex].length) {
return (buf[posIndex][pos++] & 0xff);
} else {
if (!(posOffset < bufOffset[posIndex] + buf[posIndex].length)) {
posIndex++;
pos = 0;
return (buf[posIndex][pos++] & 0xff);
}
return (buf[posIndex][pos++] & 0xff);
} else {
return -1;
}
Expand Down Expand Up @@ -153,7 +150,7 @@ public synchronized int read() {
* <code>-1</code> if there is no more data because the end of
* the stream has been reached.
*/
public synchronized int read(byte b[], int off, int len) {
public synchronized int read(byte[] b, int off, int len) {
if (b == null) {
throw new NullPointerException();
} else if ((off < 0) || (off > b.length) || (len < 0) ||
Expand Down Expand Up @@ -296,7 +293,7 @@ public synchronized void reset() {
* generating an <tt>IOException</tt>.
* <br>
*/
public void close() throws IOException {
public void close() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
*/
package org.icepdf.core.io;

import java.io.IOException;
import java.io.OutputStream;

/**
* @author Mark Collette
* @since 2.0
*/
public class ConservativeSizingByteArrayOutputStream extends OutputStream {
protected byte buf[];
protected byte[] buf;
protected int count;

/**
Expand Down Expand Up @@ -57,15 +56,15 @@ else if (buffer.length == 0)
count = 0;
}

public synchronized void write(int b) throws IOException {
public synchronized void write(int b) {
int newCount = count + 1;
if (newCount > buf.length)
resizeArrayToFit(newCount);
buf[count] = (byte) b;
count = newCount;
}

public synchronized void write(byte b[], int off, int len) throws IOException {
public synchronized void write(byte[] b, int off, int len) {
if ((off < 0) || (off >= b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
Expand All @@ -91,7 +90,7 @@ public synchronized void reset() {
* @return The current contents of this output stream, as a byte array.
*/
public synchronized byte[] toByteArray() {
byte newBuf[] = allocateByteArray(count);
byte[] newBuf = allocateByteArray(count);
System.arraycopy(buf, 0, newBuf, 0, count);
return newBuf;
}
Expand Down Expand Up @@ -129,11 +128,10 @@ public boolean trim() {
if (count == buf.length)
return true;

byte newBuf[] = allocateByteArray(count);
byte[] newBuf = allocateByteArray(count);
if (newBuf == null)
return false;
System.arraycopy(buf, 0, newBuf, 0, count);
buf = null;
buf = newBuf;
return true;
}
Expand Down Expand Up @@ -161,7 +159,7 @@ else if (steppedSize <= 2 * 1024 * 1024) {
}

int newBufSize = Math.max(steppedSize, newCount);
byte newBuf[] = allocateByteArray(newBufSize);
byte[] newBuf = allocateByteArray(newBufSize);
System.arraycopy(buf, 0, newBuf, 0, count);
buf = newBuf;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

public class CountingOutputStream extends OutputStream {
private OutputStream wrapped;
private final OutputStream wrapped;
private long count;

public CountingOutputStream(OutputStream wrap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RandomAccessFileInputStream extends InputStream implements Seekable
Logger.getLogger(RandomAccessFileInputStream.class.toString());

private long m_lMarkPosition;
private RandomAccessFile m_RandomAccessFile;
private final RandomAccessFile m_RandomAccessFile;

private final ReentrantLock lock = new ReentrantLock();

Expand Down Expand Up @@ -70,9 +70,7 @@ public int available() {
try {
return (int) (m_RandomAccessFile.getFilePointer());
} catch (IOException e) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.WARNING, "Error calling available", e);
}
logger.log(Level.WARNING, "Error calling available", e);
}
return 0;
}
Expand All @@ -95,7 +93,7 @@ public void reset() throws IOException {

public long skip(long n) throws IOException {
int nn = (int) (n);
return (long) m_RandomAccessFile.skipBytes(nn);
return m_RandomAccessFile.skipBytes(nn);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ public class SeekableByteArrayInputStream extends ByteArrayInputStream implement
private static final Logger log =
Logger.getLogger(SeekableByteArrayInputStream.class.toString());

private int m_iBeginningOffset;
private final int m_iBeginningOffset;

private final ReentrantLock lock = new ReentrantLock();

public SeekableByteArrayInputStream(byte buf[]) {
public SeekableByteArrayInputStream(byte[] buf) {
super(buf);
m_iBeginningOffset = 0;
}

public SeekableByteArrayInputStream(byte buf[], int offset, int length) {
public SeekableByteArrayInputStream(byte[] buf, int offset, int length) {
super(buf, offset, length);
m_iBeginningOffset = offset;
}
Expand Down Expand Up @@ -66,13 +66,11 @@ public void seekEnd() {
}

public long getAbsolutePosition() {
int absPos = pos - m_iBeginningOffset;
return (((long) absPos));
return pos - m_iBeginningOffset;
}

public long getLength() {
int len = count - m_iBeginningOffset;
return (((long) len));
return count - m_iBeginningOffset;
}

public InputStream getInputStream() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
* @since 2.0
*/
public class SeekableInputConstrainedWrapper extends InputStream {
private SeekableInput streamDataInput;
private long filePositionOfStreamData;
private long lengthOfStreamData;
private final SeekableInput streamDataInput;
private final long filePositionOfStreamData;
private final long lengthOfStreamData;
private long filePositionBeforeUse;
private boolean usedYet;

Expand Down Expand Up @@ -79,7 +79,7 @@ public int read(byte[] buffer, int offset, int length) throws IOException {

if (remain <= 0)
return -1;
length = (int) Math.min(Math.min(remain, (long) length), (long) Integer.MAX_VALUE);
length = (int) Math.min(Math.min(remain, length), Integer.MAX_VALUE);
return streamDataInput.read(buffer, offset, length);
}

Expand All @@ -94,15 +94,15 @@ public boolean markSupported() {
return false;
}

public void reset() throws IOException {
public void reset() {
}

public long skip(long n) throws IOException {
ensureReadyOnFirstUse();
long remain = getBytesRemaining();
if (remain <= 0)
return -1;
n = (int) Math.min(Math.min(remain, n), (long) Integer.MAX_VALUE);
n = (int) Math.min(Math.min(remain, n), Integer.MAX_VALUE);
return streamDataInput.skip(n);
}

Expand Down Expand Up @@ -137,13 +137,6 @@ public void seekEnd() throws IOException {
streamDataInput.seekAbsolute(filePositionOfStreamData + lengthOfStreamData);
}

public long getAbsolutePosition() throws IOException {
ensureReadyOnFirstUse();
long absolutePosition = getAbsolutePosition();
absolutePosition -= filePositionOfStreamData;
return absolutePosition;
}

public long getLength() {
return lengthOfStreamData;
}
Expand All @@ -166,7 +159,7 @@ public String toString() {
if (streamDataInput == null)
sb.append("null ");
else
sb.append(streamDataInput.toString());
sb.append(streamDataInput);
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public int read() throws IOException {
}
}

public int read(byte buffer[], int off, int len) throws IOException {
public int read(byte[] buffer, int off, int len) throws IOException {
if (buffer == null) {
throw new NullPointerException();
} else if ((off < 0) || (off >= buffer.length) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
*/
public class SizeInputStream extends InputStream {

private InputStream in = null;
private final InputStream in;

private int size = 0;
private final int size;

private int bytesRead = 0;

Expand Down
Loading

0 comments on commit ec88862

Please sign in to comment.