public class Test extends AbstractVisitor
A test is a primitive visitor, so that it can access to all data to be validated. These primitives are always visited in the same order: nodes first, then ways.
Modifier and Type | Class and Description |
---|---|
static class |
Test.TagTest
A test that forwards all primitives to
Test.TagTest.check(OsmPrimitive) . |
Modifier and Type | Field and Description |
---|---|
protected JCheckBox |
checkBeforeUpload
The preferences check for validation on upload
|
protected JCheckBox |
checkEnabled
The preferences check for validation
|
protected String |
description
Description of the test
|
boolean |
enabled
Whether this test is enabled.
|
protected List<TestError> |
errors
The list of errors
|
protected boolean |
isBeforeUpload
Whether this test is performing just before an upload
|
protected String |
name
Name of the test
|
protected boolean |
partialSelection
Whether the test is run on a partial selection data
|
protected ProgressMonitor |
progressMonitor
the progress monitor to use
|
protected long |
startTime
the start time to compute elapsed time when test finishes
|
boolean |
testBeforeUpload
Whether this test must check before upload.
|
Constructor and Description |
---|
Test(String name)
Constructor
|
Test(String name,
String description)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addGui(JPanel testPanel)
Allow the tester to manage its own preferences
|
protected Command |
deletePrimitivesIfNeeded(Collection<? extends OsmPrimitive> primitives)
Build a Delete command on all primitives that have not yet been deleted manually by user, or by another error fix.
|
void |
endTest()
Notification of the end of the test.
|
boolean |
equals(Object obj) |
Command |
fixError(TestError testError)
Fixes the error with the appropriate command
|
List<TestError> |
getErrors()
Gets the validation errors accumulated until this moment.
|
String |
getName()
Returns the test name.
|
int |
hashCode() |
void |
initialize()
Initializes any global data used this tester.
|
protected static boolean |
isBuilding(OsmPrimitive p)
Determines if the specified primitive denotes a building.
|
boolean |
isCanceled()
Determines if the test has been canceled.
|
boolean |
isFixable(TestError testError)
Returns true if the given error can be fixed automatically
|
boolean |
isPrimitiveUsable(OsmPrimitive p)
Determines if the primitive is usable for tests.
|
boolean |
ok()
Called when the used submits the preferences
|
void |
setBeforeUpload(boolean isUpload)
Sets the flag that marks an upload check
|
void |
setPartialSelection(boolean partialSelection)
Flag notifying that this test is run over a partial data selection
|
void |
startTest(ProgressMonitor progressMonitor)
Start the test using a given progress monitor
|
boolean |
testBeforeUpload()
Returns true if this plugin must check the uploaded data before uploading
|
void |
visit(Collection<OsmPrimitive> selection)
Visits all primitives to be tested.
|
void |
visit(Node n)
Visiting call for points.
|
void |
visit(Relation r)
Visiting call for relations.
|
void |
visit(Way w)
Visiting call for lines.
|
visit
protected final String description
public boolean enabled
protected JCheckBox checkEnabled
protected JCheckBox checkBeforeUpload
public boolean testBeforeUpload
protected boolean isBeforeUpload
protected boolean partialSelection
protected ProgressMonitor progressMonitor
protected long startTime
public Test(String name, String description)
name
- Name of the testdescription
- Description of the testpublic void initialize() throws Exception
Exception
- When cannot initialize the testpublic void startTest(ProgressMonitor progressMonitor)
progressMonitor
- the progress monitorpublic void setPartialSelection(boolean partialSelection)
partialSelection
- Whether the test is on a partial selection datapublic List<TestError> getErrors()
public void endTest()
If you override this method, don't forget to cleanup progressMonitor
(most overrides call super.endTest()
to do this).
public void visit(Collection<OsmPrimitive> selection)
selection
- The primitives to be testedpublic boolean isPrimitiveUsable(OsmPrimitive p)
p
- The primitivetrue
if the primitive can be tested, false
otherwisepublic void visit(Node n)
Visitor
n
- The node to inspect.public void visit(Way w)
Visitor
w
- The way to inspect.public void visit(Relation r)
Visitor
r
- The relation to inspect.public void addGui(JPanel testPanel)
testPanel
- The panel to add any preferences componentpublic boolean ok()
true
if restart is required, false
otherwisepublic Command fixError(TestError testError)
testError
- error to fixpublic boolean isFixable(TestError testError)
testError
- The error to check if can be fixedpublic boolean testBeforeUpload()
public void setBeforeUpload(boolean isUpload)
isUpload
- if true, the test is before uploadpublic boolean isCanceled()
true
if the test has been canceled, false
otherwiseprotected final Command deletePrimitivesIfNeeded(Collection<? extends OsmPrimitive> primitives)
primitives
- The primitives wanted for deletionprotected static final boolean isBuilding(OsmPrimitive p)
p
- The primitive to be tested