Here you can find the source of getUnifiedCity(@Nullable final String sCity, @Nonnull final Locale aSortLocale)
@Nullable public static String getUnifiedCity(@Nullable final String sCity, @Nonnull final Locale aSortLocale)
//package com.java2s; /**//from ww w . ja va2s. c o m * Copyright (C) 2014-2015 Philip Helger (www.helger.com) * philip[at]helger[dot]com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Locale; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class Main { private static final AtomicBoolean s_aComplexAddressHandlingEnabled = new AtomicBoolean(false); @Nullable public static String getUnifiedCity(@Nullable final String sCity, @Nonnull final Locale aSortLocale) { if (!isComplexAddressHandlingEnabled()) return sCity; if (sCity == null) return null; return _unifyPart(sCity, aSortLocale); } public static boolean isComplexAddressHandlingEnabled() { return s_aComplexAddressHandlingEnabled.get(); } @Nullable private static String _unifyPart(@Nonnull final String sPart, @Nonnull final Locale aSortLocale) { // empty name? String s = sPart.trim(); final int nLength = s.length(); if (nLength == 0) return null; // all upper case name? if (nLength == 1) return s.toUpperCase(aSortLocale); // uppercase first only s = s.substring(0, 1).toUpperCase(aSortLocale) + s.substring(1); return s; } }