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

net.sf.jett.tag.TagContext Maven / Gradle / Ivy

package net.sf.jett.tag;

import java.util.List;
import java.util.Map;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Drawing;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;

import net.sf.jett.model.Block;

/**
 * A TagContext object represents the context associated with a
 * Tag.
 *
 * @author Randy Gettman
 */
public class TagContext
{
   private Sheet mySheet;
   private Block myBlock;
   private Map myBeans;
   private Map myProcessedCells;
   private Drawing myDrawing;
   private List myMergedRegions;
   private List> myConditionalFormattingRegions;
   private Tag myCurrTag;

   /**
    * Construct a TagContext, initializing things to null.
    */
   public TagContext()
   {
      mySheet = null;
      myBlock = null;
      myBeans = null;
      myDrawing = null;
      myMergedRegions = null;
      myConditionalFormattingRegions = null;
   }

   /**
    * Returns the Sheet on which a tag is found.
    * @return A Sheet.
    */
   public Sheet getSheet()
   {
      return mySheet;
   }

   /**
    * Sets the Sheet on which a tag is found.
    * @param sheet A Sheet.
    */
   public void setSheet(Sheet sheet)
   {
      this.mySheet = sheet;
   }

   /**
    * Returns the Block that applies to a tag.
    * @return A Block.
    */
   public Block getBlock()
   {
      return myBlock;
   }

   /**
    * Sets the Block that applies to a tag.
    * @param block A Block.
    */
   public void setBlock(Block block)
   {
      this.myBlock = block;
   }

   /**
    * Returns the Map of beans.
    * @return A Map of bean names and objects.
    */
   public Map getBeans()
   {
      return myBeans;
   }

   /**
    * Sets the Map of beans.
    * @param beans A Map of bean names and objects.
    */
   public void setBeans(Map beans)
   {
      this.myBeans = beans;
   }

   /**
    * Returns the Map of Cells that have already been
    * processed.
    * @return A Map of Cells.
    */
   public Map getProcessedCellsMap()
   {
      return myProcessedCells;
   }

   /**
    * Sets the Map of Cells that have already been
    * processed.
    * @param processedCells A Map of Cells.
    */
   public void setProcessedCellsMap(Map processedCells)
   {
      myProcessedCells = processedCells;
   }

   /**
    * Returns the Sheet's Drawing object, creating it
    * if it doesn't exist.  It is hoped that this would be replaced by a call
    * to getDrawingPatriarch in the POI "ss" package, and that
    * that call would NOT corrupt drawings, charts, etc.
    * @return A Drawing.
    * @since 0.2.0
    */
   public Drawing createDrawing()
   {
      if (myDrawing == null)
      {
         myDrawing = mySheet.createDrawingPatriarch();
      }
      return myDrawing;
   }

   /**
    * Returns the Sheet's Drawing object, if it
    * exists yet.
    * @return A Drawing, or null if it doesn't exist
    *    yet.
    * @since 0.2.0
    */
   public Drawing getDrawing()
   {
      return myDrawing;
   }

   /**
    * Sets the Sheet's Drawing object.  This is
    * usually used to initialize a TagContext from another
    * TagContext, copying the Drawing object.
    * @param drawing A Drawing.
    * @since 0.2.0
    */
   public void setDrawing(Drawing drawing)
   {
      myDrawing = drawing;
   }

   /**
    * Sets the List of CellRangeAddress objects to be
    * manipulated through this TagContext.  All merged region
    * manipulation for a Sheet goes through this list, instead of
    * the Sheet itself, for performance reasons.
    * @param mergedRegions A List of
    *    CellRangeAddresses.
    * @since 0.8.0
    */
   public void setMergedRegions(List mergedRegions)
   {
      myMergedRegions = mergedRegions;
   }

   /**
    * Returns the List of CellRangeAddress objects on
    * the current Sheet.  For performance reasons, the
    * SheetTransformer reads all merged regions into this list
    * before transformation, all manipulations are done to this list, and after
    * transformation, the list is re-applied to the Sheet.
    * @return A List of CellRangeAddresses.
    * @since 0.8.0
    */
   public List getMergedRegions()
   {
      return myMergedRegions;
   }
   
   /**
    * Sets the List of Lists of
    * CellRangeAddress objects to be manipulated through this
    * TagContext.  All conditional formatting range manipulation
    * for a Sheet goes through this list.  Each individual list
    * inside the outer list represents the updated cell range addresses for the
    * ConditionalFormatting at the corresponding index.
    * @param conditionalFormattingRegions A List of Lists of
    *    CellRangeAddresses.
    * @since 0.9.0
    */
   public void setConditionalFormattingRegions(List> conditionalFormattingRegions)
   {
      myConditionalFormattingRegions = conditionalFormattingRegions;
   }

   /**
    * Returns the List of Lists of
    * CellRangeAddress objects to be manipulated through this
    * TagContext.  All conditional formatting range manipulation
    * for a Sheet goes through this list.  Each individual list
    * inside the outer list represents the updated cell range addresses for the
    * ConditionalFormatting at the corresponding index.
    * @return A List of Lists of
    *    CellRangeAddresses.
    * @since 0.9.0
    */
   public List> getConditionalFormattingRegions()
   {
      return myConditionalFormattingRegions;
   }

   /**
    * Returns the current Tag for this context.
    * @return The current Tag for this context.
    * @since 0.9.0
    */
   public Tag getCurrentTag()
   {
      return myCurrTag;
   }

   /**
    * Sets the current Tag for this context.
    * @param tag The current Tag for this context.
    * @since 0.9.0
    */
   public void setCurrentTag(Tag tag)
   {
      myCurrTag = tag;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy