/*
 * Copyright (c) 2003-2004, Franz-Josef Elmer, All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met:
 * 
 * - Redistributions of source code must retain the above copyright notice, 
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright notice, 
 *   this list of conditions and the following disclaimer in the documentation 
 *   and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */
package classycle.dependency;

import java.util.HashMap;


/**
 * @author  Franz-Josef Elmer
 */
public class DefaultPreferenceFactory implements PreferenceFactory
{
  public static final Preference ONLY_SHORTEST_PATHS 
                  = new DefaultPreference("onlyShortestPaths");
  public static final Preference ALL_PATHS = new DefaultPreference("allPaths");
  public static final Preference ALL_RESULTS 
                  = new DefaultPreference("allResults");
  public static final Preference ONLY_FAILURES 
                  = new DefaultPreference("onlyFailures");
  
  private static class DefaultPreference implements Preference
  {
    private static final HashMap REPOSITORY = new HashMap();
    public static Preference getPreference(String key)
    {
      return (Preference) REPOSITORY.get(key);
    }
    private final String _key; 
    protected DefaultPreference(String key)
    {
      _key = key;
      if (REPOSITORY.containsKey(key))
      {
        throw new IllegalArgumentException(
                    "There exists already an instance for '" + key + "'.");
      }
      REPOSITORY.put(key, this);
    }
    public final String getKey()
    {
      return _key;
    }
    public String toString()
    {
      return getKey();
    }
  }

  public Preference get(String key)
  {
    return DefaultPreference.getPreference(key);
  }

}

@@ -1445,16 +1445,744 @@
 ;%0A%0A%0A/**%0A
+ * Factory of %7B@link Preference Preferences%7D known by the %0A * %7B@link DefaultResultRenderer%7D.%0A * %0A * %3Ctable border=%221%22 cellspacing=%220%22 cellpadding=%225%22%3E%0A *   %3Ctr%3E%3Cth%3EPreference Key%3C/th%3E%3Cth%3EDescription%3C/th%3E%3C/tr%3E%0A *   %3Ctr%3E%3Ctd%3E%3Ctt%3EonlyShortestPaths%3C/tt%3E%3C/td%3E%0A *       %3Ctd%3EOnly the shortest paths are reported in the case of%0A *           unwanted dependencies.%3C/td%3E%0A *   %3C/tr%3E%0A *   %3Ctr%3E%3Ctd%3E%3Ctt%3EallPaths%3C/tt%3E%3C/td%3E%0A *       %3Ctd%3EAll paths are reported in the case of%0A *           unwanted dependencies.%3C/td%3E%0A *   %3C/tr%3E%0A *   %3Ctr%3E%3Ctd%3E%3Ctt%3EonlyFailures%3C/tt%3E%3C/td%3E%0A *       %3Ctd%3EOnly results are reported which are not ok.%3C/td%3E%0A *   %3C/tr%3E%0A *   %3Ctr%3E%3Ctd%3E%3Ctt%3EallResults%3C/tt%3E%3C/td%3E%0A *       %3Ctd%3EAll results are reported.%3C/td%3E%0A *   %3C/tr%3E%0A * %3C/table%3E%0A
  * @auth

add Javadoc