  public Map<String, Component> readComponents(File directory)
  {
    if (!directory.isDirectory())
    {
      throw new IllegalArgumentException(
          directory.getAbsolutePath() + " is no Directory");
    }
    Map<String, Component> result = new HashMap<>();
    File[] files = directory.listFiles();
    for (File file : files)
    {
      String fileName = file.getName();
      if (fileName.endsWith(".xhtml"))
      {
        try
        {
          FileInputStream inputStream = new FileInputStream(file);
          Component component = parse(inputStream);
          if (component.getId() == null)
          {
            component.setId(fileName.substring(0, fileName.length() - 6));
          }
          result.put(component.getId(), component);
        }
        catch (FileNotFoundException e)
        {
          throw new RuntimeException(e);
        } 
        catch (SAXException e)
        {
          throw new RuntimeException(e);
        }
        catch (IOException e)
        {
          throw new RuntimeException(e);
        } 
        catch (ParserConfigurationException e)
        {
          throw new RuntimeException(e);
        }
      }
    }
    return result;
  }  

  public Map<String, Component> readComponents(File sourceDirectory)
  {
    if (sourceDirectory == null)
    {
      throw new NullPointerException("sourceDirectory must not be null");
    }
    if (!sourceDirectory.isDirectory())
    {
      throw new IllegalArgumentException(
          sourceDirectory.getAbsolutePath() + " is no Directory");
    }
    Map<String, Component> result = new HashMap<>();
    File[] files = sourceDirectory.listFiles();
    for (File file : files)
    {
      String fileName = file.getName();
      if (fileName.endsWith(".xhtml"))
      {
        try
        {
          FileInputStream inputStream = new FileInputStream(file);
          Component component = parse(inputStream);
          if (component.getId() == null)
          {
            component.setId(fileName.substring(0, fileName.length() - 6));
          }
          result.put(component.getId(), component);
        }
        catch (FileNotFoundException e)
        {
          throw new RuntimeException(e);
        } 
        catch (SAXException e)
        {
          throw new RuntimeException(e);
        }
        catch (IOException e)
        {
          throw new RuntimeException(e);
        } 
        catch (ParserConfigurationException e)
        {
          throw new RuntimeException(e);
        }
      }
    }
    return result;
  }  
