private EOAttribute _attribute;
@SuppressWarnings("deprecation")
public IndexAttribute(EOAttribute attribute) {
_attribute = attribute;
NSDictionary dict = attribute.userInfo() != null ? attribute.userInfo() : NSDictionary.emptyDictionary();
_columnName = attribute.columnName();
boolean isClassProperty = _attribute.entity().classPropertyNames().contains(_attribute.name());
boolean isDataProperty = _attribute.className().endsWith("NSData");
boolean isStringProperty = _attribute.className().endsWith("String");
_termVector = (TermVector) classValue(dict, "termVector", TermVector.class, isClassProperty && !isDataProperty && isStringProperty ? "YES" : "NO");
_store = (Store) classValue(dict, "store", Store.class, "YES");
_index = (Index) classValue(dict, "index", Index.class, isClassProperty && !isDataProperty && isStringProperty ? "ANALYZED" : "NOT_ANALYZED");
String analyzerClass = (String) dict.objectForKey("analyzer");
if (analyzerClass == null && _columnName.matches("\\w+_(\\w+)")) {
String locale = _columnName.substring(_columnName.lastIndexOf('_') + 1).toLowerCase();
analyzerClass = LOCALES.objectForKey(locale);
if (analyzerClass != null) {
analyzerClass = ERXPatcher.classForName("org.apache.lucene.analysis." + locale + "." + analyzerClass).getName();
}
}
if (analyzerClass == null) {
analyzerClass = StandardAnalyzer.class.getName();
}
Class c = ERXPatcher.classForName(analyzerClass);
_analyzer = (Analyzer) _NSUtilities.instantiateObject(c, new Class[] { Version.class }, new Object[] { Version.LUCENE_20 }, true, false);
_format = (Format) create((String) dict.objectForKey("format"));
String numberFormat = (String) dict.objectForKey("numberformat");
if (numberFormat != null) {
_format = new NSNumberFormatter(numberFormat);
}
String dateformat = (String) dict.objectForKey("dateformat");
if (dateformat != null) {
_format = new NSTimestampFormatter(dateformat);
}
}