001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * https://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.model.filter; 021 022 023import org.apache.directory.api.ldap.model.entry.Value; 024import org.apache.directory.api.ldap.model.schema.AttributeType; 025 026 027/** 028 * A assertion value node for Equality. 029 * 030 * @param <T> The Value type 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 */ 034public class EqualityNode<T> extends SimpleNode<T> 035{ 036 /** 037 * Creates a new Equality object. 038 * 039 * @param attributeType the attributeType 040 * @param value the value to test for 041 */ 042 public EqualityNode( AttributeType attributeType, Value value ) 043 { 044 super( attributeType, value, AssertionType.EQUALITY ); 045 } 046 047 048 /** 049 * Creates a new Equality object. 050 * 051 * @param attribute the attribute name 052 * @param value the value to test for 053 */ 054 public EqualityNode( String attribute, byte[] value ) 055 { 056 super( attribute, value, AssertionType.EQUALITY ); 057 } 058 059 060 /** 061 * Creates a new Equality object. 062 * 063 * @param attribute the attribute name 064 * @param value the value to test for 065 */ 066 public EqualityNode( String attribute, String value ) 067 { 068 super( attribute, value, AssertionType.EQUALITY ); 069 } 070 071 072 /** 073 * @see Object#toString() 074 * @return A string representing the AndNode 075 */ 076 @Override 077 public String toString() 078 { 079 StringBuilder buf = new StringBuilder(); 080 081 buf.append( '(' ); 082 083 if ( attributeType != null ) 084 { 085 buf.append( attributeType.getName() ); 086 } 087 else 088 { 089 buf.append( attribute ); 090 } 091 092 buf.append( "=" ); 093 094 String escapedValue = getEscapedValue(); 095 096 if ( escapedValue != null ) 097 { 098 buf.append( escapedValue ); 099 } 100 101 buf.append( super.toString() ); 102 103 buf.append( ')' ); 104 105 return buf.toString(); 106 } 107}