1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.maven.plugin.eclipse;
21
22 import org.codehaus.plexus.util.xml.XMLWriter;
23 import org.codehaus.plexus.util.xml.Xpp3Dom;
24
25
26
27
28
29
30 public class LinkedResource
31 {
32
33 private String name;
34
35
36 private String type;
37
38
39 private String location;
40
41 public String getName()
42 {
43 return name;
44 }
45
46 public void setName( String name )
47 {
48 this.name = name;
49 }
50
51 public String getType()
52 {
53 return type;
54 }
55
56 public void setType( String type )
57 {
58 this.type = type;
59 }
60
61 public String getLocation()
62 {
63 return location;
64 }
65
66 public void setLocation( String location )
67 {
68 this.location = location;
69 }
70
71
72
73
74 public LinkedResource()
75 {
76 super();
77 }
78
79
80
81
82
83
84
85
86 public LinkedResource( Xpp3Dom node )
87 {
88 Xpp3Dom nameNode = node.getChild( "name" );
89
90 if ( nameNode == null )
91 {
92 throw new IllegalArgumentException( "No name node." );
93 }
94
95 name = nameNode.getValue();
96
97 Xpp3Dom typeNode = node.getChild( "type" );
98
99 if ( typeNode == null )
100 {
101 throw new IllegalArgumentException( "No type node." );
102 }
103
104 type = typeNode.getValue();
105
106 Xpp3Dom locationNode = node.getChild( "location" );
107
108 if ( locationNode == null )
109 {
110 throw new IllegalArgumentException( "No location node." );
111 }
112
113 location = locationNode.getValue();
114 }
115
116 public void print( XMLWriter writer )
117 {
118 writer.startElement( "link" );
119
120 writer.startElement( "name" );
121 writer.writeText( name );
122 writer.endElement();
123
124 writer.startElement( "type" );
125 writer.writeText( type );
126 writer.endElement();
127
128 writer.startElement( "location" );
129 writer.writeText( location );
130 writer.endElement();
131 writer.endElement();
132 }
133
134 public boolean equals( Object obj )
135 {
136 if ( obj instanceof LinkedResource )
137 {
138 LinkedResource b = (LinkedResource) obj;
139
140 return name.equals( b.name ) && ( type == null ? b.type == null : type.equals( b.type ) )
141 && ( location == null ? b.location == null : location.equals( b.location ) );
142 }
143 else
144 {
145 return false;
146 }
147 }
148
149 public int hashCode()
150 {
151 return name.hashCode() + ( type == null ? 0 : 13 * type.hashCode() )
152 + ( location == null ? 0 : 17 * location.hashCode() );
153 }
154 }