Debian Codegraph @

netx/net/sourceforge/jnlp/splashscreen/parts/DescriptionInfoItem.java

raw
1 /* DescriptionInfoItem.java
2 Copyright (C) 2012 Red Hat, Inc.
3
4 This file is part of IcedTea.
5
6 IcedTea is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 IcedTea is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with IcedTea; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
25
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
37 package net.sourceforge.jnlp.splashscreen.parts;
38
39 /**
40 *description element: A short statement about the application. Description
41 * elements are optional. The kind attribute defines how the description should
42 * be used. It can have one of the following values:
43 *
44 * * one-line: If a reference to the application is going to appear on one row
45 * in a list or a table, this description will be used.
46 * * short: If a reference to the application is going to be displayed in a
47 * situation where there is room for a paragraph, this description is used.
48 * * tooltip: If a reference to the application is going to appear in a
49 * tooltip, this description is used.
50 *
51 * Only one description element of each kind can be specified. A description
52 * element without a kind is used as a default value. Thus, if Java Web Start
53 * needs a description of kind short, and it is not specified in the JNLP file,
54 * then the text from the description without an attribute is used.
55 *
56 * All descriptions contain plain text. No formatting, such as with HTML tags,
57 * is supported.
58 */
59 public class DescriptionInfoItem extends InfoItem {
60
61 protected String kind;
62
63 public DescriptionInfoItem(String value, String kind) {
64 super(InfoItem.description, value);
65 this.kind = kind;
66 }
67
68 public String getKind() {
69 return kind;
70 }
71
72 public void setKind(String kind) {
73 this.kind = kind;
74 }
75
76 public boolean isOfSameKind(DescriptionInfoItem o) {
77 if (o.getKind() == null && getKind() == null) {
78 return true;
79 }
80 if (o.getKind() == null && getKind() != null) {
81 return false;
82 }
83 if (o.getKind() != null && getKind() == null) {
84 return false;
85 }
86 return (o.getKind().equals(getKind()));
87 }
88
89 public boolean isSame(DescriptionInfoItem o) {
90 return isOfSameKind(o) && isofSameType(o);
91
92 }
93
94 @Override
95 public boolean equals(Object obj) {
96 if (!(obj instanceof DescriptionInfoItem)) {
97 return false;
98 }
99 DescriptionInfoItem o = (DescriptionInfoItem) obj;
100 return super.equals(o) && isOfSameKind(o);
101
102
103 }
104
105 @Override
106 public int hashCode() {
107 int hash = 7;
108 hash = 59 * hash + (this.kind != null ? this.kind.hashCode() : 0);
109 hash = 59 * hash + (this.getType() != null ? this.getType().hashCode() : 0);
110 hash = 59 * hash + (this.getValue() != null ? this.getValue().hashCode() : 0);
111 return hash;
112 }
113
114 @Override
115 public String toString() {
116 return super.toString() + " (" + getKind() + ")";
117 }
118
119
120
121 @Override
122 public String toNiceString() {
123 return super.toNiceString();
124 }
125
126 }