/*------------------------------------------------------------------------------------
Copyright (c)2000 TogetherSoft Corporation. Patents pending. All rights reserved. 
------------------------------------------------------------------------------------*/ 

package com.togethersoft.modules.xmleditor.dtd.impl;

import java.util.*;
import com.togethersoft.modules.xmleditor.dtd.*;
import com.togethersoft.modules.ejbframework.utils.ConfigProperties;

public class DTDAttributeDefImpl extends DTDValueDefImpl implements DTDAttributeDef
{
  /**
   * @supplierCardinality 1 
   */
  private DTDElementDefImpl m_elementDef = null;

  private String  m_name;
  private String  m_fullName = null;
  private boolean m_isHidden = false;

  //--------------------------------------------------------------------
  public DTDAttributeDefImpl (String name, int dataType)
  {
    super();
    m_name = name;
    setDataType (dataType);
  }

  //--------------------------------------------------------------------
  public DTDElementDef getContainingElementDef()
  {
    return m_elementDef;
  }

  //--------------------------------------------------------------------
  void setContainingElementDef (DTDElementDefImpl elementDef)
  {
    m_elementDef = elementDef;
  }

  //--------------------------------------------------------------------
  public String getName()
  {
    return m_name;
  }

  //--------------------------------------------------------------------
  public String getFullName()
  {
    return (m_fullName != null) ? m_fullName : m_name;
  }

  //--------------------------------------------------------------------
  public void setFullName (String fullName)
  {
    m_fullName = fullName;
  }

  //--------------------------------------------------------------------
  public void load (ConfigProperties prop, String prefix)
  {
    String s;
    String prefix2 = prefix + "attr." + m_name + '.';

    m_fullName = prop.getProperty (prefix2 + "title");

    s = prop.getProperty (prefix2 + "hidden");
    if (s != null && (s.equalsIgnoreCase("true") || s.trim().length() == 0))
      m_isHidden = true;

    super.load (prop, prefix2);
  }

  //--------------------------------------------------------------------
  public boolean isHidden()
  {
    return m_isHidden;
  }
}
