01: /*
02: * SalomeTMF is a Test Management Framework
03: * Copyright (C) 2005 France Telecom R&D
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: *
19: * @author Mikael MARCHE
20: *
21: * Contact: mikael.marche@rd.francetelecom.com
22: */
23:
24: package org.objectweb.salome_tmf.data;
25:
26: import java.net.MalformedURLException;
27: import java.net.URL;
28:
29: import org.objectweb.salome_tmf.api.data.UrlAttachementWrapper;
30:
31: public class UrlAttachment extends Attachment {
32: URL url;
33:
34: public UrlAttachment(String name, String description) {
35: super (name, description);
36: }
37:
38: public UrlAttachment(UrlAttachementWrapper pAttach) {
39: super (pAttach);
40: try {
41: url = new URL(pAttach.getName());
42: // url = new URL(pAttach.getUrlProtocol(), pAttach.getUrlHost(), pAttach.getUrlPort(), pAttach.getUrlFile());
43: } catch (MalformedURLException e) {
44: e.printStackTrace();
45: }
46: idBdd = pAttach.getIdBDD();
47: }
48:
49: public void clearCache() {
50: /* NOTHING */
51: }
52:
53: /**
54: * @return the Url of the attachment
55: */
56: public URL getUrl() {
57: return url;
58: }
59:
60: /**
61: * Set the Url of the attachment
62: * @param url
63: */
64: public void setUrl(URL url) {
65: this .url = url;
66: }
67:
68: public String toString() {
69: return "[URL] : " + name;
70: }
71:
72: public boolean equals(Object o) {
73: if (o instanceof UrlAttachment) {
74: UrlAttachment toTest = (UrlAttachment) o;
75: if (isInBase() && toTest.isInBase()) {
76: if (getIdBdd() == toTest.getIdBdd()) {
77: return true;
78: }
79: } else {
80: return getUrl().equals(toTest.getUrl());
81: }
82: }
83: return false;
84: }
85:
86: /*public int hashCode(){
87: if (isInBase()) {
88: return getIdBdd();
89: } else {
90: return super.hashCode();
91: }
92: }*/
93: }
|