Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Apr 9, 2024
1 parent 164c351 commit 43c5a7a
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ static AuditDuration fromValues(final long start, final long finish) {
}

public static String getStringDuration(final long difference) {
long hours = difference / (minInHour * secInMin * msInSec);
long minutes = difference / (secInMin * msInSec) % minInHour;
long seconds = difference / msInSec % secInMin;
long millis = difference % msInSec;

try (Formatter formatter = new Formatter()) {
long hours = difference / (minInHour * secInMin * msInSec);
long minutes = difference / (secInMin * msInSec) % minInHour;
long seconds = difference / msInSec % secInMin;
long millis = difference % msInSec;
formatter.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, //$NON-NLS-1$
millis);
return formatter.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ public static FeatureTreeNode parseMetadata(InputStream metadata, String nodeNam
if (metadata == null) {
return null;
}
FeatureTreeNode node;
node = parent.addMetadataChild(nodeName);
FeatureTreeNode node = parent.addMetadataChild(nodeName);
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import org.verapdf.processor.reports.enums.JobEndStatus;

import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created as the result of validating a PDF/A document against a
Expand Down Expand Up @@ -93,5 +93,5 @@ public interface ValidationResult {

public JobEndStatus getJobEndStatus();

public HashMap<RuleId, Integer> getFailedChecks();
public Map<RuleId, Integer> getFailedChecks();
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class BaseValidator implements PDFAValidator {
public static final int DEFAULT_MAX_NUMBER_OF_DISPLAYED_FAILED_CHECKS = 100;
private static final int MAX_CHECKS_NUMBER = 10_000;
private static final URI componentId = URI.create("http://pdfa.verapdf.org/validators#default");
private static final String componentName = "veraPDF PDF/A Validator";
private static final String componentName = "veraPDF Validator";
private static final ComponentDetails componentDetails = Components.libraryDetails(componentId, componentName);
private final ValidationProfile profile;
private ScriptableObject scope;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ private static void initializeExtractor(AbstractFeaturesExtractor extractor, Plu
String name = getNonNullString(config.getName());
String version = getNonNullString(config.getVersion());
String description = getNonNullString(config.getDescription());
AbstractFeaturesExtractor.ExtractorDetails details = new AbstractFeaturesExtractor.ExtractorDetails(name, version, description);

Map<String, String> attributes = new HashMap<>();
List<Attribute> attributesList = config.getAttributes();
Expand All @@ -152,6 +151,7 @@ private static void initializeExtractor(AbstractFeaturesExtractor extractor, Plu
}
}
}
AbstractFeaturesExtractor.ExtractorDetails details = new AbstractFeaturesExtractor.ExtractorDetails(name, version, description);
extractor.initialize(details, attributes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@ private boolean hasCustomProfile() {
}

private void fixMetadata(final PDFAParser parser, final String fileName) {
TaskType type = TaskType.FIX_METADATA;
Components.Timer timer = Components.Timer.start();
File orig = new File(fileName);
if (!orig.isFile()) {
// FIXME: This needs to handle the unnamed input stream case.
}
File fxfl;
TaskType type = TaskType.FIX_METADATA;
try {
fxfl = this.mdFixMapper.mapFile(orig);
} catch (VeraPDFException excep) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ public String toString() {
}

static String toXml(final VeraAppConfig toConvert, Boolean prettyXml) throws JAXBException, IOException {
String retVal = ""; //$NON-NLS-1$
try (StringWriter writer = new StringWriter()) {
toXml(toConvert, writer, prettyXml);
retVal = writer.toString();
//$NON-NLS-1$
String retVal = writer.toString();
return retVal;
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/verapdf/report/FeaturesNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ private FeaturesNode() {
static FeaturesNode fromValues(FeatureExtractionResult collection,
FeatureObjectType... types) {
List<Object> qChildren = new ArrayList<>();
Map<QName, Object> attr = new HashMap<>();
StringBuilder builder = new StringBuilder();
for (FeatureObjectType type : types) {
List<FeatureTreeNode> children = collection.getFeatureTreesForType(type);
Expand All @@ -104,6 +103,7 @@ static FeaturesNode fromValues(FeatureExtractionResult collection,
}
}
}
Map<QName, Object> attr = new HashMap<>();
if (!builder.toString().isEmpty()) {
attr.put(new QName(ErrorsHelper.ERRORID), builder.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public final void testFromValidationProfile() {
@Test
public final void testToXmlStream() throws JAXBException, IOException {
Set<Rule> rules = new HashSet<>();
Set<Variable> vars = new HashSet<>();
rules.add(Profiles.defaultRule());
Set<Variable> vars = new HashSet<>();
vars.add(Profiles.defaultVariable());
ValidationProfile profile = Profiles.profileFromValues(PDFAFlavour.NO_FLAVOUR,
ProfileDetailsImpl.defaultInstance(), "hash", rules, vars);
Expand Down

0 comments on commit 43c5a7a

Please sign in to comment.