private ValidationReport validateCharge ( IAtom atom ) { ValidationReport report = new ValidationReport ( ) ; ValidationTest tooCharged = new ValidationTest ( atom , "Atom has an unlikely large positive or negative charge" ) ; if ( atom . getSymbol ( ) . equals ( "O" ) || atom . getSymbol ( ) . equals ( "N" ) || atom . getSymbol ( ) . equals ( "C" ) || atom . getSymbol ( ) . equals ( "H" ) ) { if ( atom . getFormalCharge ( ) == 0 ) { report . addOK ( tooCharged ) ; } else { tooCharged . setDetails ( "Atom " + atom . getSymbol ( ) + " has charge " + atom . getFormalCharge ( ) ) ; if ( atom . getFormalCharge ( ) < - 3 ) { report . addError ( tooCharged ) ; } else if ( atom . getFormalCharge ( ) < - 1 ) { report . addWarning ( tooCharged ) ; } else if ( atom . getFormalCharge ( ) > 3 ) { report . addError ( tooCharged ) ; } else if ( atom . getFormalCharge ( ) > 1 ) { report . addWarning ( tooCharged ) ; } } } else { if ( atom . getFormalCharge ( ) == 0 ) { report . addOK ( tooCharged ) ; } else { tooCharged . setDetails ( "Atom " + atom . getSymbol ( ) + " has charge " + atom . getFormalCharge ( ) ) ; if ( atom . getFormalCharge ( ) < - 4 ) { report . addError ( tooCharged ) ; } else if ( atom . getFormalCharge ( ) < - 3 ) { report . addWarning ( tooCharged ) ; } else if ( atom . getFormalCharge ( ) > 4 ) { report . addError ( tooCharged ) ; } else if ( atom . getFormalCharge ( ) > 3 ) { report . addWarning ( tooCharged ) ; } } } return report ; }
the Atom tests