public final class CamelCaseInsightInputFilter extends InsightInputFilter
This is a singleton class accessible through INSTANCE
CamelCaseFilter
Modifier and Type | Field and Description |
---|---|
static CamelCaseInsightInputFilter |
INSTANCE
The CamelCaseInsightInputFilter class is a singleton.
|
Modifier and Type | Method and Description |
---|---|
ListDataItem |
findClosestDataItem(ListDataItem[] dataList, java.lang.String name)
Utility routine to find the
ListDataItem with display name, as returned by getName() that is closest to the provided name. |
java.lang.String |
findCommonPrefix(ListDataItem[] dataList, java.lang.String prefix)
Utility routine to find the common prefix of
ListDataItems the data list that begin with the specified name. |
java.util.Comparator<ListDataItem> |
getComparator(java.lang.String prefix)
Returns the comparator suitable to sort a list according the that prefix.
|
ListDataItem[] |
getMatchingData(ListDataItem[] dataList, java.lang.String prefix)
Utility routine which fetches the subset of data items in this list model that match with the given CamelCase pattern specified.
|
java.util.ArrayList<ListDataItem> |
getMatchingDataList(ListDataItem[] dataList, java.lang.String prefix) |
void |
sort(ListDataItem[] listDataItems, java.lang.String prefix)
Sort the list based on the input: If the user started with a lowercase, put the lowercase first.
|
protected void |
sortData(ListDataItem[] dataList) |
public static final CamelCaseInsightInputFilter INSTANCE
protected void sortData(ListDataItem[] dataList)
sortData
in class InsightInputFilter
public ListDataItem findClosestDataItem(ListDataItem[] dataList, java.lang.String name)
InsightInputFilter
ListDataItem
with display name, as returned by getName()
that is closest to the provided name. For example, suppose the user had the following items in the list:
If the passed in name is "equalsFoo()", the data item returned will be "equalsIgnoreCase()". If the passed in name is "regionMatches()", the data item returned will be "substring()".
This utility routine can be used by clients to help locate the closest data item that should be selected in an insight list so that the list tracks what the user is typing.
findClosestDataItem
in class InsightInputFilter
name
- the display name to find the closest data item forpublic ListDataItem[] getMatchingData(ListDataItem[] dataList, java.lang.String prefix)
Then there are 2 items which match the prefix "DM", and this routine will return an array of those 2 items. Note that uppercase items match lowercase prefixes. For example "dM" would return "DefaultMutableTreeNode" and "DesktopManager" and "jb" would return "JButton". However the reverse is not true and "EQ" would not return "equalsIgnoreCase".
Note that if the prefix is an empty string, "", then all items will be returned. If there are no items that start with the specified prefix, an empty array will be returned.
getMatchingData
in class InsightInputFilter
prefix
- the prefix to search for matching itemspublic java.util.ArrayList<ListDataItem> getMatchingDataList(ListDataItem[] dataList, java.lang.String prefix)
public void sort(ListDataItem[] listDataItems, java.lang.String prefix)
listDataItems
-prefix
-public java.util.Comparator<ListDataItem> getComparator(java.lang.String prefix)
prefix
-public java.lang.String findCommonPrefix(ListDataItem[] dataList, java.lang.String prefix)
ListDataItems
the data list that begin with the specified name. As with findClosestDataItem()
, the name of the ListDataItem
used is what is returned by getName()
.
Note that a case-insensitive comparison is used for determining the common prefix but the prefix's casing is preserved. So for example, if the specified name is "eq", and the following data items are in the list:
Then the common prefix is "equals", and since the first data item is "EQUALS_SOMETHING", the common prefix returned will be "eqUALS".
If there are no items that start with the specified name, an empty (zero-length) String will be returned.
findCommonPrefix
in class InsightInputFilter