All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.alantea.viewml.handlers.IncludeHandler Maven / Gradle / Ivy

The newest version!

package net.alantea.viewml.handlers;

import net.alantea.viewml.VmlException;
import net.alantea.viewml.VmlParser;
import net.alantea.viewml.annotations.VAttribute;
import net.alantea.viewml.annotations.VElement;
import net.alantea.viewml.annotations.VEnd;
import net.alantea.viewml.internal.Referencer;

/**
 * The Class TouchyComponentHandler.
 */
@VElement("include")
public class IncludeHandler implements TransparentHandler
{
   
   /** The manager. */
   private VmlParser manager;
   
   /** The path. */
   private String path;
   
   /** The reference. */
   private String reference;

   /** The root. */
   private Object root;
   
   /**
    * Instantiates.
    *
    * @param parser the parser
    */
   public IncludeHandler(VmlParser parser)
   {
      manager = parser;
   }

   /**
    * reference.
    *
    * @param value the value
    */
   @VAttribute("reference")
   private void reference(String value)
   {
      reference = value;
   }

   /**
    * Resource.
    *
    * @param value the value
    */
   @VAttribute("resource")
   private void resource(String value)
   {
      path = value;
   }
   
   /**
    * End.
    *
    * @throws VmlException the vml exception
    */
   @VEnd
   private void end() throws VmlException
   {
      VmlParser parser = new VmlParser();
      Object rootObject = manager.getCurrentElement();
      parser.parse(rootObject, path);
      
      if (reference != null)
      {
         Referencer.putReference(reference, parser.getInnerRoot());
      }
      
      root = parser.getCurrentElement();
   }
   
   /**
    * Gets the component.
    *
    * @return the component
    */
   public Object getComponent()
   {
      return root;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy