source: src/main/java/genius/core/repository/DomainRepItem.java

Last change on this file was 1, checked in by Wouter Pasman, 7 years ago

Initial import : Genius 9.0.0

File size: 1.9 KB
Line 
1package genius.core.repository;
2
3import java.net.URL;
4import java.util.ArrayList;
5
6import javax.xml.bind.annotation.XmlAttribute;
7import javax.xml.bind.annotation.XmlElement;
8import javax.xml.bind.annotation.XmlRootElement;
9
10import genius.core.exceptions.Warning;
11
12/**
13 * A DomainRepItem is a domain reference that can be put in the domain
14 * repository. It contains only a unique reference to an xml file with the
15 * domain description.
16 *
17 * @author wouter
18 */
19@XmlRootElement
20public class DomainRepItem implements RepItem {
21 private static final long serialVersionUID = 6672725212678925392L;
22 @XmlAttribute
23 private URL url;
24 @XmlElement(name = "profile")
25 private ArrayList<ProfileRepItem> profiles = new ArrayList<ProfileRepItem>(); // default
26
27 /** for serialization support */
28 @SuppressWarnings("unused")
29 private DomainRepItem() {
30 try {
31 url = new URL("file:unknownfilename");
32 } catch (Exception e) {
33 new Warning("default url failed!?", e);
34 }
35 }
36
37 public DomainRepItem(URL newurl) {
38 url = newurl;
39 }
40
41 public URL getURL() {
42 return url;
43 }
44
45 public ArrayList<ProfileRepItem> getProfiles() {
46 return profiles;
47 }
48
49 @Override
50 public String toString() {
51 return getName();
52 }
53
54 public String getFullName() {
55 return "DomainRepItem[" + url + "," + profiles + "]";
56 }
57
58 @Override
59 public boolean equals(Object o) {
60 if (!(o instanceof DomainRepItem)) {
61 return false;
62 }
63 return url.equals(((DomainRepItem) o).getURL());
64 }
65
66 @Override
67 public int hashCode() {
68 int hash = 7;
69 hash = 89 * hash + (this.url != null ? this.url.hashCode() : 0);
70 return hash;
71 }
72
73 public String getName() {
74 String name = url.getFile();
75 int dotindex = name.lastIndexOf('.'), slashindex = name
76 .lastIndexOf('/');
77
78 if (slashindex < 0)
79 slashindex = 0;
80 if (dotindex < 0)
81 dotindex = name.length() - 1;
82 name = name.substring(slashindex + 1, dotindex);
83
84 return name;
85 }
86
87}
Note: See TracBrowser for help on using the repository browser.