Class CreateOrUseExistingRule<T>

java.lang.Object
org.apache.commons.digester.Rule
org.apache.commons.digester.ObjectCreateRule
org.chenile.owiz.config.impl.CreateOrUseExistingRule<T>
Type Parameters:
T - .

public class CreateOrUseExistingRule<T> extends org.apache.commons.digester.ObjectCreateRule
Useful as an enhancement over the ObjectCreateRule for digester. This one creates a new object or uses an existing one if an old one was already created using the same ID. The ID has to be an attribute for the given xml tag. Its name is "id" by default but can be changed to something else if required. The finderMethod is the method to call on the previous object in the digester stack ( the object that is assumed to "collect" all the IDs so far) to obtain the old object if an old object was already created for that Id. The finderMethod must accept the "id" and nothing else and return the already created object. Only string ids are supported.
Author:
Raja Shankar Kolluru
  • Field Details

    • ID

      private static final String ID
      See Also:
    • finderMethod

      private String finderMethod
    • classToCreate

      private Class<T> classToCreate
    • idAttributeName

      private String idAttributeName
    • alternateStackToPushTo

      private String alternateStackToPushTo
    • endMethod

      private String endMethod
  • Constructor Details

    • CreateOrUseExistingRule

      public CreateOrUseExistingRule(Class<T> whichClazz, String finderMethod, String idAttributeName, String alternateStackToPushTo, String endMethod)
    • CreateOrUseExistingRule

      public CreateOrUseExistingRule(Class<T> whichClazz, String finderMethod, String alternateStackToPushTo, String endMethod)
  • Method Details

    • begin

      public void begin(Attributes attributes) throws Exception
      Overrides:
      begin in class org.apache.commons.digester.ObjectCreateRule
      Throws:
      Exception
    • end

      public void end() throws Exception
      Overrides:
      end in class org.apache.commons.digester.ObjectCreateRule
      Throws:
      Exception