/*
 * JBoss, Home of Professional Open Source
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package org.jboss.services.xml;

import java.util.Map;
import java.util.Iterator;
import java.util.Properties;

import org.jboss.util.xml.JBossEntityResolver;

/**
 A simple mbean for managing the static JBossEntityResolver class entity
 mappings.

 @todo update this to support xml catalog mappings

 @author Scott.Stark@jboss.org
 @version $Revision: 1.1 $
 */
public class JBossEntityResolverMgr
   implements JBossEntityResolverMgrMBean
{

   public boolean isWarnOnNonFileURLs()
   {
      return JBossEntityResolver.isWarnOnNonFileURLs();
   }
   public void setWarnOnNonFileURLs(boolean flag)
   {
      JBossEntityResolver.setWarnOnNonFileURLs(flag);
   }

   public Properties getEntityMap()
   {
      Map map = JBossEntityResolver.getEntityMap();
      Properties props = new Properties();
      Iterator entries = map.entrySet().iterator();
      while( entries.hasNext() )
      {
         Map.Entry entry = (Map.Entry) entries.next();
         String key = (String) entry.getKey();
         String value = (String) entry.getValue();
         props.setProperty(key, value);
      }
      return props;
   }
   public void setEntityMap(Properties map)
   {
      Iterator entries = map.entrySet().iterator();
      while( entries.hasNext() )
      {
         Map.Entry entry = (Map.Entry) entries.next();
         String key = (String) entry.getKey();
         String value = (String) entry.getValue();
         JBossEntityResolver.registerEntity(key, value);
      }
   }

   public void registerEntity(String id, String file)
   {
      JBossEntityResolver.registerEntity(id, file);
   }
}
