private TableSyntaxNode[] selectAndSortNodes( XlsModuleSyntaxNode moduleSyntaxNode, ISelector<ISyntaxNode> childSelector, Comparator<TableSyntaxNode> nodesComparator) { ArrayList<TableSyntaxNode> childSyntaxNodes = new ArrayList<TableSyntaxNode>(); for (TableSyntaxNode tsn : moduleSyntaxNode.getXlsTableSyntaxNodes()) { if (childSelector == null || childSelector.select(tsn)) { childSyntaxNodes.add(tsn); } } TableSyntaxNode[] tableSyntaxNodes = childSyntaxNodes.toArray(new TableSyntaxNode[childSyntaxNodes.size()]); if (nodesComparator != null) { try { Arrays.sort(tableSyntaxNodes, nodesComparator); } catch (Exception e) { // ignore sort exceptions. } } return tableSyntaxNodes; }
private TableSyntaxNode[] selectSpreadsheetNodes( XlsModuleSyntaxNode moduleSyntaxNode, ISelector<ISyntaxNode> childSelector) { ArrayList<TableSyntaxNode> childSyntaxNodes = new ArrayList<TableSyntaxNode>(); for (TableSyntaxNode tsn : moduleSyntaxNode.getXlsTableSyntaxNodes()) { if (childSelector == null || childSelector.select(tsn)) { childSyntaxNodes.add(tsn); } } return childSyntaxNodes.toArray(new TableSyntaxNode[childSyntaxNodes.size()]); }