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
19cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn/**
200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Helper for accessing features in {@link android.util.DebugUtils}
210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * introduced after API level 4 in a backwards compatible fashion.
220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov *
230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @hide
24cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */
25cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornpublic class DebugUtils {
260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov
27cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public static void buildShortClassTag(Object cls, StringBuilder out) {
28cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn        if (cls == null) {
29cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            out.append("null");
30cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn        } else {
31cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            String simpleName = cls.getClass().getSimpleName();
32cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            if (simpleName == null || simpleName.length() <= 0) {
33cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn                simpleName = cls.getClass().getName();
34cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn                int end = simpleName.lastIndexOf('.');
35cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn                if (end > 0) {
36cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn                    simpleName = simpleName.substring(end+1);
37cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn                }
38cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            }
39cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            out.append(simpleName);
40cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            out.append('{');
41cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn            out.append(Integer.toHexString(System.identityHashCode(cls)));
42cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn        }
43cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    }
44cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn}
45