Skip to content

Commit

Permalink
Remove duplicated processor
Browse files Browse the repository at this point in the history
  • Loading branch information
seadowg committed Jul 8, 2024
1 parent 7961fbd commit 18fdb44
Showing 1 changed file with 1 addition and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
import org.javarosa.core.reference.ReferenceManager;
import org.javarosa.xml.util.InvalidStructureException;
import org.javarosa.xml.util.UnfullfilledRequirementsException;
import org.jetbrains.annotations.NotNull;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
Expand All @@ -22,7 +20,6 @@

public class ExternalInstanceParser {

private List<ExternalDataInstanceProcessor> externalDataInstanceProcessors = new ArrayList<>();
private List<FileInstanceParser> fileInstanceParsers = asList(
new CsvExternalInstance(),
new GeoJsonExternalInstance()
Expand All @@ -41,18 +38,9 @@ public TreeElement parse(ReferenceManager referenceManager, String instanceId, S
} else {
root = XmlExternalInstance.parse(instanceId, path);
}

for (ExternalDataInstanceProcessor processor : externalDataInstanceProcessors) {
processor.processInstance(instanceId, root);
}

return root;
}

public void addProcessor(Processor processor) {
externalDataInstanceProcessors.add((ExternalDataInstanceProcessor) processor);
}

/**
* Adds {@link FileInstanceParser} before others. The last added {@link FileInstanceParser} will be checked
* (via {@link FileInstanceParser#isSupported(String, String)}) first.
Expand All @@ -75,16 +63,9 @@ private static String getPath(ReferenceManager referenceManager, String srcLocat
return uri.startsWith("//") /* todo why is this? */ ? uri.substring(1) : uri;
}

public interface Processor {

}

public interface ExternalDataInstanceProcessor extends ExternalInstanceParser.Processor {
void processInstance(@NotNull String id, @NotNull TreeElement root);
}

public interface FileInstanceParser {
TreeElement parse(String instanceId, String path) throws IOException;

boolean isSupported(String instanceId, String instanceSrc);
}
}

0 comments on commit 18fdb44

Please sign in to comment.