1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
21
22
23 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
24 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
25 import org.apache.directory.api.util.Strings;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 @SuppressWarnings("serial")
44 public class DerefAliasSyntaxChecker extends SyntaxChecker
45 {
46
47 private static final Logger LOG = LoggerFactory.getLogger( DerefAliasSyntaxChecker.class );
48
49
50
51
52
53 public DerefAliasSyntaxChecker()
54 {
55 super( SchemaConstants.DEREF_ALIAS_SYNTAX );
56 }
57
58
59
60
61
62 public boolean isValidSyntax( Object value )
63 {
64 String strValue = null;
65
66 if ( value == null )
67 {
68 LOG.debug( "Syntax invalid for 'null'" );
69 return false;
70 }
71
72 if ( value instanceof String )
73 {
74 strValue = ( String ) value;
75 }
76 else if ( value instanceof byte[] )
77 {
78 strValue = Strings.utf8ToString( ( byte[] ) value );
79 }
80 else
81 {
82 strValue = value.toString();
83 }
84
85 strValue = Strings.trim( Strings.toLowerCase( strValue ) );
86
87 return ( "never".equals( strValue ) ||
88 "finding".equals( strValue ) ||
89 "searching".equals( strValue ) || "always".equals( strValue ) );
90 }
91 }