Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Language |
|
| 1.1666666666666667;1.167 |
1 | /* $Id: Language.java 17868 2010-01-12 20:47:51Z linus $ | |
2 | ***************************************************************************** | |
3 | * Copyright (c) 2009 Contributors - see below | |
4 | * All rights reserved. This program and the accompanying materials | |
5 | * are made available under the terms of the Eclipse Public License v1.0 | |
6 | * which accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * penyaskito | |
11 | ***************************************************************************** | |
12 | * | |
13 | * Some portions of this file was previously release using the BSD License: | |
14 | */ | |
15 | ||
16 | // Copyright (c) 2005-2006 The Regents of the University of California. All | |
17 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
18 | // software and its documentation without fee, and without a written | |
19 | // agreement is hereby granted, provided that the above copyright notice | |
20 | // and this paragraph appear in all copies. This software program and | |
21 | // documentation are copyrighted by The Regents of the University of | |
22 | // California. The software program and documentation are supplied "AS | |
23 | // IS", without any accompanying services from The Regents. The Regents | |
24 | // does not warrant that the operation of the program will be | |
25 | // uninterrupted or error-free. The end-user understands that the program | |
26 | // was developed for research purposes and is advised not to rely | |
27 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
28 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
29 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
30 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
31 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
32 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
33 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
34 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
35 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
36 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
37 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
38 | ||
39 | package org.argouml.uml.generator; | |
40 | ||
41 | import javax.swing.Icon; | |
42 | ||
43 | /** | |
44 | * Encapsulates a programming language name and other properties. | |
45 | * | |
46 | * @author Daniele Tamino | |
47 | */ | |
48 | 0 | public class Language implements Comparable<Language> { |
49 | ||
50 | private String name; | |
51 | private String title; | |
52 | private Icon icon; | |
53 | ||
54 | /** | |
55 | * Construct a language instance with all its properties. | |
56 | * | |
57 | * @param theName The name of the language. | |
58 | * @param theTitle A string representing the language for display. | |
59 | * @param theIcon An icon for the language. | |
60 | */ | |
61 | 0 | public Language(String theName, String theTitle, Icon theIcon) { |
62 | 0 | this.name = theName; |
63 | 0 | if (theTitle == null) { |
64 | 0 | this.title = theName; |
65 | } else { | |
66 | 0 | this.title = theTitle; |
67 | } | |
68 | 0 | this.icon = theIcon; |
69 | 0 | } |
70 | ||
71 | /** | |
72 | * Creates a language with no icon. | |
73 | * | |
74 | * @param theName The name of the language. | |
75 | * @param theTitle A string representing the language for display. | |
76 | */ | |
77 | public Language(String theName, String theTitle) { | |
78 | 0 | this(theName, theTitle, null); |
79 | 0 | } |
80 | ||
81 | /** | |
82 | * Creates a language with title equal to the name. | |
83 | * | |
84 | * @param theName The name of the language. | |
85 | * @param theIcon An icon for the language. | |
86 | */ | |
87 | public Language(String theName, Icon theIcon) { | |
88 | 0 | this(theName, theName, theIcon); |
89 | 0 | } |
90 | ||
91 | /** | |
92 | * Creates a language with title equal to the name and no icon. | |
93 | * | |
94 | * @param theName The name of the language. | |
95 | */ | |
96 | public Language(String theName) { | |
97 | 0 | this(theName, theName, null); |
98 | 0 | } |
99 | ||
100 | /** | |
101 | * Compares the current object with another object. | |
102 | * | |
103 | * @param o The object one compares to | |
104 | * @return int | |
105 | */ | |
106 | public int compareTo(Language o) { | |
107 | 0 | return (this.getName().compareToIgnoreCase(o.getName())); |
108 | } | |
109 | ||
110 | /** | |
111 | * @return Returns the icon. | |
112 | */ | |
113 | public Icon getIcon() { | |
114 | 0 | return icon; |
115 | } | |
116 | ||
117 | /** | |
118 | * @param theIcon The icon to set. | |
119 | */ | |
120 | public void setIcon(Icon theIcon) { | |
121 | 0 | this.icon = theIcon; |
122 | 0 | } |
123 | ||
124 | /** | |
125 | * @return Returns the name. | |
126 | */ | |
127 | public String getName() { | |
128 | 0 | return name; |
129 | } | |
130 | ||
131 | /** | |
132 | * @param theName The name to set. | |
133 | */ | |
134 | public void setName(String theName) { | |
135 | 0 | this.name = theName; |
136 | 0 | } |
137 | ||
138 | /** | |
139 | * @return Returns the title, which should be a string representing the | |
140 | * language, in a form suitable for display. | |
141 | */ | |
142 | public String getTitle() { | |
143 | 0 | return title; |
144 | } | |
145 | ||
146 | /** | |
147 | * @param theTitle A string representing the language, in a form suitable | |
148 | * for display. | |
149 | */ | |
150 | public void setTitle(String theTitle) { | |
151 | 0 | this.title = theTitle; |
152 | 0 | } |
153 | ||
154 | public String toString() { | |
155 | 0 | String tit = getTitle(); |
156 | 0 | return tit == null ? "(no name)" : tit; |
157 | } | |
158 | ||
159 | } |