@@ -76,6 +76,8 @@ public class Metafix implements StreamPipe<StreamReceiver>, Maps {
76
76
77
77
public static final Map <String , String > NO_VARS = Collections .emptyMap ();
78
78
79
+ public static final int MAX_ENTITY_COUNT = Integer .getInteger ("org.metafacture.metafix.maxEntityCount" , -1 );
80
+
79
81
private static final Logger LOG = LoggerFactory .getLogger (Metafix .class );
80
82
81
83
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 {
101
103
private boolean repeatedFieldsToEntities ;
102
104
private boolean strictnessHandlesProcessExceptions ;
103
105
private int entityCount ;
104
- private int maxEntityCount = Integer .getInteger ("org.metafacture.metafix.maxEntityCount" , -1 );
105
106
106
107
public Metafix () {
107
108
this (NO_VARS );
@@ -316,7 +317,7 @@ public void startEntity(final String name) {
316
317
317
318
++entityCount ;
318
319
if (maxEntityCountExceeded ()) {
319
- LOG .debug ("Maximum number of entities exceeded: {}/{}" , entityCount , maxEntityCount );
320
+ LOG .debug ("Maximum number of entities exceeded: {}/{}" , entityCount , MAX_ENTITY_COUNT );
320
321
return ;
321
322
}
322
323
@@ -340,7 +341,7 @@ public void endEntity() {
340
341
341
342
@ Override
342
343
public void literal (final String name , final String value ) {
343
- if (entityCountStack . size () > 1 && maxEntityCountExceeded ()) {
344
+ if (maxEntityCountExceeded ()) {
344
345
return ;
345
346
}
346
347
@@ -453,16 +454,8 @@ public String getEntityMemberName() {
453
454
return entityMemberName ;
454
455
}
455
456
456
- public void setMaxEntityCount (final int maxEntityCount ) {
457
- this .maxEntityCount = maxEntityCount ;
458
- }
459
-
460
- public int getMaxEntityCount () {
461
- return maxEntityCount ;
462
- }
463
-
464
457
private boolean maxEntityCountExceeded () {
465
- return maxEntityCount >= 0 && entityCount > maxEntityCount ;
458
+ return MAX_ENTITY_COUNT >= 0 && entityCount > MAX_ENTITY_COUNT ;
466
459
}
467
460
468
461
public enum Strictness {
0 commit comments