git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271742 13f79535-47bb-0310-9956-ffa450edef68master
@@ -19,19 +19,17 @@ package org.apache.myrmidon.components.configurer; | |||||
class DefaultConfigurationState | class DefaultConfigurationState | ||||
implements ConfigurationState | implements ConfigurationState | ||||
{ | { | ||||
private final int[] m_propCount; | |||||
private final Object[] m_createdObjects; | |||||
private final int[] m_propertyCount; | |||||
private final ObjectConfigurer m_configurer; | private final ObjectConfigurer m_configurer; | ||||
private final Object m_object; | private final Object m_object; | ||||
public DefaultConfigurationState( final ObjectConfigurer configurer, | public DefaultConfigurationState( final ObjectConfigurer configurer, | ||||
final Object object, | final Object object, | ||||
final int numProps ) | |||||
final int propertyCount ) | |||||
{ | { | ||||
m_configurer = configurer; | m_configurer = configurer; | ||||
m_object = object; | m_object = object; | ||||
m_propCount = new int[ numProps ]; | |||||
m_createdObjects = new Object[ numProps ]; | |||||
m_propertyCount = new int[ propertyCount ]; | |||||
} | } | ||||
/** | /** | ||||
@@ -49,26 +47,14 @@ class DefaultConfigurationState | |||||
} | } | ||||
/** Returns a property count. */ | /** Returns a property count. */ | ||||
public int getPropCount( final int propIndex ) | |||||
public int getPropertyCount( final int index ) | |||||
{ | { | ||||
return m_propCount[ propIndex ]; | |||||
return m_propertyCount[ index ]; | |||||
} | } | ||||
/** Increments a property count. */ | /** Increments a property count. */ | ||||
public void incPropCount( final int propIndex ) | |||||
public void incPropertyCount( final int index ) | |||||
{ | { | ||||
m_propCount[ propIndex ]++; | |||||
} | |||||
/** Returns a property's pending objects. */ | |||||
public Object getCreatedObject( final int propIndex ) | |||||
{ | |||||
return m_createdObjects[ propIndex ]; | |||||
} | |||||
/** Sets a property's pending objects. */ | |||||
public void setCreatedObject( final int propIndex, final Object object ) | |||||
{ | |||||
m_createdObjects[ propIndex ] = object; | |||||
m_propertyCount[ index ]++; | |||||
} | } | ||||
} | } |
@@ -298,8 +298,8 @@ public class DefaultConfigurer | |||||
final String name = element.getName(); | final String name = element.getName(); | ||||
// Locate the configurer for the child element | // Locate the configurer for the child element | ||||
final PropertyConfigurer childConfigurer | |||||
= getConfigurerFromName( state.getConfigurer(), name, true ); | |||||
final PropertyConfigurer childConfigurer = | |||||
getConfigurerFromName( state.getConfigurer(), name, true ); | |||||
// Create & configure the child element | // Create & configure the child element | ||||
final Object child = | final Object child = | ||||
@@ -263,16 +263,6 @@ class DefaultObjectConfigurer | |||||
{ | { | ||||
// Make sure there are no pending created objects | // Make sure there are no pending created objects | ||||
final DefaultConfigurationState defState = (DefaultConfigurationState)state; | final DefaultConfigurationState defState = (DefaultConfigurationState)state; | ||||
final int size = m_allProps.size(); | |||||
for( int i = 0; i < size; i++ ) | |||||
{ | |||||
if( null != defState.getCreatedObject( i ) ) | |||||
{ | |||||
final String message = REZ.getString( "pending-property-value.error" ); | |||||
throw new ConfigurationException( message ); | |||||
} | |||||
} | |||||
return defState.getObject(); | return defState.getObject(); | ||||
} | } | ||||
@@ -65,21 +65,13 @@ class DefaultPropertyConfigurer | |||||
{ | { | ||||
final DefaultConfigurationState defState = (DefaultConfigurationState)state; | final DefaultConfigurationState defState = (DefaultConfigurationState)state; | ||||
// Make sure the supplied object is the pending object | |||||
final Object pending = defState.getCreatedObject( m_propIndex ); | |||||
if( pending != null && pending != value ) | |||||
{ | |||||
} | |||||
defState.setCreatedObject( m_propIndex, null ); | |||||
// Check the property count | // Check the property count | ||||
if( defState.getPropCount( m_propIndex ) >= m_maxCount ) | |||||
if( defState.getPropertyCount( m_propIndex ) >= m_maxCount ) | |||||
{ | { | ||||
final String message = REZ.getString( "too-many-values.error" ); | final String message = REZ.getString( "too-many-values.error" ); | ||||
throw new ConfigurationException( message ); | throw new ConfigurationException( message ); | ||||
} | } | ||||
defState.incPropCount( m_propIndex ); | |||||
defState.incPropertyCount( m_propIndex ); | |||||
try | try | ||||
{ | { | ||||