/*
 * <copyright> Copyright (c) 2006 by Know-Center, Graz, Austria </copyright>
 * 
 * This software is the confidential and proprietary information of Know-Center,
 * Graz, Austria. You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Know-Center.
 * 
 * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
 * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 * 
 * $Id: Entry.java,v 1.3 2006/08/25 17:08:19 wprinz Exp $
 */
package at.knowcenter.wag.egov.egiz.table;

import java.io.Serializable;

/**
 * This class implements a table entry for different types. A table entry can be
 * styled and setting there column dimensions. The default value for the column
 * dimension is 1. To declare the type of the entry use the public
 * <code>TYPE_</code> definitions.
 * 
 * @author wlackner
 */
public class Entry implements Serializable
{

  /**
   * SVUID.
   */
  private static final long serialVersionUID = -7952755200668528348L;

  /**
   * Type for a text entry.
   */
  public final static int TYPE_CAPTION = 0;

  /**
   * Type for a text entry.
   */
  public final static int TYPE_VALUE = 1;

  /**
   * Type for an image entry.
   */
  public final static int TYPE_IMAGE = 2;

  /**
   * Type for a table entry.
   */
  public final static int TYPE_TABLE = 3;

  /**
   * The type info holder, default value is 0!
   */
  private int type_ = 0;

  /**
   * The entry value.
   */
  private Object value_ = null;

  /**
   * The key value
   */
  private String key_ = null;

  /**
   * The entry style information.
   */
  private Style style_ = null;

  /**
   * The column dimension.
   */
  private int colSpan_ = 1;

  /**
   * Text wrap indicator, default is <code>false</code>.
   */
  private boolean noWrap_ = false;

  /**
   * The empty constructor.
   */
  public Entry()
  {
  }

  /**
   * A constructor setting the type and the value.
   * 
   * @param type
   *          the entry type to set
   * @param value
   *          the entry value to set
   */
  public Entry(int type, Object value, String key)
  {
    type_ = type;
    value_ = value;
    key_ = key;
  }

  /**
   * @return Returns the entry style.
   */
  public Style getStyle()
  {
    return style_;
  }

  /**
   * @param style
   *          The style to set.
   */
  public void setStyle(Style style)
  {
    style_ = style;
  }

  /**
   * @return Returns the entry type.
   */
  public int getType()
  {
    return type_;
  }

  /**
   * @param type
   *          The type to set.
   */
  public void setType(int type)
  {
    type_ = type;
  }

  /**
   * @return Returns the entry value.
   */
  public Object getValue()
  {
    return value_;
  }

  /**
   * @param value
   *          The value to set.
   */
  public void setValue(Object value)
  {
    value_ = value;
  }

  /**
   * @return Returns the key.
   */

  public String getKey()
  {
    return key_;
  }

  /**
   * @param key
   *          The key to set.
   */
  public void setKey(String key)
  {
    key_ = key;
  }

  /**
   * @return Returns the colSpan.
   */
  public int getColSpan()
  {
    return colSpan_;
  }

  /**
   * @param colSpan
   *          The colSpan to set.
   */
  public void setColSpan(int colSpan)
  {
    colSpan_ = colSpan;
  }

  /**
   * @return Returns the wrap indicator.
   */
  public boolean isNoWrap()
  {
    return noWrap_;
  }

  /**
   * @param noWrap
   *          The wrap indicator to set.
   */
  public void setNoWrap(boolean noWrap)
  {
    noWrap_ = noWrap;
  }

  /**
   * The toString method, used for tests or debugging.
   */
  public String toString()
  {
    Object obj = getValue();
    String value = null;
    if (obj != null)
    {
      value = obj.toString();
    }
    return "Type:" + getType() + " Value:" + value + " ColSpan:" + getColSpan();
  }

}