Example usage for java.lang Class getCanonicalName

List of usage examples for java.lang Class getCanonicalName

Introduction

In this page you can find the example usage for java.lang Class getCanonicalName.

Prototype

public String getCanonicalName() 

Source Link

Document

Returns the canonical name of the underlying class as defined by the Java Language Specification.

Usage

From source file:ca.uwaterloo.iss4e.hadoop.io.CartesianInputFormat.java

public static void setLeftInputInfo(Job job, Class<? extends FileInputFormat> inputFormat, String inputPath) {
    Configuration conf = job.getConfiguration();
    conf.set(LEFT_INPUT_FORMAT, inputFormat.getCanonicalName());
    conf.set(LEFT_INPUT_PATH, inputPath);
}

From source file:ca.uwaterloo.iss4e.hadoop.io.CartesianInputFormat.java

public static void setRightInputInfo(Job job, Class<? extends FileInputFormat> inputFormat, String inputPath) {
    Configuration conf = job.getConfiguration();
    conf.set(RIGHT_INPUT_FORMAT, inputFormat.getCanonicalName());
    conf.set(RIGHT_INPUT_PATH, inputPath);
}

From source file:Main.java

/**
 * getMethodNameList//  w ww.j a  va2s .c  o m
 * @param theClass
 * @return
 */
public final static HashMap<String, Integer> getMethodNameList(Class<?> theClass) {
    // Method - Number of params
    HashMap<String, Integer> methodsAndParams = new HashMap<String, Integer>();
    // Get the class name
    String className = theClass.getCanonicalName();

    Method[] classMethods = theClass.getDeclaredMethods();
    String currMethodCanonicalName = "";
    String currMethodName = "";
    int currMethodNumberParams = 0;
    for (int i = 0; i < classMethods.length; i++) {
        currMethodCanonicalName = classMethods[i].toString();

        // Get method name only
        String methodString = currMethodCanonicalName.substring(currMethodCanonicalName.lastIndexOf(className),
                currMethodCanonicalName.indexOf('('));
        currMethodName = methodString.substring(methodString.lastIndexOf('.') + 1, methodString.length());

        // Get method number of params
        String params = currMethodCanonicalName.substring(currMethodCanonicalName.indexOf('(') + 1,
                currMethodCanonicalName.lastIndexOf(')'));
        String theParams[] = params.split(",");
        currMethodNumberParams = theParams.length;

        methodsAndParams.put(currMethodName, currMethodNumberParams);
    }

    /**
    for (String name: methodsAndParams.keySet()){
       String key =name.toString();
       String value = methodsAndParams.get(name).toString();  
       System.out.println(key + " " + value);  
    } 
     */

    return methodsAndParams;

}

From source file:com.streamsets.pipeline.stage.destination.mapreduce.MapreduceUtils.java

/**
 * Add jars containing the following classes to the job's classpath.
 *///from   w  w  w  . jav a 2 s.  c om
public static void addJarsToJob(Configuration conf, Class... klasses) {
    // Build set of jars that needs to be added, order doesn't matter for us and we will remove duplicates
    Set<String> additinonalJars = new HashSet<>();
    for (Class klass : klasses) {
        final String jar = jarForClass(klass);
        LOG.info("Adding jar {} for class {}", jar, klass.getCanonicalName());
        additinonalJars.add(jar);
    }

    appendJars(conf, additinonalJars);
}

From source file:com.sqewd.open.dal.services.EntitySchema.java

public static EntitySchema loadSchema(Class<?> type) throws Exception {
    if (!type.isAnnotationPresent(Entity.class))
        throw new Exception("Class [" + type.getCanonicalName() + "] has not been annotated as an Entity.");

    StructEntityReflect enref = ReflectionUtils.get().getEntityMetadata(type);

    return loadSchema(enref);
}

From source file:jp.co.acroquest.endosnipe.perfdoctor.rule.RuleInstanceUtil.java

/**
 * ??//from w  w  w .  j a v  a 2  s  . c  o  m
 * @param obj ?
 * @param fieldName ??
 * @param value 
 * @throws RuleCreateException ???????
 */
protected static void setValue(final Object obj, final String fieldName, final String value)
        throws RuleCreateException {
    Class<? extends Object> clazz = obj.getClass();
    Object[] args = new Object[] { clazz.getCanonicalName(), fieldName, value };

    try {
        Field field = clazz.getField(fieldName);

        Object convertedValue = ConvertUtils.convert(value, field.getType());
        field.set(obj, convertedValue);
    } catch (NoSuchFieldException ex) {
        throw new RuleCreateException(PerfConstants.PROPERTY_NOT_FOUND, args);
    } catch (SecurityException ex) {
        throw new RuleCreateException(PerfConstants.PROPERTY_ERROR, args);
    } catch (IllegalArgumentException ex) {
        throw new RuleCreateException(PerfConstants.PROPERTY_TYPE_ERROR, args);
    } catch (IllegalAccessException ex) {
        throw new RuleCreateException(PerfConstants.PROPERTY_ACCESS_ERROR, args);
    }
}

From source file:com.alta189.bukkit.script.event.EventScanner.java

public static void removeEvents(Plugin plugin) {
    if (pluginEvents.containsKey(plugin)) {
        Set<Class<? extends Event>> events = pluginEvents.get(plugin);

        for (Class<? extends Event> clazz : events) {
            String className = clazz.getCanonicalName();
            if (className == null) {
                className = clazz.getName();
            }//  w  w w . ja v  a 2  s .  co m
            EventScanner.events.remove(className);
        }

        pluginEvents.remove(plugin);
    }
}

From source file:br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.java

private static <T> String getExceptionMessage(Class<T> type, List<Class<? extends T>> ambiguous) {
    StringBuffer classes = new StringBuffer();

    int i = 0;/*from ww w  .  j  a  v a2 s. c o  m*/
    for (Class<? extends T> clazz : ambiguous) {
        if (i++ != 0) {
            classes.append(", ");
        }

        classes.append(clazz.getCanonicalName());
    }

    return getBundle().getString("ambiguous-strategy-resolution", type.getCanonicalName(), classes.toString());
}

From source file:com.alta189.bukkit.script.event.EventScanner.java

private static Class<? extends Event> getEventClass(String pluginName, String event) {
    Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName);
    Set<? extends Class<? extends Event>> classes = pluginEvents.get(plugin);
    if (plugin != null) {
        if (event.contains(".")) {
            for (Class<? extends Event> clazz : classes) {
                String className = clazz.getCanonicalName();
                if (className == null) {
                    className = clazz.getName();
                }//from   ww  w  . j a v a2 s  . c om
                if (className.equals(event)) {
                    return clazz;
                }
            }
        } else {
            for (Class<? extends Event> clazz : classes) {
                if (clazz.getSimpleName().equals(event)) {
                    return clazz;
                }
            }
        }
    }
    return null;
}

From source file:com.shelfmap.stepsfinder.CandidateStepsFactory.java

public static List<Object> createStepsInstances(Class<?> embedderClass) {
    List<Object> steps = new ArrayList<Object>();
    for (Class<?> clazz : findStepsClasses(embedderClass)) {
        try {// w  w w. ja va  2 s. com
            steps.add(clazz.newInstance());
        } catch (InstantiationException ex) {
            LOGGER.error("Could not instanciate a class: " + clazz.getCanonicalName(), ex);
        } catch (IllegalAccessException ex) {
            LOGGER.error("Could not access ot the constructer of the class: " + clazz.getCanonicalName(), ex);
        }
    }
    return steps;
}