1  /*
     2   * Copyright the original author or authors.
     3   * 
     4   * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   * 
     8   *      http://www.mozilla.org/MPL/MPL-1.1.html
     9   * 
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  import org.as2lib.core.BasicClass;
    18  import org.as2lib.core.ObjectStringifier;
    19  import org.as2lib.util.Stringifier;
    20  
    21  /**
    22   * {@code Config} is the basic configuration class of the as2lib framework.
    23   * 
    24   * <p>It lets you configure global behavior of key features like the stringification
    25   * of classes and instances.
    26   * 
    27   * @author Martin Heidegger
    28   * @author Simon Wacker
    29   */
    30  class org.as2lib.Config extends BasicClass {
    31  	
    32  	/** Stringifier used to stringify objects. */
    33  	private static var objectStringifier:Stringifier;
    34  	
    35  	/**
    36  	 * Private constructor.
    37  	 */
    38  	private function Config(Void) {
    39  	}
    40  	
    41  	/**
    42  	 * Sets a new stringifier used to stringify objects.
    43  	 *
    44  	 * <p>If {@code newStringifier} is {@code null} or {@code undefined}
    45  	 * {@link #getObjectStringifier} will return the default stringifier.
    46  	 * 
    47  	 * @param newStringifier the new object stringifier
    48  	 */
    49  	public static function setObjectStringifier(newStringifier:Stringifier):Void {
    50  		objectStringifier = newStringifier;
    51  	}
    52  	
    53  	/**
    54  	 * Returns the stringifier used to stringify objects.
    55  	 *
    56  	 * <p>If no stringifier is set the default stringifier will be returned. This is an
    57  	 * instance of class {@link ObjectStringifier}.
    58  	 * 
    59  	 * @return the currently used object stringifier
    60  	 */
    61  	public static function getObjectStringifier(Void):Stringifier {
    62  		if (!objectStringifier) objectStringifier = new ObjectStringifier();
    63  		return objectStringifier;
    64  	}
    65  	
    66  }