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 | 0 | return name; |
44 | |
} |
45 | |
|
46 | |
public void setName( String name ) |
47 | |
{ |
48 | 0 | this.name = name; |
49 | 0 | } |
50 | |
|
51 | |
public String getType() |
52 | |
{ |
53 | 0 | return type; |
54 | |
} |
55 | |
|
56 | |
public void setType( String type ) |
57 | |
{ |
58 | 0 | this.type = type; |
59 | 0 | } |
60 | |
|
61 | |
public String getLocation() |
62 | |
{ |
63 | 0 | return location; |
64 | |
} |
65 | |
|
66 | |
public void setLocation( String location ) |
67 | |
{ |
68 | 0 | this.location = location; |
69 | 0 | } |
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
public LinkedResource() |
75 | |
{ |
76 | 0 | super(); |
77 | 0 | } |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
public LinkedResource( Xpp3Dom node ) |
87 | 6 | { |
88 | 6 | Xpp3Dom nameNode = node.getChild( "name" ); |
89 | |
|
90 | 6 | if ( nameNode == null ) |
91 | |
{ |
92 | 0 | throw new IllegalArgumentException( "No name node." ); |
93 | |
} |
94 | |
|
95 | 6 | name = nameNode.getValue(); |
96 | |
|
97 | 6 | Xpp3Dom typeNode = node.getChild( "type" ); |
98 | |
|
99 | 6 | if ( typeNode == null ) |
100 | |
{ |
101 | 0 | throw new IllegalArgumentException( "No type node." ); |
102 | |
} |
103 | |
|
104 | 6 | type = typeNode.getValue(); |
105 | |
|
106 | 6 | Xpp3Dom locationNode = node.getChild( "location" ); |
107 | |
|
108 | 6 | if ( locationNode == null ) |
109 | |
{ |
110 | 0 | throw new IllegalArgumentException( "No location node." ); |
111 | |
} |
112 | |
|
113 | 6 | location = locationNode.getValue(); |
114 | 6 | } |
115 | |
|
116 | |
public void print( XMLWriter writer ) |
117 | |
{ |
118 | 6 | writer.startElement( "link" ); |
119 | |
|
120 | 6 | writer.startElement( "name" ); |
121 | 6 | writer.writeText( name ); |
122 | 6 | writer.endElement(); |
123 | |
|
124 | 6 | writer.startElement( "type" ); |
125 | 6 | writer.writeText( type ); |
126 | 6 | writer.endElement(); |
127 | |
|
128 | 6 | writer.startElement( "location" ); |
129 | 6 | writer.writeText( location ); |
130 | 6 | writer.endElement(); |
131 | 6 | writer.endElement(); |
132 | 6 | } |
133 | |
|
134 | |
public boolean equals( Object obj ) |
135 | |
{ |
136 | 0 | if ( obj instanceof LinkedResource ) |
137 | |
{ |
138 | 0 | LinkedResource b = (LinkedResource) obj; |
139 | |
|
140 | 0 | 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 | 0 | return false; |
146 | |
} |
147 | |
} |
148 | |
|
149 | |
public int hashCode() |
150 | |
{ |
151 | 6 | return name.hashCode() + ( type == null ? 0 : 13 * type.hashCode() ) |
152 | |
+ ( location == null ? 0 : 17 * location.hashCode() ); |
153 | |
} |
154 | |
} |