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:ae.config.ActiveEntity.java

/**
 * Configures the super class of the resulting class.
 * //from   w w w .jav  a 2s .com
 * @param desiredSuperClass
 *            class to be used as super Class.
 * @throws NullPointerException
 *             if desiredSuperClass is <code>null</code>.
 */
protected void superClass(final Class<?> desiredSuperClass) {
    checkNotNull(desiredSuperClass, "desiredSuperClass");
    superClass(desiredSuperClass.getCanonicalName());
}

From source file:com.speed.ob.Obfuscator.java

public void execute() {
    LOGGER.info("Starting obfuscation");
    for (Class<? extends ObfuscatorTransform> clazz : transforms) {
        try {//w  w w .j av  a2s .com
            ObfuscatorTransform transform = clazz.getConstructor(Config.class).newInstance(config);
            LOGGER.info("Processing transform: " + clazz.getCanonicalName());
            if (fHandler != null) {
                transform.addLogHandler(fHandler);
            }
            transform.setLogLevel(level, false);
            LOGGER.info("Running: " + clazz.getCanonicalName());
            transform.run(store, config);
            LOGGER.info("Finished processing: " + clazz.getCanonicalName());
            transform.results();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:com.sqewd.open.dal.core.persistence.csv.CSVPersister.java

@Override
public List<AbstractEntity> read(final String query, final Class<?> type, final int limit) throws Exception {
    List<AbstractEntity> result = null;
    String cname = type.getCanonicalName();
    if (!cache.containsKey(cname)) {
        load(type);// w ww.java  2s  . com
    }

    // Make sure the type for the class is available.
    ReflectionUtils.get().getEntityMetadata(type);

    List<AbstractEntity> records = cache.get(cname);
    if (query != null && !query.isEmpty()) {
        SimpleFilterQuery filter = new SimpleFilterQuery();

        filter.parse(new Class<?>[] { type }, query);
        result = filter.select(records);
    } else {
        result = records;
    }
    return result;
}

From source file:org.smartdeveloperhub.vocabulary.config.Configuration.java

private <T> String getExtensionId(final Class<? extends T> clazz) {
    final ConfigurationExtension annotation = clazz.getAnnotation(ConfigurationExtension.class);
    String id = null;/*from   w ww. j a  v a 2  s.  c  o m*/
    if (annotation != null) {
        id = annotation.value();
    } else {
        id = clazz.getSimpleName();
    }
    Preconditions.checkArgument(id != null, "Unknown extension %s", clazz.getCanonicalName());
    return id;
}

From source file:com.openmeap.model.ModelServiceImpl.java

@SuppressWarnings("unchecked")
public <T extends ModelEntity> List<T> findAll(Class<T> clazz) {
    Query q = entityManager.createQuery("select distinct a from " + clazz.getCanonicalName() + " a");
    try {//from  w ww. j av  a2s .  c  o m
        return q.getResultList();
    } catch (NoResultException nre) {
        return null;
    }
}

From source file:com.qubole.quark.plugins.jdbc.JdbcFactory.java

private DataSource getDataSource(Map<String, Object> properties, Class dbClass) throws QuarkException {
    try {// w w w .  j av  a2 s.c  o  m
        return (DataSource) (dbClass.getConstructor(Map.class).newInstance(properties));
    } catch (NoSuchMethodException | IllegalAccessException | InstantiationException e) {
        throw new QuarkException(new Throwable("Invoking invalid constructor on class " + "specified for type "
                + properties.get("type") + ": " + dbClass.getCanonicalName()));
    } catch (InvocationTargetException e) {
        throw new QuarkException(e.getTargetException());
    }
}

From source file:seava.j4e.business.service.AbstractBusinessBaseService.java

/**
 * Return a new instance of a business delegate by the given class.
 * //from www . ja  va 2  s  . com
 * @param <T>
 * @param clazz
 * @return
 * @throws BusinessException
 */
public <T extends AbstractBusinessDelegate> T getBusinessDelegate(Class<T> clazz) throws BusinessException {
    T delegate;
    try {
        delegate = clazz.newInstance();
    } catch (Exception e) {
        throw new BusinessException(ErrorCode.G_RUNTIME_ERROR,
                "Cannot create a new instance of  " + clazz.getCanonicalName(), e);
    }
    delegate.setApplicationContext(this.getApplicationContext());
    delegate.setEntityManager(this.getEntityManager());
    return delegate;
}

From source file:info.archinnov.achilles.internal.metadata.holder.ClusteringComponents.java

void validateClusteringComponents(String className, List<Object> clusteringComponents) {
    Validator.validateNotNull(clusteringComponents,
            "There should be at least one clustering key provided for querying on entity '%s'", className);

    int maxClusteringCount = componentClasses.size();

    Validator.validateTrue(clusteringComponents.size() <= maxClusteringCount,
            "There should be at most %s value(s) of clustering component(s) provided for querying on entity '%s'",
            maxClusteringCount, className);

    validateNoHoleAndReturnLastNonNullIndex(clusteringComponents);

    for (int i = 0; i < clusteringComponents.size(); i++) {
        Object clusteringKey = clusteringComponents.get(i);
        if (clusteringKey != null) {
            Class<?> clusteringType = clusteringKey.getClass();
            Class<?> expectedClusteringType = componentClasses.get(i);

            Validator.validateComparable(clusteringType,
                    "The type '%s' of clustering key '%s' for querying on entity '%s' should implement the Comparable<T> interface",
                    clusteringType.getCanonicalName(), clusteringKey, className);

            Validator.validateTrue(expectedClusteringType.equals(clusteringType),
                    "The type '%s' of clustering key '%s' for querying on entity '%s' is not valid. It should be '%s'",
                    clusteringType.getCanonicalName(), clusteringKey, className,
                    expectedClusteringType.getCanonicalName());
        }/*from  w w w.jav  a 2 s.c o  m*/

    }
}

From source file:it.unisannio.srss.dame.Dame.java

public List<Payload> getAllPayloads() throws IOException {
    Reflections reflections = new Reflections(PAYLOADS_BASE_PACKAGE);
    Set<Class<? extends Payload>> payloadClasses = reflections.getSubTypesOf(Payload.class);
    List<Payload> payloads = new ArrayList<Payload>();
    for (Class<? extends Payload> payloadClass : payloadClasses) {
        try {/*from w  w w .j ava 2  s . co  m*/
            payloads.add(payloadClass.newInstance());
        } catch (Exception e) {
            log.error("Could not load payload: " + payloadClass.getCanonicalName(), e);
        }
    }
    return payloads;
}

From source file:com.norconex.commons.lang.xml.EnhancedXMLStreamWriter.java

public void writeElementClass(String localName, Class<?> value) throws XMLStreamException {
    if (value == null) {
        writeElementObject(localName, null);
    } else {/* w w  w  . ja va 2 s .  com*/
        writeElementObject(localName, value.getCanonicalName());
    }
}