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.

SearchResults.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.HashMap;
  22. import java.util.List;
  23. import java.util.Map;
  24. /**
  25. * SearchResults
  26. *
  27. */
  28. public class SearchResults
  29. {
  30. private Map<String, SearchResultHit> hits = new HashMap<String, SearchResultHit>();
  31. private int totalHits;
  32. private int totalHitsMapSize;
  33. private int returnedHitsCount;
  34. private SearchResultLimits limits;
  35. public SearchResults()
  36. {
  37. /* do nothing */
  38. }
  39. // for new RepositorySearch
  40. public void addHit( String id, SearchResultHit hit )
  41. {
  42. hits.put( id, hit );
  43. }
  44. /**
  45. * Get the list of {@link SearchResultHit} objects.
  46. *
  47. * @return the list of {@link SearchResultHit} objects.
  48. */
  49. public List<SearchResultHit> getHits()
  50. {
  51. return new ArrayList<>( hits.values() );
  52. }
  53. /**
  54. * see SearchUtil on how to generate the key
  55. *
  56. * @param key
  57. * @return
  58. */
  59. public SearchResultHit getSearchResultHit( String key )
  60. {
  61. return hits.get( key );
  62. }
  63. public Map<String, SearchResultHit> getHitsMap()
  64. {
  65. return hits;
  66. }
  67. public boolean isEmpty()
  68. {
  69. return hits.isEmpty();
  70. }
  71. public SearchResultLimits getLimits()
  72. {
  73. return limits;
  74. }
  75. public void setLimits( SearchResultLimits limits )
  76. {
  77. this.limits = limits;
  78. }
  79. public int getTotalHits()
  80. {
  81. return totalHits;
  82. }
  83. public void setTotalHits( int totalHits )
  84. {
  85. this.totalHits = totalHits;
  86. }
  87. /**
  88. * @return
  89. * @since 1.4-M1
  90. */
  91. public int getReturnedHitsCount()
  92. {
  93. return returnedHitsCount;
  94. }
  95. /**
  96. * @param returnedHitsCount
  97. * @since 1.4-M1
  98. */
  99. public void setReturnedHitsCount( int returnedHitsCount )
  100. {
  101. this.returnedHitsCount = returnedHitsCount;
  102. }
  103. /**
  104. * @return
  105. * @since 1.4-M1
  106. */
  107. public int getTotalHitsMapSize()
  108. {
  109. return totalHitsMapSize;
  110. }
  111. /**
  112. * @param totalHitsMapSize
  113. * @since 1.4-M1
  114. */
  115. public void setTotalHitsMapSize( int totalHitsMapSize )
  116. {
  117. this.totalHitsMapSize = totalHitsMapSize;
  118. }
  119. @Override
  120. public String toString()
  121. {
  122. return "SearchResults{" + "hits=" + hits + ", totalHits=" + totalHits + ", returnedHitsCount="
  123. + returnedHitsCount + ", limits=" + limits + '}';
  124. }
  125. }