Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Oct 9, 2024
1 parent d8fec7c commit 678e621
Show file tree
Hide file tree
Showing 26 changed files with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public byte bufferPop() {
*/
public int bufferPopArray(byte[] buffer, int read) throws IOException {
int actualRead = Math.min(read, bufferSize());
if(actualRead == -1) {
if (actualRead == -1) {
return -1;
}
if (buffer.length < actualRead) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public COSFilterASCIIReader(ASInputStream stream, boolean isASCIIHex) {
this.isASCIIHex = isASCIIHex;
this.buf = new byte[ASBufferedInFilter.BF_BUFFER_SIZE];
bufPointer = 0;
if(buf[0] == '<' && buf[1] == '~') { //Skipping leading <~
if (buf[0] == '<' && buf[1] == '~') { //Skipping leading <~
bufPointer += 2;
}
isEOD = false;
Expand Down Expand Up @@ -186,7 +186,7 @@ private byte readByte() throws IOException {
}

private void processCaseOfZ(byte[] fiveBytes, int i) {
for(int j = i; j < 5; ++j) {
for (int j = i; j < 5; ++j) {
fiveBytes[j] = EXCLAM_MARK;
}
ascii85ZeroRemains = i;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/verapdf/cos/COSArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected COSArray(final int size) {
this.entries = new ArrayList<>(size);
}

public COSArray(List<COSObject> values){
public COSArray(List<COSObject> values) {
super();
this.entries = new ArrayList<>();
this.entries.addAll(values);
Expand Down Expand Up @@ -197,7 +197,7 @@ public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if(obj instanceof COSObject) {
if (obj instanceof COSObject) {
return this.equals(((COSObject) obj).get());
}
if (getClass() != obj.getClass()) {
Expand All @@ -216,7 +216,7 @@ boolean equals(Object obj, List<COSBasePair> checkedObjects) {
if (obj == null) {
return false;
}
if(obj instanceof COSObject) {
if (obj instanceof COSObject) {
return this.equals(((COSObject) obj).get());
}
if (COSBasePair.listContainsPair(checkedObjects, this, (COSBase) obj)) {
Expand Down Expand Up @@ -250,7 +250,7 @@ public ASInputStream getData(final COSStream.FilterFlags flags) {
}
}
} catch (Exception any) {
for(ASInputStream stream : streams) {
for (ASInputStream stream : streams) {
try {
stream.close();
} catch (IOException e) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/verapdf/cos/COSDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,13 @@ public Collection<COSObject> getValues() {

@Override
public boolean equals(Object obj) {
if(this == obj) {
if (this == obj) {
return true;
}
if(obj == null) {
if (obj == null) {
return false;
}
if(obj instanceof COSObject) {
if (obj instanceof COSObject) {
return this.equals(((COSObject) obj).get());
}
List<COSBasePair> checkedObjects = new LinkedList<>();
Expand All @@ -322,7 +322,7 @@ boolean equals(Object obj, List<COSBasePair> checkedObjects) {
if (obj == null) {
return false;
}
if(obj instanceof COSObject) {
if (obj instanceof COSObject) {
return this.equals(((COSObject) obj).get());
}
if (COSBasePair.listContainsPair(checkedObjects, this, (COSBase) obj)) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/verapdf/cos/COSFilters.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public COSFilters(final COSObject object) {
public ASInputStream getInputStream(ASInputStream inputStream,
COSObject decodeParams) throws IOException {
List<COSDictionary> decodeParameters = null;
if(!decodeParams.empty()) {
if(decodeParams.getType() == COSObjType.COS_DICT) {
if (!decodeParams.empty()) {
if (decodeParams.getType() == COSObjType.COS_DICT) {
decodeParameters = new ArrayList<>(1);
decodeParameters.add((COSDictionary) decodeParams.getDirectBase());
} else if (decodeParams.getType() == COSObjType.COS_ARRAY) {
decodeParameters = new ArrayList<>(decodeParams.size());
for(int i = 0; i < decodeParams.size(); ++i) {
for (int i = 0; i < decodeParams.size(); ++i) {
COSObjType paramsType = decodeParams.at(i).getType();
if (decodeParams.at(i).empty() || paramsType == COSObjType.COS_NULL) {
decodeParameters.add((COSDictionary) COSDictionary.construct().get());
Expand All @@ -74,7 +74,7 @@ public ASInputStream getInputStream(ASInputStream inputStream,
}
if (decodeParameters == null) {
decodeParameters = new ArrayList<>(entries.size());
for(int i = 0; i < entries.size(); ++i) {
for (int i = 0; i < entries.size(); ++i) {
decodeParameters.add((COSDictionary) COSDictionary.construct().get());
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ protected void updateToObject() {
@Override
protected void updateFromObject() {
COSObject filters = getObject();
if(filters.getType() == COSObjType.COS_ARRAY) {
if (filters.getType() == COSObjType.COS_ARRAY) {
int size = filters.size();

this.entries.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/verapdf/cos/COSObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public Boolean getBoolean() {
}

public void setBoolean(final boolean value) {
if(this.base == null || !this.base.setBoolean(value)) {
if (this.base == null || !this.base.setBoolean(value)) {
this.base = new COSBoolean(value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public int read(byte[] buffer, int size) throws IOException {
*/
@Override
public int read(byte[] buffer, int off, int size) throws IOException {
if(this.bufferSize() == 0) {
if (this.bufferSize() == 0) {
int bytesFed = this.feedBuffer(getBufferCapacity());
if (bytesFed == -1) {
return -1;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/verapdf/parser/PDFParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ private void checkXrefTableEntryLastBytes() throws IOException {
isLastBytesCorrect = false;
}

if (!isLastBytesCorrect){
if (!isLastBytesCorrect) {
this.getSource().unread();
LOGGER.log(Level.WARNING, getErrorMessage("Incorrect end of line in cross-reference table"));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/verapdf/parser/SignatureParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void parseDictionary()
if (c == '>') {
done = true;
} else {
if(parseSignatureNameValuePair()) {
if (parseSignatureNameValuePair()) {
done = true;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/verapdf/pd/PDAnnotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public String getTU() {
return getStringKey(ASAtom.TU);
}

public COSObject getParent(){
public COSObject getParent() {
COSObject res = getKey(ASAtom.PARENT);
if (res != null && res.getType() == COSObjType.COS_DICT) {
return res;
Expand Down Expand Up @@ -108,15 +108,15 @@ public double[] getRect() {
return TypeConverter.getRealArray(getKey(ASAtom.RECT), 4, "Rect");
}

public COSObject getCOSC(){
public COSObject getCOSC() {
COSObject res = getKey(ASAtom.C);
if (res != null && res.getType() == COSObjType.COS_ARRAY) {
return res;
}
return null;
}

public COSObject getCOSIC(){
public COSObject getCOSIC() {
COSObject res = getKey(ASAtom.IC);
if (res != null && res.getType() == COSObjType.COS_ARRAY) {
return res;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/verapdf/pd/PDPageTreeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public PDPageTreeBranch findTerminal(int index) {
}

public PDPage findTerminalPDPage(int index) {
if(parent == null) {
if (parent == null) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/verapdf/pd/colors/PDDeviceRGB.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public ASAtom getType() {
@Override
public double[] toRGB(double[] value) {
float[] rgb = new float[value.length];
for (int i = 0; i < value.length; ++i){
for (int i = 0; i < value.length; ++i) {
rgb[i] = (float) value[i];
}
rgb = colorSpaceRGB.toRGB(rgb);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/verapdf/pd/encryption/PDCryptFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public PDCryptFilter(COSObject obj) {
*/
public ASAtom getMethod() {
COSObject obj = getKey(ASAtom.CFM);
if(obj != null && obj.getType() == COSObjType.COS_NAME) {
if (obj != null && obj.getType() == COSObjType.COS_NAME) {
return obj.getName();
}
return ASAtom.NONE;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/verapdf/pd/font/PDSimpleFont.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public PDSimpleFont(COSDictionary dictionary) {
public String toUnicode(int code) {

String unicodeString = super.toUnicode(code);
if(unicodeString != null) {
if (unicodeString != null) {
return unicodeString;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ class CFFCharStringsHandler {
} else {
this.fontStream = fontStream;
this.charStringsOffsets = new long[charStrings.size() + 1];
for(int i = 0; i < charStrings.size() + 1; ++i) {
for (int i = 0; i < charStrings.size() + 1; ++i) {
this.charStringsOffsets[i] = charStringsOffset +
charStrings.getOffsetShift() + charStrings.getOffset(i) - 1;
}
}
}

byte[] getCharString(int num) throws IOException {
if(num >= 0 && num < this.amount) {
if (num >= 0 && num < this.amount) {
if (memoryInCharStirngs != null) {
return memoryInCharStirngs.get(num);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ public Double getDescent() {
*/
@Override
public float getWidth(int charCode) {
if(externalCMap != null) {
if (externalCMap != null) {
int gid = this.externalCMap.toCID(charCode);
float res = this.widths.getWidth(gid);
if(res != -1.) {
if (res != -1.) {
return res;
} else {
return this.widths.getWidth(0);
Expand Down Expand Up @@ -327,7 +327,7 @@ private void initializeCharSet(String[] charSetArray) {
public String[] getEncoding() {
if (this.encodingStrings == null) {
this.encodingStrings = new String[256];
for(int i = 0; i < 256; ++i) {
for (int i = 0; i < 256; ++i) {
String glyphName = inverseCharSet.get(encoding[i]);
this.encodingStrings[i] =
glyphName == null ? NOTDEF_STRING : glyphName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected boolean processNextOperator(int nextByte) throws IOException {

private boolean execSubr(CFFIndex subrs, int bias) throws IOException {
int subrNum = (int) this.stack.pop().getInteger();
if(subrs.size() > Math.max(subrNum + bias, 0)) {
if (subrs.size() > Math.max(subrNum + bias, 0)) {
byte[] subr = subrs.get(subrNum + bias);
ASMemoryInStream subrStream = new ASMemoryInStream(subr, subr.length, false);
addStream(subrStream);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/verapdf/pd/font/cmap/CMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ void addUnicodeMapping(int code, String toUnicodeMap) {
*/
public String getUnicode(int code) {
String res = this.toUnicode.get(code);
if(res == null) {
for(ToUnicodeInterval interval : this.unicodeIntervals) {
if(interval.containsCode(code)) {
if (res == null) {
for (ToUnicodeInterval interval : this.unicodeIntervals) {
if (interval.containsCode(code)) {
return interval.toUnicode(code);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/verapdf/pd/font/cmap/NotDefInterval.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class NotDefInterval extends CIDInterval {
*/
@Override
public int getCID(int character) {
if(!contains(character)) {
if (!contains(character)) {
return -1;
}
return startingCID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SingleCIDMapping implements CIDMappable {

@Override
public int getCID(int character) {
if(character != from) {
if (character != from) {
return -1;
}
return to;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ private void readTrimmedTableMapping(TrueTypeCmapSubtable cmap) throws IOExcepti
* Gets the gid for given code from any of the cmap subtables.
*/
public int getGID(int code) {
for(TrueTypeCmapSubtable ttcs : cmapInfos) {
if(ttcs.containsCID(code)) {
for (TrueTypeCmapSubtable ttcs : cmapInfos) {
if (ttcs.containsCID(code)) {
return ttcs.getGlyph(code);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/verapdf/pd/font/type1/PDType1Font.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private boolean isNameStandard() {
*/
public String toUnicodePDFA1(int code) {
String unicodeString = super.cMapToUnicode(code);
if(unicodeString != null) {
if (unicodeString != null) {
return unicodeString;
}
Encoding fontEncoding = this.getEncodingMapping();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/verapdf/pd/function/PDFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ public Long getFunctionType() {
return getObject().getIntegerKey(ASAtom.FUNCTION_TYPE);
}

public COSArray getCOSArray(final ASAtom key){
public COSArray getCOSArray(final ASAtom key) {
COSObject obj = this.getKey(key);
return obj == null ? null : (COSArray) obj.getDirectBase();
}

public COSArray getDomain(){
public COSArray getDomain() {
return getCOSArray(ASAtom.DOMAIN);
}

public COSArray getRange(){
public COSArray getRange() {
return getCOSArray(ASAtom.RANGE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public String[] getGroupNames() {
int size = ocgsArray.size();
String[] groups = new String[size];

for(int i = 0; i < size; ++i) {
for (int i = 0; i < size; ++i) {
COSObject obj = ocgs.at(i);
if (!obj.empty() && obj.getType() == COSObjType.COS_DICT) {
COSDictionary ocgDict = (COSDictionary) obj.getDirectBase();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/verapdf/tools/TaggedPDFConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public final class TaggedPDFConstants {
public static final String STRONG = "Strong";
public static final String ARTIFACT = "Artifact";

private TaggedPDFConstants(){
private TaggedPDFConstants() {
//disable default constructor
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void testGetResult(@ConvertWith(PDFunctionTestHelper.ListOfCOSObjectsConv
func.setOperators(operators);
List<COSObject> actualResult = func.getResult(operands);
Assertions.assertEquals(result.size(), actualResult.size());
for (int i = 0; i < result.size(); ++i){
for (int i = 0; i < result.size(); ++i) {
Assertions.assertEquals(result.get(i).getReal(), actualResult.get(i).getReal(), EPSILON);
}
}
Expand Down

0 comments on commit 678e621

Please sign in to comment.