1 17 package org.alfresco.repo.dictionary; 18 19 import java.util.Locale ; 20 21 import org.alfresco.i18n.I18NUtil; 22 import org.alfresco.service.cmr.dictionary.DictionaryException; 23 import org.alfresco.service.cmr.dictionary.DataTypeDefinition; 24 import org.alfresco.service.cmr.dictionary.ModelDefinition; 25 import org.alfresco.service.namespace.NamespacePrefixResolver; 26 import org.alfresco.service.namespace.QName; 27 28 29 35 class M2DataTypeDefinition implements DataTypeDefinition 36 { 37 private ModelDefinition model; 38 private QName name; 39 private M2DataType dataType; 40 41 42 M2DataTypeDefinition(ModelDefinition model, M2DataType propertyType, NamespacePrefixResolver resolver) 43 { 44 this.model = model; 45 this.name = QName.createQName(propertyType.getName(), resolver); 46 this.dataType = propertyType; 47 } 48 49 50 void resolveDependencies(ModelQuery query) 51 { 52 String javaClass = dataType.getJavaClassName(); 54 if (javaClass == null) 55 { 56 throw new DictionaryException("Java class of data type " + name.toPrefixString() + " must be specified"); 57 } 58 59 try 61 { 62 Class.forName(javaClass); 63 } 64 catch (ClassNotFoundException e) 65 { 66 throw new DictionaryException("Java class " + javaClass + " of data type " + name.toPrefixString() + " is invalid", e); 67 } 68 } 69 70 73 public String toString() 74 { 75 return getName().toString(); 76 } 77 78 81 public ModelDefinition getModel() 82 { 83 return model; 84 } 85 86 89 public QName getName() 90 { 91 return name; 92 } 93 94 95 98 public String getTitle() 99 { 100 String value = M2Label.getLabel(model, "datatype", name, "title"); 101 if (value == null) 102 { 103 value = dataType.getTitle(); 104 } 105 return value; 106 } 107 108 109 112 public String getDescription() 113 { 114 String value = M2Label.getLabel(model, "datatype", name, "description"); 115 if (value == null) 116 { 117 value = dataType.getDescription(); 118 } 119 return value; 120 } 121 122 125 public String getAnalyserClassName() 126 { 127 return getAnalyserClassName(I18NUtil.getLocale()); 128 } 129 130 133 public String getAnalyserClassName(Locale locale) 134 { 135 String value = M2Label.getLabel(locale, model, "datatype", name, "analyzer"); 136 if (value == null) 137 { 138 value = dataType.getAnalyserClassName(); 139 } 140 return value; 141 } 142 143 146 public String getJavaClassName() 147 { 148 return dataType.getJavaClassName(); 149 } 150 151 } 152 | Popular Tags |