File Source: ThemeIdentity.java
/*
P/P * Method: com.dmdirc.ui.themes.ThemeIdentity__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.themes;
24
25 import com.dmdirc.config.Identity;
26 import com.dmdirc.config.InvalidIdentityFileException;
27
28 import java.io.IOException;
29 import java.io.InputStream;
30
31 /**
32 * An identity that only claims to know about settings under the UI domain,
33 * for use with themes.
34 *
35 * @author Chris
36 */
37 public class ThemeIdentity extends Identity {
38
39 /**
40 * A version number for this class. It should be changed whenever the class
41 * structure is changed (or anything else that would prevent serialized
42 * objects being unserialized with the new class).
43 */
44 private static final long serialVersionUID = 1;
45
46 /** The theme that owns this identity. */
47 private final Theme theme;
48
49 /**
50 * Creates a new instance of ThemeIdentity.
51 *
52 * @param stream The input stream to read the identity from.
53 * @param theme The theme that owns this identity
54 * @throws InvalidIdentityFileException Missing required properties
55 * @throws IOException Input/output exception
56 */
57 public ThemeIdentity(final InputStream stream, final Theme theme) throws IOException,
58 InvalidIdentityFileException {
/*
P/P * Method: void com.dmdirc.ui.themes.ThemeIdentity(InputStream, Theme)
*
* Presumptions:
* this.myTarget@59 != null
*
* Postconditions:
* this.myTarget != null
* this.theme == theme
* init'ed(this.theme)
*/
59 super(stream, true);
60
61 myTarget.setTheme();
62 this.theme = theme;
63 }
64
65 /** {@inheritDoc} */
66 @Override @Deprecated
67 public boolean hasOption(final String domain, final String option) {
/*
P/P * Method: bool hasOption(String, String)
*
* Preconditions:
* domain != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* java.lang.String:equalsIgnoreCase(...)@68: {1}, {0}
* java.lang.String:equalsIgnoreCase(...)@68: {0}, {1}
*/
68 if (domain.equalsIgnoreCase("ui") || domain.equalsIgnoreCase("identity")
69 || domain.equalsIgnoreCase("icon") || domain.equalsIgnoreCase("theme")
70 || domain.equalsIgnoreCase("formatter") || domain.equalsIgnoreCase("colour")) {
71 return super.hasOption(domain, option);
72 } else {
73 return false;
74 }
75 }
76
77 /** {@inheritDoc} */
78 @Override
79 public String getOption(final String domain, final String option) {
/*
P/P * Method: String getOption(String, String)
*
* Preconditions:
* (soft) this.theme != null
* (soft) this.theme.file != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* com.dmdirc.config.Identity:getOption(...)@80: Inverse{null}, Addr_Set{null}
*/
80 final String result = super.getOption(domain, option);
81
82 if (result == null) {
83 return result;
84 } else {
85 return result.replaceAll("\\$theme", theme.getFileName(false));
86 }
87 }
88
89 /** {@inheritDoc} */
90 @Override
91 public String getName() {
/*
P/P * Method: String getName()
*
* Postconditions:
* java.lang.StringBuilder:toString(...)._tainted == 0
* return_value == &java.lang.StringBuilder:toString(...)
*/
92 return "Theme UI config: " + super.getName();
93 }
94
95 }
SofCheck Inspector Build Version : 2.17854
| ThemeIdentity.java |
2009-Jun-25 01:54:24 |
| ThemeIdentity.class |
2009-Sep-02 17:04:15 |