// Copyright 2003-2004 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. namespace Apache.Avalon.Composition.Data { using System; /// A logging category descriptor hierachy. The descriptor contains a category name, a /// optional priority value, and an optional target. If the priority or target values /// null, the resulting value will be derived from the parent category desciptor. A /// category descriptor may 0-n subsidiary categories. CategoryDirective names are relative. /// For example, the category "orb" will appear as "my-app.orb" if the parent category /// name is "my-app". /// ///

XML

///
	/// <categories priority="INFO">
	/// <category priority="DEBUG"  name="loader" />
	/// <category priority="WARN"  name="types" />
	/// <category priority="ERROR"  name="types.builder" target="default"/>
	/// <category name="profiles" />
	/// <category name="lifecycle" />
	/// <category name="verifier" />
	/// </categories>
	/// 
///
/// Avalon Development Team /// /// $Revision: 1.2 $ $Date: 2004/02/28 22:15:36 $ /// [Serializable] public class CategoryDirective { /// Constant category priority value for debug mode. public const System.String DEBUG = "DEBUG"; /// Constant category priority value for info mode. public const System.String INFO = "INFO"; /// Constant category priority value for warning mode. public const System.String WARN = "WARN"; /// Constant category priority value for error mode. public const System.String ERROR = "ERROR"; /// The logging category name. private System.String m_name; /// The default logging priority. private System.String m_priority; /// The default logging target. private System.String m_target; /// Creation of a new CategoryDirective using a supplied name. /// /// /// the category name /// public CategoryDirective(System.String name):this(name, null, null) { } /// Creation of a new CategoryDirective using a supplied name and priority. /// /// /// the category name /// /// the category priority - DEBUG, INFO, WARN, or ERROR /// public CategoryDirective(System.String name, System.String priority):this(name, priority, null) { } /// Creation of a new CategoryDirective using a supplied name, priority, target and /// collection of subsidiary categories. /// /// /// the category name /// /// the category priority - DEBUG, INFO, WARN, or ERROR /// /// the name of a logging category target /// /// public CategoryDirective(System.String name, System.String priority, System.String target) { m_name = name; m_target = target; if ((System.Object) priority != null) { m_priority = priority.Trim().ToUpper(); } else { m_priority = null; } } /// Return the category name. /// /// /// the category name /// public virtual System.String Name { get { return m_name; } } /// Return the logging priority for the category. /// /// /// the logging priority for the category /// public virtual System.String Priority { get { return m_priority; } } /// Return the default log target for the category. /// /// /// the default target name /// public virtual System.String Target { get { return m_target; } } public override bool Equals(System.Object other) { if (null == other) { return false; } if (!(other is CategoryDirective)) { return false; } CategoryDirective test = (CategoryDirective) other; return (equalName(test.Name) && equalPriority(test.Priority) && equalTarget(test.Target)); } private bool equalName(System.String other) { if ((System.Object) m_name == null) { return (System.Object) other == null; } else { return m_name.Equals(other); } } private bool equalPriority(System.String other) { if ((System.Object) m_priority == null) { return (System.Object) other == null; } else { return m_priority.Equals(other); } } private bool equalTarget(System.String other) { if ((System.Object) m_target == null) { return (System.Object) other == null; } else { return m_target.Equals(other); } } public override int GetHashCode() { int hash = m_name.GetHashCode(); if ((System.Object) m_priority != null) { hash ^= m_priority.GetHashCode(); } if ((System.Object) m_target != null) { hash ^= m_target.GetHashCode(); } return hash; } } }