|
Lines 10-15
Link Here
|
| 10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.core.runtime.preferences; |
11 |
package org.eclipse.core.runtime.preferences; |
| 12 |
|
12 |
|
|
|
13 |
import java.util.HashSet; |
| 14 |
|
| 13 |
/** |
15 |
/** |
| 14 |
* Class which represents and preference filter entry to be used during preference |
16 |
* Class which represents and preference filter entry to be used during preference |
| 15 |
* import/export (for example). |
17 |
* import/export (for example). |
|
Lines 21-26
Link Here
|
| 21 |
public final class PreferenceFilterEntry { |
23 |
public final class PreferenceFilterEntry { |
| 22 |
|
24 |
|
| 23 |
private String key; |
25 |
private String key; |
|
|
26 |
private HashSet matches; |
| 27 |
boolean isPrefix; |
| 24 |
|
28 |
|
| 25 |
/** |
29 |
/** |
| 26 |
* Constructor for the class. Create a new preference filter entry with the given |
30 |
* Constructor for the class. Create a new preference filter entry with the given |
|
Lines 33-38
Link Here
|
| 33 |
if (key == null || key.length() == 0) |
37 |
if (key == null || key.length() == 0) |
| 34 |
throw new IllegalArgumentException(); |
38 |
throw new IllegalArgumentException(); |
| 35 |
this.key = key; |
39 |
this.key = key; |
|
|
40 |
this.isPrefix = false; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Constructor for the class. Create a new preference filter entry with the given |
| 45 |
* key and value of regexp flag. The key must <em>not</em> be <code>null</code> or empty. |
| 46 |
* |
| 47 |
* @param key the name of the preference key |
| 48 |
* @param regexp flag shows how name is used: |
| 49 |
* "true" - as regular expression, "false" - exactly |
| 50 |
*/ |
| 51 |
public PreferenceFilterEntry(String key, boolean isPrefix) { |
| 52 |
super(); |
| 53 |
if (key == null || key.length() == 0) |
| 54 |
throw new IllegalArgumentException(); |
| 55 |
this.key = key; |
| 56 |
this.isPrefix = isPrefix; |
| 36 |
} |
57 |
} |
| 37 |
|
58 |
|
| 38 |
/** |
59 |
/** |
|
Lines 45-48
Link Here
|
| 45 |
public String getKey() { |
66 |
public String getKey() { |
| 46 |
return key; |
67 |
return key; |
| 47 |
} |
68 |
} |
|
|
69 |
|
| 70 |
/** |
| 71 |
* Return regular expression flag. |
| 72 |
* |
| 73 |
* @return the regular expression flag |
| 74 |
*/ |
| 75 |
public boolean isPrefix() { |
| 76 |
return isPrefix; |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Adding into collection of preferences names, matches the regular expression, |
| 81 |
* which is contained in the <code>key</code>. |
| 82 |
* |
| 83 |
* @param name the name of the preference, matches the regular expression, contained in the key |
| 84 |
*/ |
| 85 |
public void addMatch(String name) { |
| 86 |
if (!isPrefix) |
| 87 |
return; |
| 88 |
if (matches == null) |
| 89 |
matches = new HashSet(); |
| 90 |
matches.add(name); |
| 91 |
} |
| 92 |
|
| 93 |
/** |
| 94 |
* Return the array of preferences' names, matches the regular expression, contained in the key |
| 95 |
* |
| 96 |
* @return the array of the preferencs' names, matches the regular expression, contained in the key |
| 97 |
*/ |
| 98 |
public Object[] getMatches() { |
| 99 |
if (!isPrefix || matches == null) |
| 100 |
return null; |
| 101 |
return matches.toArray(); |
| 102 |
} |
| 48 |
} |
103 |
} |