~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to solr/solrj/src/java/org/apache/solr/client/solrj/response/RangeFacet.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.solr.client.solrj.response;
2
 
 
3
 
/*
4
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
5
 
 * contributor license agreements.  See the NOTICE file distributed with
6
 
 * this work for additional information regarding copyright ownership.
7
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
8
 
 * (the "License"); you may not use this file except in compliance with
9
 
 * 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, software
14
 
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 
 * See the License for the specific language governing permissions and
17
 
 * limitations under the License.
18
 
 */
19
 
 
20
 
import java.util.ArrayList;
21
 
import java.util.List;
22
 
 
23
 
/**
24
 
 * Represents a range facet result
25
 
 */
26
 
public abstract class RangeFacet<B, G> {
27
 
 
28
 
  private final String name;
29
 
  private final List<Count> counts = new ArrayList<Count>();
30
 
 
31
 
  private final B start;
32
 
  private final B end;
33
 
  private final G gap;
34
 
 
35
 
  private final Number before;
36
 
  private final Number after;
37
 
 
38
 
  protected RangeFacet(String name, B start, B end, G gap, Number before, Number after) {
39
 
    this.name = name;
40
 
    this.start = start;
41
 
    this.end = end;
42
 
    this.gap = gap;
43
 
    this.before = before;
44
 
    this.after = after;
45
 
  }
46
 
 
47
 
  public void addCount(String value, int count) {
48
 
    counts.add(new Count(value, count, this));
49
 
  }
50
 
 
51
 
  public String getName() {
52
 
    return name;
53
 
  }
54
 
 
55
 
  public List<Count> getCounts() {
56
 
    return counts;
57
 
  }
58
 
 
59
 
  public B getStart() {
60
 
    return start;
61
 
  }
62
 
 
63
 
  public B getEnd() {
64
 
    return end;
65
 
  }
66
 
 
67
 
  public G getGap() {
68
 
    return gap;
69
 
  }
70
 
 
71
 
  public Number getBefore() {
72
 
    return before;
73
 
  }
74
 
 
75
 
  public Number getAfter() {
76
 
    return after;
77
 
  }
78
 
 
79
 
  public static class Numeric extends RangeFacet<Number, Number> {
80
 
 
81
 
    public Numeric(String name, Number start, Number end, Number gap, Number before, Number after) {
82
 
      super(name, start, end, gap, before, after);
83
 
    }
84
 
 
85
 
  }
86
 
 
87
 
  public static class Date extends RangeFacet<java.util.Date, String> {
88
 
 
89
 
    public Date(String name, java.util.Date start, java.util.Date end, String gap, Number before, Number after) {
90
 
      super(name, start, end, gap, before, after);
91
 
    }
92
 
 
93
 
  }
94
 
 
95
 
  public static class Count {
96
 
 
97
 
    private final String value;
98
 
    private final int count;
99
 
    private final RangeFacet rangeFacet;
100
 
 
101
 
    public Count(String value, int count, RangeFacet rangeFacet) {
102
 
      this.value = value;
103
 
      this.count = count;
104
 
      this.rangeFacet = rangeFacet;
105
 
    }
106
 
 
107
 
    public String getValue() {
108
 
      return value;
109
 
    }
110
 
 
111
 
    public int getCount() {
112
 
      return count;
113
 
    }
114
 
 
115
 
    public RangeFacet getRangeFacet() {
116
 
      return rangeFacet;
117
 
    }
118
 
  }
119
 
 
120
 
}