// ----------------------------------------------------------------------- // // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You 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 Lucene.Net.Analysis.TokenAttributes { using System.Diagnostics.CodeAnalysis; using Lucene.Net.Util; /// /// A 's lexical type. The default value is 'word'. /// [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix", Justification = "The class was called Attribute in Java. It would be fun to call it Annotation. However, " + "its probably best to try to honor the correlating names when possible.")] public class TypeAttribute : AttributeBase, ITypeAttribute { /// /// The default type for the 's lexical type. /// public const string DefaultType = "word"; /// /// Initializes a new instance of the class. /// public TypeAttribute() : this(DefaultType) { } /// /// Initializes a new instance of the class. /// /// The type. public TypeAttribute(string type) { this.Type = type; } /// /// Gets or sets the 's lexical type. /// /// The type. public string Type { get; set; } /// /// Clears the instance. /// public override void Clear() { this.Type = DefaultType; } /// /// Creates a clone of the object, generally shallow. /// /// an the clone of the current instance. public override AttributeBase Clone() { return new TypeAttribute() { Type = this.Type }; } /// /// Copies this instance to the specified target. /// /// The attribute base. public override void CopyTo(AttributeBase attributeBase) { ITypeAttribute attribute = (ITypeAttribute)attributeBase; attribute.Type = this.Type; } /// /// Determines whether the specified is equal to this instance. /// /// The to compare with this instance. /// /// true if the specified is equal to this instance; otherwise, false. /// public override bool Equals(object obj) { if (obj == this) return true; TypeAttribute attribute = obj as TypeAttribute; return attribute != null && attribute.Type.Equals(this.Type); } /// /// Returns a hash code for this instance. /// /// /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// public override int GetHashCode() { return this.Type.GetHashCode(); } } }