You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SearchResultHit.java 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. package org.apache.archiva.indexer.search;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import java.util.ArrayList;
  21. import java.util.List;
  22. /**
  23. * SearchResultHit
  24. *
  25. */
  26. public class SearchResultHit
  27. {
  28. // The (optional) context for this result.
  29. private String context;
  30. // Basic hit, direct to non-artifact resource.
  31. private String url;
  32. // Advanced hit, reference to groupId.
  33. private String groupId;
  34. // Advanced hit, reference to artifactId.
  35. private String artifactId;
  36. private String repositoryId = "";
  37. private List<String> versions = new ArrayList<>();
  38. private String packaging;
  39. /**
  40. * Plugin goal prefix (only if packaging is "maven-plugin")
  41. */
  42. private String prefix;
  43. /**
  44. * Plugin goals (only if packaging is "maven-plugin")
  45. */
  46. private List<String> goals;
  47. /**
  48. * contains osgi metadata Bundle-Version if available
  49. *
  50. * @since 1.4-M1
  51. */
  52. private String bundleVersion;
  53. /**
  54. * contains osgi metadata Bundle-SymbolicName if available
  55. *
  56. * @since 1.4-M1
  57. */
  58. private String bundleSymbolicName;
  59. /**
  60. * contains osgi metadata Export-Package if available
  61. *
  62. * @since 1.4-M1
  63. */
  64. private String bundleExportPackage;
  65. /**
  66. * contains osgi metadata Export-Service if available
  67. *
  68. * @since 1.4-M1
  69. */
  70. private String bundleExportService;
  71. /**
  72. * contains osgi metadata Bundle-Description if available
  73. *
  74. * @since 1.4-M1
  75. */
  76. private String bundleDescription;
  77. /**
  78. * contains osgi metadata Bundle-Name if available
  79. *
  80. * @since 1.4-M1
  81. */
  82. private String bundleName;
  83. /**
  84. * contains osgi metadata Bundle-License if available
  85. *
  86. * @since 1.4-M1
  87. */
  88. private String bundleLicense;
  89. /**
  90. * contains osgi metadata Bundle-DocURL if available
  91. *
  92. * @since 1.4-M1
  93. */
  94. private String bundleDocUrl;
  95. /**
  96. * contains osgi metadata Import-Package if available
  97. *
  98. * @since 1.4-M1
  99. */
  100. private String bundleImportPackage;
  101. /**
  102. * contains osgi metadata Require-Bundle if available
  103. *
  104. * @since 1.4-M1
  105. */
  106. private String bundleRequireBundle;
  107. private String classifier;
  108. /**
  109. * file extension of the search result
  110. * @since 1.4-M2
  111. */
  112. private String fileExtension;
  113. public String getContext()
  114. {
  115. return context;
  116. }
  117. public void setContext( String context )
  118. {
  119. this.context = context;
  120. }
  121. public String getUrl()
  122. {
  123. return url;
  124. }
  125. public void setUrl( String url )
  126. {
  127. this.url = url;
  128. }
  129. public String getUrlFilename()
  130. {
  131. return this.url.substring( this.url.lastIndexOf( '/' ) );
  132. }
  133. public String getArtifactId()
  134. {
  135. return artifactId;
  136. }
  137. public void setArtifactId( String artifactId )
  138. {
  139. this.artifactId = artifactId;
  140. }
  141. public String getGroupId()
  142. {
  143. return groupId;
  144. }
  145. public void setGroupId( String groupId )
  146. {
  147. this.groupId = groupId;
  148. }
  149. public List<String> getVersions()
  150. {
  151. return versions;
  152. }
  153. public void setVersions( List<String> versions )
  154. {
  155. this.versions = versions;
  156. }
  157. public String getRepositoryId()
  158. {
  159. return repositoryId;
  160. }
  161. public void setRepositoryId( String repositoryId )
  162. {
  163. this.repositoryId = repositoryId;
  164. }
  165. public void addVersion( String version )
  166. {
  167. versions.add( version );
  168. }
  169. public String getBundleVersion()
  170. {
  171. return bundleVersion;
  172. }
  173. public void setBundleVersion( String bundleVersion )
  174. {
  175. this.bundleVersion = bundleVersion;
  176. }
  177. public String getBundleSymbolicName()
  178. {
  179. return bundleSymbolicName;
  180. }
  181. public void setBundleSymbolicName( String bundleSymbolicName )
  182. {
  183. this.bundleSymbolicName = bundleSymbolicName;
  184. }
  185. public String getBundleExportPackage()
  186. {
  187. return bundleExportPackage;
  188. }
  189. public void setBundleExportPackage( String bundleExportPackage )
  190. {
  191. this.bundleExportPackage = bundleExportPackage;
  192. }
  193. public String getBundleExportService()
  194. {
  195. return bundleExportService;
  196. }
  197. public void setBundleExportService( String bundleExportService )
  198. {
  199. this.bundleExportService = bundleExportService;
  200. }
  201. public String getPrefix()
  202. {
  203. return prefix;
  204. }
  205. public void setPrefix( String prefix )
  206. {
  207. this.prefix = prefix;
  208. }
  209. public List<String> getGoals()
  210. {
  211. return goals;
  212. }
  213. public void setGoals( List<String> goals )
  214. {
  215. this.goals = goals;
  216. }
  217. public String getBundleDescription()
  218. {
  219. return bundleDescription;
  220. }
  221. public void setBundleDescription( String bundleDescription )
  222. {
  223. this.bundleDescription = bundleDescription;
  224. }
  225. public String getBundleName()
  226. {
  227. return bundleName;
  228. }
  229. public void setBundleName( String bundleName )
  230. {
  231. this.bundleName = bundleName;
  232. }
  233. public String getBundleLicense()
  234. {
  235. return bundleLicense;
  236. }
  237. public void setBundleLicense( String bundleLicense )
  238. {
  239. this.bundleLicense = bundleLicense;
  240. }
  241. public String getBundleDocUrl()
  242. {
  243. return bundleDocUrl;
  244. }
  245. public void setBundleDocUrl( String bundleDocUrl )
  246. {
  247. this.bundleDocUrl = bundleDocUrl;
  248. }
  249. public String getBundleImportPackage()
  250. {
  251. return bundleImportPackage;
  252. }
  253. public void setBundleImportPackage( String bundleImportPackage )
  254. {
  255. this.bundleImportPackage = bundleImportPackage;
  256. }
  257. public String getBundleRequireBundle()
  258. {
  259. return bundleRequireBundle;
  260. }
  261. public void setBundleRequireBundle( String bundleRequireBundle )
  262. {
  263. this.bundleRequireBundle = bundleRequireBundle;
  264. }
  265. public String getPackaging()
  266. {
  267. return packaging;
  268. }
  269. public void setPackaging( String packaging )
  270. {
  271. this.packaging = packaging;
  272. }
  273. public String getType()
  274. {
  275. return getPackaging();
  276. }
  277. public String getClassifier()
  278. {
  279. return classifier;
  280. }
  281. public void setClassifier( String classifier )
  282. {
  283. this.classifier = classifier;
  284. }
  285. public String getFileExtension()
  286. {
  287. return fileExtension;
  288. }
  289. public void setFileExtension( String fileExtension )
  290. {
  291. this.fileExtension = fileExtension;
  292. }
  293. @Override
  294. public String toString()
  295. {
  296. final StringBuilder sb = new StringBuilder();
  297. sb.append( "SearchResultHit" );
  298. sb.append( "{context='" ).append( context ).append( '\'' );
  299. sb.append( ", url='" ).append( url ).append( '\'' );
  300. sb.append( ", groupId='" ).append( groupId ).append( '\'' );
  301. sb.append( ", artifactId='" ).append( artifactId ).append( '\'' );
  302. sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' );
  303. sb.append( ", versions=" ).append( versions );
  304. sb.append( ", packaging='" ).append( packaging ).append( '\'' );
  305. sb.append( ", prefix='" ).append( prefix ).append( '\'' );
  306. sb.append( ", goals=" ).append( goals );
  307. sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' );
  308. sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' );
  309. sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' );
  310. sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' );
  311. sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' );
  312. sb.append( ", bundleName='" ).append( bundleName ).append( '\'' );
  313. sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' );
  314. sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' );
  315. sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' );
  316. sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' );
  317. sb.append( ", classifier='" ).append( classifier ).append( '\'' );
  318. sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' );
  319. sb.append( '}' );
  320. return sb.toString();
  321. }
  322. @Override
  323. public boolean equals( Object o )
  324. {
  325. if ( this == o )
  326. {
  327. return true;
  328. }
  329. if ( o == null || getClass() != o.getClass() )
  330. {
  331. return false;
  332. }
  333. SearchResultHit that = (SearchResultHit) o;
  334. if ( artifactId != null ? !artifactId.equals( that.artifactId ) : that.artifactId != null )
  335. {
  336. return false;
  337. }
  338. if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null )
  339. {
  340. return false;
  341. }
  342. if ( groupId != null ? !groupId.equals( that.groupId ) : that.groupId != null )
  343. {
  344. return false;
  345. }
  346. if ( packaging != null ? !packaging.equals( that.packaging ) : that.packaging != null )
  347. {
  348. return false;
  349. }
  350. return true;
  351. }
  352. @Override
  353. public int hashCode()
  354. {
  355. int result = groupId != null ? groupId.hashCode() : 0;
  356. result = 31 * result + ( artifactId != null ? artifactId.hashCode() : 0 );
  357. result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 );
  358. result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 );
  359. return result;
  360. }
  361. }