@@ -76,6 +76,8 @@ public class Metafix implements StreamPipe<StreamReceiver>, Maps {
7676
7777 public static final Map <String , String > NO_VARS = Collections .emptyMap ();
7878
79+ public static final int MAX_ENTITY_COUNT = Integer .getInteger ("org.metafacture.metafix.maxEntityCount" , -1 );
80+
7981 private static final Logger LOG = LoggerFactory .getLogger (Metafix .class );
8082
8183 private static final String ENTITIES_NOT_BALANCED = "Entity starts and ends are not balanced" ;
@@ -101,7 +103,6 @@ public class Metafix implements StreamPipe<StreamReceiver>, Maps {
101103 private boolean repeatedFieldsToEntities ;
102104 private boolean strictnessHandlesProcessExceptions ;
103105 private int entityCount ;
104- private int maxEntityCount = Integer .getInteger ("org.metafacture.metafix.maxEntityCount" , -1 );
105106
106107 public Metafix () {
107108 this (NO_VARS );
@@ -316,7 +317,7 @@ public void startEntity(final String name) {
316317
317318 ++entityCount ;
318319 if (maxEntityCountExceeded ()) {
319- LOG .debug ("Maximum number of entities exceeded: {}/{}" , entityCount , maxEntityCount );
320+ LOG .debug ("Maximum number of entities exceeded: {}/{}" , entityCount , MAX_ENTITY_COUNT );
320321 return ;
321322 }
322323
@@ -340,7 +341,7 @@ public void endEntity() {
340341
341342 @ Override
342343 public void literal (final String name , final String value ) {
343- if (entityCountStack . size () > 1 && maxEntityCountExceeded ()) {
344+ if (maxEntityCountExceeded ()) {
344345 return ;
345346 }
346347
@@ -453,16 +454,8 @@ public String getEntityMemberName() {
453454 return entityMemberName ;
454455 }
455456
456- public void setMaxEntityCount (final int maxEntityCount ) {
457- this .maxEntityCount = maxEntityCount ;
458- }
459-
460- public int getMaxEntityCount () {
461- return maxEntityCount ;
462- }
463-
464457 private boolean maxEntityCountExceeded () {
465- return maxEntityCount >= 0 && entityCount > maxEntityCount ;
458+ return MAX_ENTITY_COUNT >= 0 && entityCount > MAX_ENTITY_COUNT ;
466459 }
467460
468461 public enum Strictness {
0 commit comments