1cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn/*
2cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Copyright (C) 2011 The Android Open Source Project
3cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn *
4cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License");
5cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * you may not use this file except in compliance with the License.
6cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * You may obtain a copy of the License at
7cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn *
8cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn *      http://www.apache.org/licenses/LICENSE-2.0
9cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn *
10cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Unless required by applicable law or agreed to in writing, software
11cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS,
12cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * See the License for the specific language governing permissions and
14cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * limitations under the License.
15cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */
16cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
17cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornpackage android.support.v4.util;
18cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
198e10080c914d1ad0784394fa3026b85535535847Aurimas Liutikasimport static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP;
20c39d9c75590eca86a5e7e32a8824ba04a0d42e9bAlan Viverette
218e10080c914d1ad0784394fa3026b85535535847Aurimas Liutikasimport android.support.annotation.RestrictTo;
22c39d9c75590eca86a5e7e32a8824ba04a0d42e9bAlan Viverette
23cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn/**
240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Helper for accessing features in {@link android.util.DebugUtils}
250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * introduced after API level 4 in a backwards compatible fashion.
260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov *
270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @hide
28cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */
298e10080c914d1ad0784394fa3026b85535535847Aurimas Liutikas@RestrictTo(LIBRARY_GROUP)
30cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornpublic class DebugUtils {
310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov
32cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public static void buildShortClassTag(Object cls, StringBuilder out) {
33cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn        if (cls == null) {
34cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            out.append("null");
35cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn        } else {
36cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            String simpleName = cls.getClass().getSimpleName();
37cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            if (simpleName == null || simpleName.length() <= 0) {
38cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn                simpleName = cls.getClass().getName();
39cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn                int end = simpleName.lastIndexOf('.');
40cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn                if (end > 0) {
41cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn                    simpleName = simpleName.substring(end+1);
42cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn                }
43cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            }
44cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            out.append(simpleName);
45cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            out.append('{');
46cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            out.append(Integer.toHexString(System.identityHashCode(cls)));
47cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn        }
48cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    }
49cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn}
50