/*
 * Copyright (C) 2014 Lucas Rocha
 *
 * 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.
 */

package org.lucasr.probe;

import android.content.Context;
import android.view.View;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

/**
 * Utility methods to find and load {@link View} classes. Used
 * by {@link ProbeViewFactory}.
 *
 * @see ProbeViewFactory
 */
class ViewClassUtil {
    private ViewClassUtil() {
    }

    static final String[] VIEW_CLASS_PREFIX_LIST = {
            "android.widget.",
            "android.webkit."
    };

    /**
     * Loads clas for the given class name.
     */
    static Class<?> loadViewClass(Context context, String name)
            throws ClassNotFoundException {
        return context.getClassLoader().loadClass(name).asSubclass(View.class);
    }

    /**
     * Tries to load class using a predefined list of class prefixes for
     * Android views.
     */
    static Class<?> findViewClass(Context context, String name)
            throws ClassNotFoundException {
        if (name.indexOf('.') >= 0) {
            return loadViewClass(context, name);
        }

        for (String prefix : VIEW_CLASS_PREFIX_LIST) {
            try {
                return loadViewClass(context, prefix + name);
            } catch (ClassNotFoundException e) {
                continue;
            }
        }

        throw new ClassNotFoundException("Couldn't load View class for " + name);
    }
}

/*
 * Copyright (C) 2014 Lucas Rocha
 *
 * 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.
 */

package org.lucasr.probe;

import android.content.Context;
import android.view.View;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

/**
 * Utility methods to find and load {@link View} classes. Used
 * by {@link ProbeViewFactory}.
 *
 * @see ProbeViewFactory
 */
class ViewClassUtil {
    private ViewClassUtil() {
    }

    static final String[] VIEW_CLASS_PREFIX_LIST = {
            "android.widget.",
            "android.webkit."
    };

    /**
     * Loads class for the given class name.
     */
    static Class<?> loadViewClass(Context context, String name)
            throws ClassNotFoundException {
        return context.getClassLoader().loadClass(name).asSubclass(View.class);
    }

    /**
     * Tries to load class using a predefined list of class prefixes for
     * Android views.
     */
    static Class<?> findViewClass(Context context, String name)
            throws ClassNotFoundException {
        if (name.indexOf('.') >= 0) {
            return loadViewClass(context, name);
        }

        for (String prefix : VIEW_CLASS_PREFIX_LIST) {
            try {
                return loadViewClass(context, prefix + name);
            } catch (ClassNotFoundException e) {
                continue;
            }
        }

        throw new ClassNotFoundException("Couldn't load View class for " + name);
    }
}

Fix typo in JavaDoc