org.openstreetmap.josm.data.validation.tests
Class TagChecker

java.lang.Object
  extended by org.openstreetmap.josm.data.osm.visitor.AbstractVisitor
      extended by org.openstreetmap.josm.data.validation.Test
          extended by org.openstreetmap.josm.data.validation.tests.TagChecker
All Implemented Interfaces:
Visitor

public class TagChecker
extends Test

Check for misspelled or wrong properties


Nested Class Summary
protected static class TagChecker.CheckerData
           
protected static class TagChecker.IgnoreKeyPair
           
 
Field Summary
protected  javax.swing.JButton addSrcButton
           
protected  boolean checkComplex
           
protected static java.util.List<TagChecker.CheckerData> checkerData
          The TagChecker data
protected  boolean checkFixmes
           
protected  boolean checkKeys
           
protected  boolean checkValues
           
static java.lang.String DATA_FILE
          The default data files
protected  javax.swing.JButton deleteSrcButton
           
protected  javax.swing.JButton editSrcButton
           
protected static int EMPTY_VALUES
           
protected static Entities entities
           
protected static int FIXME
           
static java.lang.String IGNORE_FILE
           
protected static java.util.List<java.lang.String> ignoreDataEndsWith
           
protected static java.util.List<java.lang.String> ignoreDataEquals
           
protected static java.util.List<TagChecker.IgnoreKeyPair> ignoreDataKeyPair
           
protected static java.util.List<java.lang.String> ignoreDataStartsWith
           
protected static int INVALID_HTML
           
protected static int INVALID_KEY
           
protected static int INVALID_KEY_SPACE
           
protected static int INVALID_SPACE
           
protected static int INVALID_VALUE
           
protected static int LONG_KEY
           
protected static int LONG_VALUE
           
protected static int LOW_CHAR_KEY
           
protected static int LOW_CHAR_VALUE
           
static java.lang.String PREF_CHECK_COMPLEX
           
static java.lang.String PREF_CHECK_COMPLEX_BEFORE_UPLOAD
           
static java.lang.String PREF_CHECK_FIXMES
           
static java.lang.String PREF_CHECK_FIXMES_BEFORE_UPLOAD
           
static java.lang.String PREF_CHECK_KEYS
           
static java.lang.String PREF_CHECK_KEYS_BEFORE_UPLOAD
           
static java.lang.String PREF_CHECK_VALUES
           
static java.lang.String PREF_CHECK_VALUES_BEFORE_UPLOAD
           
static java.lang.String PREF_SOURCES
           
static java.lang.String PREF_USE_DATA_FILE
           
static java.lang.String PREF_USE_IGNORE_FILE
           
static java.lang.String PREF_USE_SPELL_FILE
           
protected  javax.swing.JCheckBox prefCheckComplex
           
protected  javax.swing.JCheckBox prefCheckComplexBeforeUpload
           
protected  javax.swing.JCheckBox prefCheckFixmes
           
protected  javax.swing.JCheckBox prefCheckFixmesBeforeUpload
           
protected  javax.swing.JCheckBox prefCheckKeys
           
protected  javax.swing.JCheckBox prefCheckKeysBeforeUpload
           
protected  javax.swing.JCheckBox prefCheckPaint
           
protected  javax.swing.JCheckBox prefCheckPaintBeforeUpload
           
protected  javax.swing.JCheckBox prefCheckValues
           
protected  javax.swing.JCheckBox prefCheckValuesBeforeUpload
           
protected static java.lang.String PREFIX
          The preferences prefix
protected  javax.swing.JCheckBox prefUseDataFile
           
protected  javax.swing.JCheckBox prefUseIgnoreFile
           
protected  javax.swing.JCheckBox prefUseSpellFile
           
protected static MultiMap<java.lang.String,java.lang.String> presetsValueData
          The spell check preset values
protected  javax.swing.JList sourcesList
          List of sources for spellcheck data
static java.lang.String SPELL_FILE
           
protected static java.util.Map<java.lang.String,java.lang.String> spellCheckKeyData
          The spell check key substitutions: the key should be substituted by the value
 
Fields inherited from class org.openstreetmap.josm.data.validation.Test
checkBeforeUpload, checkEnabled, description, enabled, errors, isBeforeUpload, name, partialSelection, progressMonitor, testBeforeUpload
 
Constructor Summary
TagChecker()
          Constructor
 
Method Summary
 void addGui(javax.swing.JPanel testPanel)
          Allow the tester to manage its own preferences
private  void checkPrimitive(OsmPrimitive p)
          Checks the primitive properties
private  boolean containsLow(java.lang.String s)
          Checks given string (key or value) if it contains characters with code below 0x20 (either newline or some other special characters)
 Command fixError(TestError testError)
          Fixes the error with the appropriate command
 void handlePrefEnable()
           
 void initialize()
          Initializes any global data used this tester.
private static void initializeData()
          Reads the spellcheck file into a HashMap.
static void initializePresets()
          Reads the presets data.
 boolean isFixable(TestError testError)
          Returns true if the given error can be fixed automatically
 boolean ok()
          Called when the used submits the preferences
 void startTest(ProgressMonitor monitor)
          Start the test using a given progress monitor
 void visit(java.util.Collection<OsmPrimitive> selection)
          Visits all primitives to be tested.
 void visit(Node n)
          Visiting call for points.
 void visit(Relation n)
          Visiting call for relations.
 void visit(Way w)
          Visiting call for lines.
 
Methods inherited from class org.openstreetmap.josm.data.validation.Test
deletePrimitivesIfNeeded, endTest, getErrors, getName, isBuilding, isCanceled, setBeforeUpload, setPartialSelection, testBeforeUpload
 
Methods inherited from class org.openstreetmap.josm.data.osm.visitor.AbstractVisitor
visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_FILE

public static final java.lang.String DATA_FILE
The default data files

See Also:
Constant Field Values

IGNORE_FILE

public static final java.lang.String IGNORE_FILE
See Also:
Constant Field Values

SPELL_FILE

public static final java.lang.String SPELL_FILE
See Also:
Constant Field Values

spellCheckKeyData

protected static java.util.Map<java.lang.String,java.lang.String> spellCheckKeyData
The spell check key substitutions: the key should be substituted by the value


presetsValueData

protected static MultiMap<java.lang.String,java.lang.String> presetsValueData
The spell check preset values


checkerData

protected static final java.util.List<TagChecker.CheckerData> checkerData
The TagChecker data


ignoreDataStartsWith

protected static final java.util.List<java.lang.String> ignoreDataStartsWith

ignoreDataEquals

protected static final java.util.List<java.lang.String> ignoreDataEquals

ignoreDataEndsWith

protected static final java.util.List<java.lang.String> ignoreDataEndsWith

ignoreDataKeyPair

protected static final java.util.List<TagChecker.IgnoreKeyPair> ignoreDataKeyPair

PREFIX

protected static final java.lang.String PREFIX
The preferences prefix


PREF_CHECK_VALUES

public static final java.lang.String PREF_CHECK_VALUES

PREF_CHECK_KEYS

public static final java.lang.String PREF_CHECK_KEYS

PREF_CHECK_COMPLEX

public static final java.lang.String PREF_CHECK_COMPLEX

PREF_CHECK_FIXMES

public static final java.lang.String PREF_CHECK_FIXMES

PREF_SOURCES

public static final java.lang.String PREF_SOURCES

PREF_USE_DATA_FILE

public static final java.lang.String PREF_USE_DATA_FILE

PREF_USE_IGNORE_FILE

public static final java.lang.String PREF_USE_IGNORE_FILE

PREF_USE_SPELL_FILE

public static final java.lang.String PREF_USE_SPELL_FILE

PREF_CHECK_KEYS_BEFORE_UPLOAD

public static final java.lang.String PREF_CHECK_KEYS_BEFORE_UPLOAD

PREF_CHECK_VALUES_BEFORE_UPLOAD

public static final java.lang.String PREF_CHECK_VALUES_BEFORE_UPLOAD

PREF_CHECK_COMPLEX_BEFORE_UPLOAD

public static final java.lang.String PREF_CHECK_COMPLEX_BEFORE_UPLOAD

PREF_CHECK_FIXMES_BEFORE_UPLOAD

public static final java.lang.String PREF_CHECK_FIXMES_BEFORE_UPLOAD

checkKeys

protected boolean checkKeys

checkValues

protected boolean checkValues

checkComplex

protected boolean checkComplex

checkFixmes

protected boolean checkFixmes

prefCheckKeys

protected javax.swing.JCheckBox prefCheckKeys

prefCheckValues

protected javax.swing.JCheckBox prefCheckValues

prefCheckComplex

protected javax.swing.JCheckBox prefCheckComplex

prefCheckFixmes

protected javax.swing.JCheckBox prefCheckFixmes

prefCheckPaint

protected javax.swing.JCheckBox prefCheckPaint

prefCheckKeysBeforeUpload

protected javax.swing.JCheckBox prefCheckKeysBeforeUpload

prefCheckValuesBeforeUpload

protected javax.swing.JCheckBox prefCheckValuesBeforeUpload

prefCheckComplexBeforeUpload

protected javax.swing.JCheckBox prefCheckComplexBeforeUpload

prefCheckFixmesBeforeUpload

protected javax.swing.JCheckBox prefCheckFixmesBeforeUpload

prefCheckPaintBeforeUpload

protected javax.swing.JCheckBox prefCheckPaintBeforeUpload

prefUseDataFile

protected javax.swing.JCheckBox prefUseDataFile

prefUseIgnoreFile

protected javax.swing.JCheckBox prefUseIgnoreFile

prefUseSpellFile

protected javax.swing.JCheckBox prefUseSpellFile

addSrcButton

protected javax.swing.JButton addSrcButton

editSrcButton

protected javax.swing.JButton editSrcButton

deleteSrcButton

protected javax.swing.JButton deleteSrcButton

EMPTY_VALUES

protected static final int EMPTY_VALUES
See Also:
Constant Field Values

INVALID_KEY

protected static final int INVALID_KEY
See Also:
Constant Field Values

INVALID_VALUE

protected static final int INVALID_VALUE
See Also:
Constant Field Values

FIXME

protected static final int FIXME
See Also:
Constant Field Values

INVALID_SPACE

protected static final int INVALID_SPACE
See Also:
Constant Field Values

INVALID_KEY_SPACE

protected static final int INVALID_KEY_SPACE
See Also:
Constant Field Values

INVALID_HTML

protected static final int INVALID_HTML
See Also:
Constant Field Values

LONG_VALUE

protected static final int LONG_VALUE
See Also:
Constant Field Values

LONG_KEY

protected static final int LONG_KEY
See Also:
Constant Field Values

LOW_CHAR_VALUE

protected static final int LOW_CHAR_VALUE
See Also:
Constant Field Values

LOW_CHAR_KEY

protected static final int LOW_CHAR_KEY
See Also:
Constant Field Values

sourcesList

protected javax.swing.JList sourcesList
List of sources for spellcheck data


entities

protected static final Entities entities
Constructor Detail

TagChecker

public TagChecker()
Constructor

Method Detail

initialize

public void initialize()
                throws java.io.IOException
Description copied from class: Test
Initializes any global data used this tester.

Overrides:
initialize in class Test
Throws:
java.io.IOException

initializeData

private static void initializeData()
                            throws java.io.IOException
Reads the spellcheck file into a HashMap. The data file is a list of words, beginning with +/-. If it starts with +, the word is valid, but if it starts with -, the word should be replaced by the nearest + word before this.

Throws:
java.io.FileNotFoundException
java.io.IOException

initializePresets

public static void initializePresets()
Reads the presets data.


visit

public void visit(Node n)
Description copied from interface: Visitor
Visiting call for points.

Specified by:
visit in interface Visitor
Overrides:
visit in class Test
Parameters:
n - The node to inspect.

visit

public void visit(Relation n)
Description copied from interface: Visitor
Visiting call for relations.

Specified by:
visit in interface Visitor
Overrides:
visit in class Test
Parameters:
n - The relation to inspect.

visit

public void visit(Way w)
Description copied from interface: Visitor
Visiting call for lines.

Specified by:
visit in interface Visitor
Overrides:
visit in class Test
Parameters:
w - The way to inspect.

containsLow

private boolean containsLow(java.lang.String s)
Checks given string (key or value) if it contains characters with code below 0x20 (either newline or some other special characters)

Parameters:
s - string to check

checkPrimitive

private void checkPrimitive(OsmPrimitive p)
Checks the primitive properties

Parameters:
p - The primitive to check

startTest

public void startTest(ProgressMonitor monitor)
Description copied from class: Test
Start the test using a given progress monitor

Overrides:
startTest in class Test
Parameters:
monitor - the progress monitor

visit

public void visit(java.util.Collection<OsmPrimitive> selection)
Description copied from class: Test
Visits all primitives to be tested. These primitives are always visited in the same order: nodes first, then ways.

Overrides:
visit in class Test
Parameters:
selection - The primitives to be tested

addGui

public void addGui(javax.swing.JPanel testPanel)
Description copied from class: Test
Allow the tester to manage its own preferences

Overrides:
addGui in class Test
Parameters:
testPanel - The panel to add any preferences component

handlePrefEnable

public void handlePrefEnable()

ok

public boolean ok()
Description copied from class: Test
Called when the used submits the preferences

Overrides:
ok in class Test

fixError

public Command fixError(TestError testError)
Description copied from class: Test
Fixes the error with the appropriate command

Overrides:
fixError in class Test
Returns:
The command to fix the error

isFixable

public boolean isFixable(TestError testError)
Description copied from class: Test
Returns true if the given error can be fixed automatically

Overrides:
isFixable in class Test
Parameters:
testError - The error to check if can be fixed
Returns:
true if the error can be fixed


JOSM