Logo Search packages:      
Sourcecode: josm-plugins version File versions  Download package

void org::openstreetmap::josm::plugins::validator::tests::SpellCheck::checkPrimitive ( OsmPrimitive  p  )  [inline, private]

Checks the spelling of the primitive properties

Parameters:
p The primitive to check

Definition at line 222 of file SpellCheck.java.

References checkFixmes, checkKeys, checkValues, EMPTY_VALUES, org::openstreetmap::josm::plugins::validator::Test::errors, FIXME, INVALID_KEY, INVALID_VALUE, spellCheckKeyData, and spellCheckValueData.

      {
          // Just a collection to know if a primitive has been already marked with error
        Bag<OsmPrimitive, String> withErrors = new Bag<OsmPrimitive, String>();
        
        Map<String, String> props = (p.keys == null) ? Collections.<String, String>emptyMap() : p.keys;
            for(Entry<String, String> prop: props.entrySet() )
            {
                  String key = prop.getKey();
                  String value = prop.getValue();
                  if( checkValues && (value==null || value.trim().length() == 0) && !withErrors.contains(p, "EV"))
                  {
                        errors.add( new TestError(this, Severity.WARNING, tr("Tags with empty values"), p, EMPTY_VALUES) );
                        withErrors.add(p, "EV");
                  }
                  if( checkKeys && spellCheckKeyData.containsKey(key) && !withErrors.contains(p, "IPK"))
                  {
                        errors.add( new TestError(this, Severity.WARNING, tr("Invalid property keys"), p, INVALID_KEY) );
                        withErrors.add(p, "IPK");
                  }
            if( checkValues && value != null && value.length() > 0 && spellCheckValueData != null)
            {
                List<String> values = spellCheckValueData.get(key);
                if( values != null && !values.contains(prop.getValue()) && !withErrors.contains(p, "UPV"))
                {
                    errors.add( new TestError(this, Severity.OTHER, tr("Unknown property values"), p, INVALID_VALUE) );
                    withErrors.add(p, "UPV");
                }
            }
            if( checkFixmes && value != null && value.length() > 0 )
            {
                if( (value.contains("FIXME") || key.contains("todo") || key.contains("fixme"))
                          && !withErrors.contains(p, "FIXME"))
                {
                    errors.add( new TestError(this, Severity.OTHER, tr("FIXMES"), p, FIXME) );
                    withErrors.add(p, "FIXME");
                }
            }
            }
      }


Generated by  Doxygen 1.6.0   Back to index