NodeSortRecordFactorypublic class NodeSortRecordFactory extends Object
Fields Summary |
---|
private static int | DESCENDING | private static int | NUMBER | private final DOM | _dom | private final String | _className | private Class | _class | private SortSettings | _sortSettings | protected Collator | _collator |
Constructors Summary |
---|
public NodeSortRecordFactory(DOM dom, String className, Translet translet, String[] order, String[] type)Creates a NodeSortRecord producing object. The DOM specifies which tree
to get the nodes to sort from, the class name specifies what auxillary
class to use to sort the nodes (this class is generated by the Sort
class), and the translet parameter is needed for methods called by
this object.
this(dom, className, translet, order, type, null, null);
| public NodeSortRecordFactory(DOM dom, String className, Translet translet, String[] order, String[] type, String[] lang, String[] caseOrder)Creates a NodeSortRecord producing object. The DOM specifies which tree
to get the nodes to sort from, the class name specifies what auxillary
class to use to sort the nodes (this class is generated by the Sort
class), and the translet parameter is needed for methods called by
this object.
try {
_dom = dom;
_className = className;
// This should return a Class definition if using TrAX
_class = translet.getAuxiliaryClass(className);
// This code is only run when the native API is used
if (_class == null) {
_class = ObjectFactory.findProviderClass(
className, ObjectFactory.findClassLoader(), true);
}
int levels = order.length;
int[] iOrder = new int[levels];
int[] iType = new int[levels];
for (int i = 0; i < levels; i++) {
if (order[i].length() == DESCENDING) {
iOrder[i] = NodeSortRecord.COMPARE_DESCENDING;
}
if (type[i].length() == NUMBER) {
iType[i] = NodeSortRecord.COMPARE_NUMERIC;
}
}
// Old NodeSortRecordFactory constructor had no lang or case_order
// arguments. Provide default values in that case for binary
// compatibility.
String[] emptyStringArray = null;
if (lang == null || caseOrder == null) {
int numSortKeys = order.length;
emptyStringArray = new String[numSortKeys];
// Set up array of zero-length strings as default values
// of lang and case_order
for (int i = 0; i < numSortKeys; i++) {
emptyStringArray[i] = "";
}
}
if (lang == null) {
lang = emptyStringArray;
}
if (caseOrder == null) {
caseOrder = emptyStringArray;
}
final int length = lang.length;
Locale[] locales = new Locale[length];
Collator[] collators = new Collator[length];
for (int i = 0; i< length; i++){
locales[i] = LocaleUtility.langToLocale(lang[i]);
collators[i] = Collator.getInstance(locales[i]);
}
_sortSettings = new SortSettings((AbstractTranslet) translet,
iOrder, iType, locales, collators,
caseOrder);
} catch (ClassNotFoundException e) {
throw new TransletException(e);
}
|
|