Skip to content

Commit

Permalink
Clear property if it is set to null
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvid Berg authored and egonw committed Mar 25, 2010
1 parent 8a850c5 commit dca281c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ public String getInChI(IMolecule.Property urgency)
getDefault().getJavaInChIManager();
try {
InChI cachedInchi = inchi.generate(this);
setProperty( INCHI_KEY, cachedInchi );
if(cachedInchi != null)
setProperty( INCHI_KEY, cachedInchi );
return cachedInchi.getValue();
} catch (Exception e) {
throw new BioclipseException("Could not create InChI: "
Expand All @@ -281,7 +282,8 @@ public String getInChIKey(IMolecule.Property urgency)
getDefault().getJavaInChIManager();
try {
InChI cachedInchi = inchi.generate(this);
setProperty( INCHI_KEY, cachedInchi );
if(cachedInchi != null)
setProperty( INCHI_KEY, cachedInchi );
return cachedInchi.getKey();
} catch (Exception e) {
throw new BioclipseException("Could not create InChIKey: "
Expand All @@ -294,7 +296,10 @@ public Object getProperty(String propertyKey, Property urgency) {
}

public void setProperty(String propertyKey, Object value) {
atomContainer.setProperty( propertyKey, value );
if(value == null)
atomContainer.getProperties().remove( propertyKey );
else
atomContainer.setProperty( propertyKey, value );
}

void clearProperty( String key ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ public <T extends Object>void setPropertyFor( int moleculeIndex,
String property,
T value) {
Map<String,Object> props = molProps.get( moleculeIndex );
if(value == null) {
if(props!=null)
setDirty( props.remove( property )!=null );
return;
}
if(value!=null)
propertyList.put( property, value.getClass() );
if(props==null)
Expand Down

0 comments on commit dca281c

Please sign in to comment.