|
1 /* |
|
2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 package com.sun.swingset3.demos.table; |
|
25 |
|
26 import java.net.URI; |
|
27 |
|
28 /** |
|
29 * Class representing the state of a hyperlink |
|
30 * This class may be used in conjunction with HyperlinkCellRenderer, |
|
31 * but it is not required. |
|
32 * |
|
33 * @author aim |
|
34 */ |
|
35 public class Link { |
|
36 protected String displayText; |
|
37 private URI uri; |
|
38 private String description; |
|
39 private boolean visited; |
|
40 |
|
41 /** |
|
42 * Creates a new instance of Link |
|
43 */ |
|
44 public Link(String text) { |
|
45 setDisplayText(text); |
|
46 } |
|
47 |
|
48 public Link(String text, URI uri) { |
|
49 this(text); |
|
50 setUri(uri); |
|
51 } |
|
52 |
|
53 public String getDisplayText() { |
|
54 return displayText; |
|
55 } |
|
56 |
|
57 public void setDisplayText(String text) { |
|
58 this.displayText = text; |
|
59 } |
|
60 |
|
61 public URI getUri() { |
|
62 return uri; |
|
63 } |
|
64 |
|
65 public void setUri(URI uri) { |
|
66 this.uri = uri; |
|
67 } |
|
68 |
|
69 public String getDescription() { |
|
70 return description != null ? description : |
|
71 uri != null ? uri.getPath() : null; |
|
72 } |
|
73 |
|
74 public void setDescription(String description) { |
|
75 this.description = description; |
|
76 } |
|
77 |
|
78 public boolean isVisited() { |
|
79 return visited; |
|
80 } |
|
81 |
|
82 public void setVisited(boolean visited) { |
|
83 this.visited = visited; |
|
84 } |
|
85 |
|
86 } |