001: /*
002: * Copyright 2004 Outerthought bvba and Schaubroeck nv
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.outerj.daisy.repository.query;
017:
018: import java.util.HashMap;
019: import java.util.Map;
020:
021: public final class FacetConf {
022: private FacetType type;
023: private boolean isFacet;
024: private int maxValues;
025: private boolean sortOnValue;
026: private boolean sortAscending;
027: private Map<String, String> properties = new HashMap<String, String>();
028:
029: public FacetConf(boolean isFacet) {
030: this ();
031: this .isFacet = isFacet;
032: }
033:
034: public FacetConf(boolean isFacet, String type) {
035: this (isFacet);
036: this .type = FacetType.valueOf(type);
037: }
038:
039: public FacetConf(int maxValues, boolean sortOnValue,
040: boolean sortAscending) {
041: this (true, maxValues, sortOnValue, sortAscending,
042: FacetType.DEFAULT.name());
043: }
044:
045: public FacetConf(boolean isFacet, int maxValues,
046: boolean sortOnValue, boolean sortAscending, String type) {
047: this .isFacet = isFacet;
048: this .maxValues = maxValues;
049: this .sortOnValue = sortOnValue;
050: this .sortAscending = sortAscending;
051: this .type = FacetType.valueOf(type);
052: }
053:
054: public FacetConf() {
055: this (true, 10, true, true, FacetType.DEFAULT.name());
056: }
057:
058: public boolean isFacet() {
059: return isFacet;
060: }
061:
062: public void setIsFacet(boolean isFacet) {
063: this .isFacet = isFacet;
064: }
065:
066: /**
067: * The maximum number of distinct values to be returned, -1 for all.
068: */
069: public int getMaxValues() {
070: return maxValues;
071: }
072:
073: public void setMaxValues(int maxValues) {
074: this .maxValues = maxValues;
075: }
076:
077: /**
078: * If true, the distinct values for this facet should be sorted on value,
079: * otherwise on count.
080: */
081: public boolean getSortOnValue() {
082: return sortOnValue;
083: }
084:
085: public void setSortOnValue(boolean sortOnValue) {
086: this .sortOnValue = sortOnValue;
087: }
088:
089: /**
090: * If true, sorting happens ascending, otherwise descending.
091: */
092: public boolean getSortAscending() {
093: return sortAscending;
094: }
095:
096: public void setSortAscending(boolean sortAscending) {
097: this .sortAscending = sortAscending;
098: }
099:
100: public FacetType getType() {
101: return type;
102: }
103:
104: public void setType(FacetType type) {
105: this .type = type;
106: }
107:
108: public Map<String, String> getProperties() {
109: return properties;
110: }
111:
112: public void setProperties(Map<String, String> properties) {
113: this .properties = properties;
114: }
115:
116: public enum FacetType {
117: DEFAULT, DATE, STRING, NUMBER
118: }
119: }
|