1 20 21 package org.apache.directory.ldapstudio.browser.core.model.schema; 22 23 24 import java.util.Arrays ; 25 import java.util.HashSet ; 26 import java.util.Iterator ; 27 import java.util.Set ; 28 29 import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin; 30 31 32 81 82 public class LdapSyntaxDescription extends SchemaPart 83 { 84 85 private static final long serialVersionUID = 2740623603305997234L; 86 87 public static final String DN_OID = "1.3.6.1.4.1.1466.115.121.1.12"; 88 89 public static final LdapSyntaxDescription DUMMY; 90 static 91 { 92 DUMMY = new LdapSyntaxDescription(); 93 DUMMY.setSchema( Schema.DEFAULT_SCHEMA ); 94 DUMMY.setNumericOID( "" ); 95 DUMMY.setDesc( "" ); 96 } 97 98 99 public LdapSyntaxDescription() 100 { 101 super(); 102 } 103 104 105 public int compareTo( Object o ) 106 { 107 if ( o instanceof LdapSyntaxDescription ) 108 { 109 return this.toString().compareTo( o.toString() ); 110 } 111 else 112 { 113 throw new ClassCastException ( "Object of type " + this.getClass().getName() + " required." ); 114 } 115 } 116 117 118 123 public String toString() 124 { 125 if ( this.desc != null && this.desc.length() > 0 ) 126 { 127 return this.desc; 128 } 129 else if ( numericOID != null ) 130 { 131 return this.numericOID; 132 } 133 else 134 { 135 return ""; 136 } 137 } 138 139 140 145 public boolean isString() 146 { 147 return !isBinary(); 148 } 149 150 151 157 public boolean isBinary() 158 { 159 Set binarySyntaxOids = BrowserCorePlugin.getDefault().getCorePreferences().getBinarySyntaxOids(); 161 if ( binarySyntaxOids.contains( this.numericOID ) ) 162 { 163 return true; 164 } 165 166 return false; 168 } 169 170 171 175 public AttributeTypeDescription[] getUsedFromAttributeTypeDescription() 176 { 177 Set usedFromSet = new HashSet (); 178 for ( Iterator it = this.getSchema().getAtdMapByName().values().iterator(); it.hasNext(); ) 179 { 180 AttributeTypeDescription atd = ( AttributeTypeDescription ) it.next(); 181 if ( atd.getSyntaxDescriptionNumericOIDTransitive() != null && this.numericOID != null 182 && atd.getSyntaxDescriptionNumericOIDTransitive().toLowerCase().equals( this.numericOID.toLowerCase() ) ) 183 { 184 usedFromSet.add( atd ); 185 } 186 } 187 AttributeTypeDescription[] atds = ( AttributeTypeDescription[] ) usedFromSet 188 .toArray( new AttributeTypeDescription[0] ); 189 Arrays.sort( atds ); 190 return atds; 191 } 192 193 } 194 | Popular Tags |