( String part )
| 107 | } |
| 108 | |
| 109 | public String [] completeName( String part ) |
| 110 | { |
| 111 | List found = new ArrayList(); |
| 112 | getMatchingNames( part, found ); |
| 113 | |
| 114 | if ( found.size() == 0 ) |
| 115 | return new String [0]; |
| 116 | |
| 117 | // Find the max common prefix |
| 118 | String maxCommon = (String)found.get(0); |
| 119 | for(int i=1; i<found.size() && maxCommon.length() > 0; i++) { |
| 120 | maxCommon = StringUtil.maxCommonPrefix( |
| 121 | maxCommon, (String)found.get(i) ); |
| 122 | |
| 123 | // if maxCommon gets as small as part, stop trying |
| 124 | if ( maxCommon.equals( part ) ) |
| 125 | break; |
| 126 | } |
| 127 | |
| 128 | // Return max common or all ambiguous |
| 129 | if ( maxCommon.length() > part.length() ) |
| 130 | return new String [] { maxCommon }; |
| 131 | else |
| 132 | return (String[])(found.toArray(new String[0])); |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | class SourceCache implements NameSource.Listener |
nothing calls this directly
no test coverage detected