Skip to content

Commit

Permalink
Merge pull request #618 from veraPDF/refactoring
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
MaximPlusov authored and Git User committed Dec 11, 2023
1 parent 794f551 commit 775ee14
Show file tree
Hide file tree
Showing 112 changed files with 290 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public final class GFFeatureParser {
private static final String DEVICERGB_ID = "devrgb";
private static final String DEVICECMYK_ID = "devcmyk";

private FeaturesReporter reporter;
private FeatureExtractorConfig config;
private Set<String> processedIDs;
private final FeaturesReporter reporter;
private final FeatureExtractorConfig config;
private final Set<String> processedIDs;

private GFFeatureParser(FeaturesReporter reporter, FeatureExtractorConfig config) {
this.reporter = reporter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
*/
public class GFAnnotationFeaturesObjectAdapter implements AnnotationFeaturesObjectAdapter {

private String id;
private String popupId;
private Set<String> formXObjects;
private PDAnnotation annot;
private final String id;
private final String popupId;
private final Set<String> formXObjects;
private final PDAnnotation annot;

/**
* Constructs new Annotation Feature Object Adapter
Expand Down Expand Up @@ -68,7 +68,7 @@ public String getPopupId() {

@Override
public Set<String> getFormXObjectsResources() {
return formXObjects == null ? Collections.<String>emptySet() : Collections.unmodifiableSet(formXObjects);
return formXObjects == null ? Collections.emptySet() : Collections.unmodifiableSet(formXObjects);
}

@Override
Expand Down Expand Up @@ -158,6 +158,6 @@ public boolean isPDFObjectPresent() {

@Override
public List<String> getErrors() {
return Collections.<String>emptyList();
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public class GFColorSpaceFeaturesObjectAdapter implements ColorSpaceFeaturesObje

private static final Logger LOGGER = Logger.getLogger(GFColorSpaceFeaturesObjectAdapter.class.getCanonicalName());

private PDColorSpace colorSpace;
private String id;
private String iccProfileChild;
private String colorSpaceChild;
private final PDColorSpace colorSpace;
private final String id;
private final String iccProfileChild;
private final String colorSpaceChild;
private String lookup;
private List<String> errors;

Expand Down Expand Up @@ -76,9 +76,7 @@ private void init(PDColorSpace colorSpace) {
PDIndexed index = (PDIndexed) colorSpace;
try (InputStream stream = index.getLookup()) {
byte[] lookupData = GFAdapterHelper.inputStreamToByteArray(stream);
if (lookupData != null) {
this.lookup = DatatypeConverter.printHexBinary(lookupData);
}
this.lookup = DatatypeConverter.printHexBinary(lookupData);
} catch (IOException e) {
LOGGER.log(Level.FINE, e.getMessage(), e);
this.errors = new ArrayList<>();
Expand Down Expand Up @@ -258,6 +256,6 @@ public boolean isPDFObjectPresent() {

@Override
public List<String> getErrors() {
return this.errors == null ? Collections.<String>emptyList() : Collections.unmodifiableList(this.errors);
return this.errors == null ? Collections.emptyList() : Collections.unmodifiableList(this.errors);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
public class GFDocSecurityFeaturesObjectAdapter implements DocSecurityFeaturesObjectAdapter {

private PDEncryption encryption;
private final PDEncryption encryption;

public GFDocSecurityFeaturesObjectAdapter(PDEncryption encryption) {
this.encryption = encryption;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
*/
public class GFEmbeddedFileFeaturesObjectAdapter implements EmbeddedFileFeaturesObjectAdapter {

private COSObject embFile;
private final COSObject embFile;
private Params params;
private COSObject cosEmbFile;
private int index;
private final COSObject cosEmbFile;
private final int index;

/**
* Constructs new Embedded File Feature Object Adapter
Expand Down Expand Up @@ -139,7 +139,7 @@ public String getFilter() {
for (COSObject elem : (COSArray) filter.getDirectBase()) {
String elemValue = elem.getString();
if (elemValue != null) {
builder.append(elemValue).append(" ");
builder.append(elemValue).append(' ');
}
}
return builder.toString().trim();
Expand Down Expand Up @@ -184,9 +184,9 @@ public List<String> getErrors() {
return Collections.emptyList();
}

private class Params {
private static class Params {

private COSObject obj;
private final COSObject obj;

public Params(COSObject obj) {
this.obj = obj;
Expand All @@ -211,8 +211,7 @@ public Long getSize() {
private Calendar getDate(ASAtom type) {
String date = obj.getStringKey(type);
if (date != null) {
Calendar dateCal = TypeConverter.parseDate(date);
return dateCal;
return TypeConverter.parseDate(date);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
*/
public class GFExtGStateFeaturesObjectAdapter implements ExtGStateFeaturesObjectAdapter {

private PDExtGState exGState;
private String id;
private String fontChildID;
private final PDExtGState exGState;
private final String id;
private final String fontChildID;

/**
* Constructs new extended graphics state feature object adapter
Expand Down Expand Up @@ -66,7 +66,7 @@ public String getFontChildId() {
public Boolean getTransparency() {
if (exGState != null && !exGState.empty()) {
Boolean res = exGState.getAlphaSourceFlag();
return res == null ? null : !res.booleanValue();
return res == null ? null : !res;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
*/
public class GFFontFeaturesObjectAdapter implements FontFeaturesObjectAdapter {

private org.verapdf.pd.font.PDFont font;
private String id;
private Set<String> extGStateChild;
private Set<String> colorSpaceChild;
private Set<String> patternChild;
private Set<String> shadingChild;
private Set<String> xobjectChild;
private Set<String> fontChild;
private Set<String> propertiesChild;
private final org.verapdf.pd.font.PDFont font;
private final String id;
private final Set<String> extGStateChild;
private final Set<String> colorSpaceChild;
private final Set<String> patternChild;
private final Set<String> shadingChild;
private final Set<String> xobjectChild;
private final Set<String> fontChild;
private final Set<String> propertiesChild;
private FontDescriptorAdapter fontDescriptorAdapter;

public GFFontFeaturesObjectAdapter(org.verapdf.pd.font.PDFont font, String id, Set<String>
Expand Down Expand Up @@ -82,43 +82,43 @@ public String getId() {
@Override
public Set<String> getExtGStateChild() {
return this.extGStateChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.extGStateChild);
Collections.emptySet() : Collections.unmodifiableSet(this.extGStateChild);
}

@Override
public Set<String> getColorSpaceChild() {
return this.colorSpaceChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.colorSpaceChild);
Collections.emptySet() : Collections.unmodifiableSet(this.colorSpaceChild);
}

@Override
public Set<String> getPatternChild() {
return this.patternChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.patternChild);
Collections.emptySet() : Collections.unmodifiableSet(this.patternChild);
}

@Override
public Set<String> getShadingChild() {
return this.shadingChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.shadingChild);
Collections.emptySet() : Collections.unmodifiableSet(this.shadingChild);
}

@Override
public Set<String> getXObjectChild() {
return this.xobjectChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.xobjectChild);
Collections.emptySet() : Collections.unmodifiableSet(this.xobjectChild);
}

@Override
public Set<String> getFontChild() {
return this.fontChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.fontChild);
Collections.emptySet() : Collections.unmodifiableSet(this.fontChild);
}

@Override
public Set<String> getPropertiesChild() {
return this.propertiesChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.propertiesChild);
Collections.emptySet() : Collections.unmodifiableSet(this.propertiesChild);
}

@Override
Expand Down Expand Up @@ -272,7 +272,7 @@ public List<String> getErrors() {

private static class GFFontDescriptorAdapter implements FontDescriptorAdapter {

private PDFontDescriptor descriptor;
private final PDFontDescriptor descriptor;
private COSStream file;
private PDMetadata metadata;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@
*/
public class GFFormXObjectFeaturesObjectAdapter implements FormXObjectFeaturesObjectAdapter {

private PDXForm formXObject;
private String id;
private String groupColorSpaceChild;
private Set<String> extGStateChild;
private Set<String> colorSpaceChild;
private Set<String> patternChild;
private Set<String> shadingChild;
private Set<String> xobjectChild;
private Set<String> fontChild;
private Set<String> propertiesChild;
private final PDXForm formXObject;
private final String id;
private final String groupColorSpaceChild;
private final Set<String> extGStateChild;
private final Set<String> colorSpaceChild;
private final Set<String> patternChild;
private final Set<String> shadingChild;
private final Set<String> xobjectChild;
private final Set<String> fontChild;
private final Set<String> propertiesChild;

/**
* Constructs new form xobject features object
Expand Down Expand Up @@ -101,43 +101,43 @@ public String getGroupColorSpaceChild() {
@Override
public Set<String> getExtGStateChild() {
return this.extGStateChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.extGStateChild);
Collections.emptySet() : Collections.unmodifiableSet(this.extGStateChild);
}

@Override
public Set<String> getColorSpaceChild() {
return this.colorSpaceChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.colorSpaceChild);
Collections.emptySet() : Collections.unmodifiableSet(this.colorSpaceChild);
}

@Override
public Set<String> getPatternChild() {
return this.patternChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.patternChild);
Collections.emptySet() : Collections.unmodifiableSet(this.patternChild);
}

@Override
public Set<String> getShadingChild() {
return this.shadingChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.shadingChild);
Collections.emptySet() : Collections.unmodifiableSet(this.shadingChild);
}

@Override
public Set<String> getXObjectChild() {
return this.xobjectChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.xobjectChild);
Collections.emptySet() : Collections.unmodifiableSet(this.xobjectChild);
}

@Override
public Set<String> getFontChild() {
return this.fontChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.fontChild);
Collections.emptySet() : Collections.unmodifiableSet(this.fontChild);
}

@Override
public Set<String> getPropertiesChild() {
return this.propertiesChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.propertiesChild);
Collections.emptySet() : Collections.unmodifiableSet(this.propertiesChild);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public class GFICCProfileFeaturesObjectAdapter implements ICCProfileFeaturesObje
private static final int VERSION_BYTE = 8;
private static final int SUBVERSION_BYTE = 9;

private ICCProfile profile;
private String id;
private final ICCProfile profile;
private final String id;
private String version;
private String cmmType;
private String dataColorSpace;
Expand Down Expand Up @@ -113,7 +113,7 @@ private static String getVersion(byte[] header) {
return null;
}
StringBuilder builder = new StringBuilder();
builder.append(header[VERSION_BYTE] & FF_FLAG).append(".");
builder.append(header[VERSION_BYTE] & FF_FLAG).append('.');
builder.append((header[SUBVERSION_BYTE] & FF_FLAG) >>> REQUIRED_LENGTH);
return builder.toString();
}
Expand Down Expand Up @@ -185,7 +185,7 @@ public boolean isPDFObjectPresent() {

@Override
public List<String> getErrors() {
return errors == null ? Collections.<String>emptyList() : Collections.unmodifiableList(errors);
return errors == null ? Collections.emptyList() : Collections.unmodifiableList(errors);
}

@Override
Expand Down Expand Up @@ -228,9 +228,9 @@ public List<Double> getRange() {
} else {
Integer n = getN();
if (n != null) {
for (int i = 0; i < n.intValue(); ++i) {
range.add(Double.valueOf(0.));
range.add(Double.valueOf(1.));
for (int i = 0; i < n; ++i) {
range.add(0.);
range.add(1.);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
*/
public class GFImageXObjectFeaturesObjectAdapter implements ImageXObjectFeaturesObjectAdapter {

private PDXImage imageXObject;
private String id;
private String colorSpaceChild;
private String maskChild;
private String sMaskChild;
private Set<String> alternatesChild;
private final PDXImage imageXObject;
private final String id;
private final String colorSpaceChild;
private final String maskChild;
private final String sMaskChild;
private final Set<String> alternatesChild;

/**
* Constructs new shading features object
Expand Down Expand Up @@ -116,7 +116,7 @@ public boolean isInterpolate() {
@Override
public Set<String> getAlternatesChild() {
return this.alternatesChild == null ?
Collections.<String>emptySet() : Collections.unmodifiableSet(this.alternatesChild);
Collections.emptySet() : Collections.unmodifiableSet(this.alternatesChild);
}

@Override
Expand Down Expand Up @@ -192,9 +192,9 @@ public List<String> getErrors() {
return Collections.emptyList();
}

private class GFStreamFilterAdapter implements StreamFilterAdapter{
private static class GFStreamFilterAdapter implements StreamFilterAdapter{

private COSObject base;
private final COSObject base;

GFStreamFilterAdapter(COSObject base) {
this.base = base == null ? COSObject.getEmpty() : base;
Expand Down
Loading

0 comments on commit 775ee14

Please sign in to comment.