FabienCampagne/TODO

From Icbwiki

Jump to: navigation, search

Fix this bug in MG4J:

In ShufflingBioSequenceWordReader, the method save should not need to clear a property this class is not concerned about.

public void saveProperties(Properties properties) {

       properties.clearProperty("parenthesesarewords");   // this reader does not use this property.
       super.saveProperties(properties);
   }

The problem is caused by the way MG4J scans properties:

 /** Scans the property set, parsing the properties that concern this class.
 	 * 
 	 * @param properties a set of properties.
 	 * @return a metadata map.
 	 */
 	
 	@SuppressWarnings("unchecked")
 	public Reference2ObjectMap<Enum,Object> parseProperties( final Properties properties ) throws ConfigurationException {
 		String key, qualifier, className = this.getClass().getName();
 		int lastDot;
 		Reference2ObjectMap<Enum,Object> metadata = new   Reference2ObjectOpenHashMap<Enum,Object>();
 		
 		for( Iterator i = properties.getKeys(); i.hasNext(); ) {
 			key = i.next().toString();
 			lastDot = key.lastIndexOf( '.' );
 			qualifier = lastDot == -1 ? "" : key.substring( 0, lastDot );  
 
 			if ( className.startsWith( qualifier )
 				&& ! parseProperty( key.substring( lastDot + 1 ), properties.getStringArray( key ), metadata ) 
 				&& className.equals( qualifier ) )
 					throw new ConfigurationException( "Unknown property " + key );
 		}
 		
 		return metadata.isEmpty() ? Reference2ObjectMaps.EMPTY_MAP : metadata; 
 	}

In this method, properties.getStringArray( key ) throws an exception with property "parenthesesarewords" (because the property is of type boolean, a type that may not convert to array?).

Personal tools