Skip to content

Commit

Permalink
(#49) Fixes to pass in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriciofx committed Dec 26, 2023
1 parent 2a5477f commit bfa802b
Show file tree
Hide file tree
Showing 51 changed files with 1,492 additions and 640 deletions.
20 changes: 7 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<useIncrementalCompilation>false</useIncrementalCompilation>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -126,16 +125,6 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
Expand Down Expand Up @@ -204,6 +193,11 @@
<configuration>
<excludes combine.children="append">
<exclude>checkstyle:/src/site/resources/.*</exclude>
<exclude>checkstyle:/src/test/resources/.*</exclude>
<exclude>checkstyle:/src/*/.DS_Store</exclude>
<exclude>checkstyle:/src/test/.DS_Store</exclude>
<exclude>checkstyle:/src/main/.DS_Store</exclude>
<exclude>checkstyle:/src/main/resources/logging.properties</exclude>
<exclude>findbugs:.*</exclude>
</excludes>
</configuration>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/github/fabriciofx/cactoos/pdf/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public Reference reference() {
return new Reference(this.number, this.generation);
}

/**
* Build a dictionary.
*
* @return A dictionary
* @throws Exception if fails
*/
public Dictionary dictionary() throws Exception {
return new Dictionary()
.add("Type", new Name("Catalog"))
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/github/fabriciofx/cactoos/pdf/Content.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ public interface Content extends Object, Bytes {
*/
byte[] stream() throws Exception;

/**
* Build an object {@link Dictionary}.
*
* @return A dictionary
* @throws Exception if fails
*/
Dictionary dictionary() throws Exception;
}
60 changes: 56 additions & 4 deletions src/main/java/com/github/fabriciofx/cactoos/pdf/Flow.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,89 @@

import java.io.ByteArrayInputStream;

/**
* Flow.
*
* @since 0.0.1
* @checkstyle BooleanExpressionComplexityCheck (150 lines)
*/
public final class Flow {
/**
* A stream of bytes.
*/
private final ByteArrayInputStream stream;

/**
* Ctor.
*
* @param bytes An array of bytes
*/
public Flow(final byte[] bytes) {
this(new ByteArrayInputStream(bytes));
}

/**
* Ctor.
*
* @param stream A stream of bytes
*/
public Flow(final ByteArrayInputStream stream) {
this.stream = stream;
}

/**
* Read length bytes and return a String contains these bytes.
*
* @param length Amount of bytes to read
* @return The String
* @throws Exception if fails
*/
public String asString(final int length) throws Exception {
return new String(this.stream.readNBytes(length));
}

/**
* Read length bytes and return an array of bytes.
*
* @param length Amount of bytes to read
* @return An array of bytes
* @throws Exception if fails
*/
public byte[] asBytes(final int length) throws Exception {
return this.stream.readNBytes(length);
}

/**
* Read length bytes and return an integer that represents these bytes.
*
* @return An integer number
* @throws Exception if fails
*/
public int asInt() throws Exception {
final byte[] bytes = this.asBytes(4);
return ((bytes[0] & 0xFF) << 24) |
((bytes[1] & 0xFF) << 16) |
((bytes[2] & 0xFF) << 8) |
(bytes[3] & 0xFF);
return ((bytes[0] & 0xFF) << 24)
| ((bytes[1] & 0xFF) << 16)
| ((bytes[2] & 0xFF) << 8)
| (bytes[3] & 0xFF);
}

/**
* Read a unique byte.
*
* @return A byte
* @throws Exception if fails
*/
public byte asByte() throws Exception {
return this.asBytes(1)[0];
}

/**
* Skip length bytes.
*
* @param length Amount of bytes to skip
* @return Amount of skiped bytes
* @throws Exception if fails
*/
public long skip(final int length) throws Exception {
return this.stream.skip(length);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

import java.util.Map;
import org.cactoos.Bytes;
import org.cactoos.text.FormattedText;
import org.cactoos.text.UncheckedText;

/**
* Document Information Dictionary.
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/github/fabriciofx/cactoos/pdf/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public interface Page extends Object {
*
* @param parent Pages parent
* @return The page dictionary
* @throws Exception if fails
*/
Dictionary dictionary(Pages parent) throws Exception;

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/github/fabriciofx/cactoos/pdf/Pages.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,11 @@ public interface Pages extends Object, Bytes {
*/
void add(Page page);

/**
* Build a {@link Dictionary}.
*
* @return A Dictionary
* @throws Exception if fails
*/
Dictionary dictionary() throws Exception;
}
46 changes: 35 additions & 11 deletions src/main/java/com/github/fabriciofx/cactoos/pdf/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,53 @@
import org.cactoos.Text;
import org.cactoos.text.FormattedText;

/**
* Reference.
*
* @since 0.0.1
*/
public final class Reference implements Text {
private final int number;
private final int generation;
/**
* Serial number.
*/
private final int num;

/**
* Generation number.
*/
private final int gen;

/**
* Ctor.
*
* @param number Serial number
* @param generation Generation number
*/
public Reference(final int number, final int generation) {
this.number = number;
this.generation = generation;
this.num = number;
this.gen = generation;
}

/**
* Object number.
*
* @return Object number
*/
public int number() {
return this.number;
return this.num;
}

/**
* Object generation.
*
* @return Object generation
*/
public int generation() {
return this.generation;
return this.gen;
}

@Override
public String asString() throws Exception {
return new FormattedText(
"%d %d R",
this.number,
this.generation
).asString();
return new FormattedText("%d %d R", this.num, this.gen).asString();
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/github/fabriciofx/cactoos/pdf/Resource.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,11 @@
*/
@SuppressWarnings("PMD.ExtendsObject")
public interface Resource extends Bytes {
/**
* Build a {@link Dictionary}.
*
* @return A Dictionary
* @throws Exception if fails
*/
Dictionary dictionary() throws Exception;
}
31 changes: 31 additions & 0 deletions src/main/java/com/github/fabriciofx/cactoos/pdf/Type.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
/*
* The MIT License (MIT)
*
* Copyright (C) 2023 Fabrício Barros Cabral
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.fabriciofx.cactoos.pdf;

import org.cactoos.Bytes;
import org.cactoos.Scalar;
import org.cactoos.Text;

/**
* Type.
*
* <p>There is no thread-safety guarantee.
*
* @param <T> The value of type.
* @since 0.0.1
*/
public interface Type<T> extends Scalar<T>, Text, Bytes {
}
Loading

0 comments on commit bfa802b

Please sign in to comment.