File Source: AdditionalTabTargets.java
/*
P/P * Method: com.dmdirc.ui.input.AdditionalTabTargets__static_init
*/
1 /*
2 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.dmdirc.ui.input;
24
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.List;
28
29 /**
30 * The AdditionalTabTargets class is a basic wrapper around an arraylist that
31 * adds an additional property to determine what types of results to include.
32 *
33 * @author chris
34 */
35 public final class AdditionalTabTargets extends ArrayList<String> {
36
37 /**
38 * A version number for this class. It should be changed whenever the class
39 * structure is changed (or anything else that would prevent serialized
40 * objects being unserialized with the new class).
41 */
42 private static final long serialVersionUID = 1;
43
44 /** Whether to include normal targets. */
45 private List<TabCompletionType> includes
46 = new ArrayList<TabCompletionType>(Arrays.asList(TabCompletionType.values()));
47
48 /** Initialises the AdditionalTabTargets. */
49 public AdditionalTabTargets() {
/*
P/P * Method: void com.dmdirc.ui.input.AdditionalTabTargets()
*
* Postconditions:
* this.includes == &new ArrayList(AdditionalTabTargets#1)
* new ArrayList(AdditionalTabTargets#1) num objects == 1
*/
50 super();
51 //Do nothing
52 }
53
54 /**
55 * Determines if the specified type of completion should be used.
56 *
57 * @param type The type to check for
58 * @return True if the specified targets are included, false otherwise
59 */
60 public boolean shouldInclude(final TabCompletionType type) {
/*
P/P * Method: bool shouldInclude(TabCompletionType)
*
* Preconditions:
* this.includes != null
*
* Postconditions:
* init'ed(return_value)
*/
61 return includes.contains(type);
62 }
63
64 /**
65 * Includes the specified target type.
66 *
67 * @param type The type to be included
68 */
69 public void include(final TabCompletionType type) {
/*
P/P * Method: void include(TabCompletionType)
*
* Preconditions:
* this.includes != null
*
* Test Vectors:
* java.util.List:contains(...)@70: {1}, {0}
*/
70 if (!includes.contains(type)) {
71 includes.add(type);
72 }
73 }
74
75 /**
76 * Excludes the specified target type.
77 *
78 * @param type The type to be excluded
79 */
80 public void exclude(final TabCompletionType type) {
/*
P/P * Method: void exclude(TabCompletionType)
*
* Preconditions:
* this.includes != null
*/
81 includes.remove(type);
82 }
83
84 /**
85 * Excludes all types of targets except ADDITIONAL.
86 *
87 * @return A reference to this object.
88 */
89 public AdditionalTabTargets excludeAll() {
/*
P/P * Method: AdditionalTabTargets excludeAll()
*
* Preconditions:
* this.includes != null
*
* Presumptions:
* init'ed(com.dmdirc.ui.input.TabCompletionType.ADDITIONAL)
*
* Postconditions:
* return_value == this
* return_value != null
*/
90 includes.clear();
91 includes.add(TabCompletionType.ADDITIONAL);
92
93 return this;
94 }
95
96 }
SofCheck Inspector Build Version : 2.17854
| AdditionalTabTargets.java |
2009-Jun-25 01:54:24 |
| AdditionalTabTargets.class |
2009-Sep-02 17:04:12 |