/**
  * Puts all of the writable properties from the given BeanMap into this
  * BeanMap. Read-only and Write-only properties will be ignored.
  *
  * @param map  the BeanMap whose properties to put
  */
 public void putAllWriteable(BeanMap map)
 {
     java.util.Iterator <Object> readableKeys = map.readMethods.keySet().iterator();
     while (readableKeys.hasNext())
     {
         Object key = readableKeys.next();
         if (getWriteMethod(key) != null)
         {
             this.put(key, map.get(key));
         }
     }
 }
 /**
  * Constructs a new <code>MyMapEntry</code>.
  *
  * @param owner  the BeanMap this entry belongs to
  * @param key  the key for this entry
  * @param value  the value for this entry
  */
 protected internal MyMapEntry(BeanMap owner, Object key, Object value)
     : base(key, value)
 {
     this.owner = owner;
 }
 public IAC_EntryIterator(BeanMap root)
 {
     this.root = root;
     this.iter = root.keyIterator();
 }
 public IAC_ValueIterator(BeanMap root)
 {
     this.root = root;
     iter      = root.keyIterator();
 }
 public IAC_EntrySet(BeanMap root)
 {
     this.root = root;
 }
        /**
         * Clone this bean map using the following process:
         *
         * <ul>
         * <li>If there is no underlying bean, return a cloned BeanMap without a
         * bean.
         *
         * <li>Since there is an underlying bean, try to instantiate a new bean of
         * the same type using Class.newInstance().
         *
         * <li>If the instantiation fails, throw a CloneNotSupportedException
         *
         * <li>Clone the bean map and set the newly instantiated bean as the
         * underlying bean for the bean map.
         *
         * <li>Copy each property that is both readable and writable from the
         * existing object to a cloned bean map.
         *
         * <li>If anything fails along the way, throw a
         * CloneNotSupportedException.
         *
         * <ul>
         */
        public Object clone()
        {//throws CloneNotSupportedException {
            BeanMap newMap = (BeanMap)base.MemberwiseClone();

            if (bean == null)
            {
                // no bean, just an empty bean map at the moment.  return a newly
                // cloned and empty bean map.
                return(newMap);
            }

            Object newBean = null;

            java.lang.Class beanClass = null;
            try
            {
                beanClass = bean.getClass();
                newBean   = beanClass.newInstance();
            }
            catch (Exception e)
            {
                // unable to instantiate
                throw new java.lang.CloneNotSupportedException
                          ("Unable to instantiate the underlying bean \"" +
                          beanClass.getName() + "\": " + e);
            }

            try
            {
                newMap.setBean(newBean);
            }
            catch (Exception exception)
            {
                throw new java.lang.CloneNotSupportedException
                          ("Unable to set bean in the cloned bean map: " +
                          exception);
            }

            try
            {
                // copy only properties that are readable and writable.  If its
                // not readable, we can't get the value from the old map.  If
                // its not writable, we can't write a value into the new map.
                java.util.Iterator <Object> readableKeys = readMethods.keySet().iterator();
                while (readableKeys.hasNext())
                {
                    Object key = readableKeys.next();
                    if (getWriteMethod(key) != null)
                    {
                        newMap.put(key, get(key));
                    }
                }
            }
            catch (Exception exception)
            {
                throw new java.lang.CloneNotSupportedException
                          ("Unable to copy bean values to cloned bean map: " +
                          exception);
            }

            return(newMap);
        }