| 1 |
/* InfoItem.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 |
import net.sourceforge.jnlp.InformationDesc; |
| 40 |
import net.sourceforge.jnlp.runtime.Translator; |
| 41 |
|
| 42 |
/** |
| 43 |
* The optional kind="splash" attribute may be used in an icon element to |
| 44 |
* indicate that the image is to be used as a "splash" screen during the launch |
| 45 |
* of an application. If the JNLP file does not contain an icon element with |
| 46 |
* kind="splash" attribute, Java Web Start will construct a splash screen using |
| 47 |
* other items from the information Element. |
| 48 |
* If the JNLP file does not contain any icon images, the splash image will |
| 49 |
* consist of the application's title and vendor, as taken from the JNLP file. |
| 50 |
* |
| 51 |
* items not used inside |
| 52 |
*/ |
| 53 |
public class InfoItem { |
| 54 |
|
| 55 |
public static final String SPLASH = "SPLASH"; |
| 56 |
public static final String title = "title"; |
| 57 |
public static final String vendor = "vendor"; |
| 58 |
public static final String homepage = "homepage"; |
| 59 |
public static final String homepageHref = "href"; |
| 60 |
public static final String description = "description"; |
| 61 |
public static final String descriptionKind = "kind"; |
| 62 |
public static final String descriptionKindOneLine = (String) InformationDesc.ONE_LINE; |
| 63 |
//when no kind is specified, then it should behave as short |
| 64 |
public static final String descriptionKindShort = (String) InformationDesc.SHORT; |
| 65 |
public static final String descriptionKindToolTip = (String) InformationDesc.TOOLTIP; |
| 66 |
protected String type; |
| 67 |
protected String value; |
| 68 |
|
| 69 |
|
| 70 |
public InfoItem(String type, String value) { |
| 71 |
this.type = type; |
| 72 |
this.value = value; |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* @return the type |
| 77 |
*/ |
| 78 |
public String getType() { |
| 79 |
return type; |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* @param type the type to set |
| 84 |
*/ |
| 85 |
public void setType(String type) { |
| 86 |
this.type = type; |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* @return the value |
| 91 |
*/ |
| 92 |
public String getValue() { |
| 93 |
return value; |
| 94 |
} |
| 95 |
|
| 96 |
/** |
| 97 |
* @param value the value to set |
| 98 |
*/ |
| 99 |
public void setValue(String value) { |
| 100 |
this.value = value; |
| 101 |
} |
| 102 |
|
| 103 |
public boolean isofSameType(InfoItem o) { |
| 104 |
return ((getType().equals(o.getType()))); |
| 105 |
|
| 106 |
|
| 107 |
} |
| 108 |
|
| 109 |
@Override |
| 110 |
public boolean equals(Object obj) { |
| 111 |
if (!(obj instanceof InfoItem)) { |
| 112 |
return false; |
| 113 |
} |
| 114 |
InfoItem o = (InfoItem) obj; |
| 115 |
return isofSameType(o) && (getValue().equals(o.getValue())); |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
} |
| 120 |
|
| 121 |
@Override |
| 122 |
public String toString() { |
| 123 |
return type + ": " + value; |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
public String toNiceString() { |
| 130 |
String key = SPLASH + type; |
| 131 |
return localise(key, value); |
| 132 |
} |
| 133 |
|
| 134 |
public static String localise(String key, String s) { |
| 135 |
return Translator.R(key) + ": " + s; |
| 136 |
} |
| 137 |
|
| 138 |
@Override |
| 139 |
public int hashCode() { |
| 140 |
int hash = 7; |
| 141 |
hash = 59 * hash + (this.getType() != null ? this.getType().hashCode() : 0); |
| 142 |
hash = 59 * hash + (this.getValue() != null ? this.getValue().hashCode() : 0); |
| 143 |
return hash; |
| 144 |
} |
| 145 |
} |