001: /**
002: * Copyright 2006 Webmedia Group Ltd.
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: **/package org.araneaframework.uilib.list.util.like;
016:
017: import java.io.Serializable;
018:
019: /**
020: * Like filter configuration.
021: *
022: * @author <a href="mailto:rein@araneaframework.org">Rein Raudjärv</a>
023: */
024: public class LikeConfiguration implements Serializable {
025:
026: /** Default custom any string wildcards. */
027: public static final String[] DEFAULT_ANY_STRING_WILDCARDS = { "*",
028: "%" };
029: /** Default custom any character wildcards. */
030: public static final String[] DEFAULT_ANY_CHAR_WILDCARDS = { ".",
031: "_", "?" };
032: /** Default line start/end any string wildcard handler. */
033: public static final WildcardHandler DEFAULT_HANDLER = new AutomaticWildcardHandler();
034:
035: /** Custom any string wildcards (e.g. *). */
036: private String[] anyStringWildcards = DEFAULT_ANY_STRING_WILDCARDS;
037: /** Custom any character wildcards (e.g. ?). */
038: private String[] anyCharWildcards = DEFAULT_ANY_CHAR_WILDCARDS;
039: /** Custom line start/end any string wildcard handler. */
040: private WildcardHandler wildcardHandler = DEFAULT_HANDLER;
041:
042: /**
043: * Returns the custom any character wildcard.
044: *
045: * @return the custom any character wildcard.
046: */
047: public String[] getAnyCharWildcards() {
048: return anyCharWildcards;
049: }
050:
051: /**
052: * Sets the custom any character wildcard.
053: *
054: * @param anyCharWildcards custom any character wildcard.
055: */
056: public void setAnyCharWildcards(String[] anyCharWildcards) {
057: this .anyCharWildcards = anyCharWildcards;
058: }
059:
060: /**
061: * Returns new instance of the line start/end any string wildcard handler.
062: *
063: * @return new instance of the line start/end any string wildcard handler.
064: */
065: public WildcardHandler createWildcardHandler() {
066: if (this .wildcardHandler == null) {
067: throw new IllegalStateException(
068: "anyStringWildcardHandler must be set first");
069: }
070: return wildcardHandler.newInstance();
071: }
072:
073: /**
074: * Sets the line start/end any string wildcard handler.
075: *
076: * @param anyStringWildcardHandler line start/end any string wildcard handler.
077: */
078: public void setWildcardHandler(
079: WildcardHandler anyStringWildcardHandler) {
080: this .wildcardHandler = anyStringWildcardHandler;
081: }
082:
083: /**
084: * Returns the custom any string wildcard.
085: *
086: * @return the custom any string wildcard.
087: */
088: public String[] getAnyStringWildcards() {
089: return anyStringWildcards;
090: }
091:
092: /**
093: * Sets the custom any string wildcard.
094: *
095: * @param anyStringWildcards custom any string wildcard.
096: */
097: public void setAnyStringWildcards(String[] anyStringWildcards) {
098: this.anyStringWildcards = anyStringWildcards;
099: }
100: }
|