| /* |
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| * contributor license agreements. See the NOTICE file distributed with |
| * this work for additional information regarding copyright ownership. |
| * The ASF licenses this file to You 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. |
| */ |
| |
| package org.apache.jdo.util; |
| |
| /** |
| * Helper class providing string utility methods. |
| */ |
| public class StringHelper { |
| |
| /** |
| * Checks if a string is null or empty. |
| * @param aString the string to be checked. |
| * @return <code>true</code> if the string is null or empty after trim, |
| * <code>false</code> otherwise. |
| */ |
| public static boolean isEmpty(String aString) { |
| return ((aString == null) || (aString.trim().length() == 0)); |
| } |
| |
| /** |
| * Returns the package portion of the specified class |
| * @param className the name of the class from which to extract the package |
| * @return package portion of the specified class |
| */ |
| public static String getPackageName(final String className) { |
| if (className != null) { |
| final int index = className.lastIndexOf('.'); |
| |
| return ((index != -1) ? className.substring(0, index) : ""); // NOI18N |
| } |
| |
| return null; |
| } |
| |
| /** |
| * Returns the name of a class without the package name. For example: if |
| * input = "java.lang.Object" , then output = "Object". |
| * @param fully qualified classname |
| * @return the unqualified classname |
| */ |
| public static String getShortClassName(final String className) { |
| if (className != null) { |
| final int index = className.lastIndexOf('.'); |
| |
| return className.substring(index + 1); |
| } |
| return null; |
| } |
| } |