AbstractStringLookup.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements. See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache license, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the license for the specific language governing permissions and
  15.  * limitations under the license.
  16.  */

  17. package org.apache.commons.text.lookup;

  18. import org.apache.commons.lang3.StringUtils;

  19. /**
  20.  * A default lookup for others to extend in this package.
  21.  *
  22.  * @since 1.3
  23.  */
  24. abstract class AbstractStringLookup implements StringLookup {

  25.     /**
  26.      * The default split char.
  27.      */
  28.     protected static final char SPLIT_CH = ':';

  29.     /**
  30.      * The default split string.
  31.      */
  32.     protected static final String SPLIT_STR = String.valueOf(SPLIT_CH);

  33.     /**
  34.      * Creates a lookup key for a given file and key.
  35.      */
  36.     static String toLookupKey(final String left, final String right) {
  37.         return toLookupKey(left, SPLIT_STR, right);
  38.     }

  39.     /**
  40.      * Creates a lookup key for a given file and key.
  41.      */
  42.     static String toLookupKey(final String left, final String separator, final String right) {
  43.         return left + separator + right;
  44.     }

  45.     /**
  46.      * Returns the substring after the first occurrence of {@code ch} in {@code value}.
  47.      *
  48.      * @param value The source string.
  49.      * @param ch The character to search.
  50.      * @return a new string.
  51.      * @deprecated Use {@link StringUtils#substringAfter(String, int)}.
  52.      */
  53.     @Deprecated
  54.     protected String substringAfter(final String value, final char ch) {
  55.         return StringUtils.substringAfter(value, ch);
  56.     }

  57.     /**
  58.      * Returns the substring after the first occurrence of {@code str} in {@code value}.
  59.      *
  60.      * @param value The source string.
  61.      * @param str The string to search.
  62.      * @return a new string.
  63.      * @deprecated Use {@link StringUtils#substringAfter(String, String)}.
  64.      */
  65.     @Deprecated
  66.     protected String substringAfter(final String value, final String str) {
  67.         return StringUtils.substringAfter(value, str);
  68.     }

  69.     /**
  70.      * Returns the substring after the first occurrence of {@code ch} in {@code value}.
  71.      *
  72.      * @param value The source string.
  73.      * @param ch The character to search.
  74.      * @return a new string.
  75.      * @deprecated Use {@link StringUtils#substringAfterLast(String, int)}.
  76.      */
  77.     @Deprecated
  78.     protected String substringAfterLast(final String value, final char ch) {
  79.         return StringUtils.substringAfterLast(value, ch);
  80.     }

  81. }