Example usage for java.lang Class toString

List of usage examples for java.lang Class toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Converts the object to a string.

Usage

From source file:org.eurekastreams.commons.search.bootstrap.SearchIndexManager.java

/**
 * purge the search index of all the entities of the input type.
 *
 * @param entityClass/*w  ww .  j  av a2s  . c o  m*/
 *            the type of entities to purge
 * @param search
 *            the FullTextSession to use
 */
@SuppressWarnings("unchecked")
public void purgeSearchIndex(final Class entityClass, final FullTextSession search) {
    log.info("purgeSearchIndex(" + entityClass.toString() + ")");

    String entityName = entityClass.toString().substring(entityClass.toString().lastIndexOf('.') + 1);

    log.info("Purging indexed data for " + entityName);
    search.purgeAll(entityClass);
    search.flushToIndexes();

    log.info("Optimizing index for " + entityName);
    search.getSearchFactory().optimize(entityClass);
    search.flushToIndexes();
}

From source file:corina.logging.CorinaLog.java

public CorinaLog(Class clazz) {
    super(clazz.toString());
    this.chained = LogFactory.getLog(clazz);
}

From source file:eu.stratosphere.nephele.io.compression.CompressionLoader.java

@SuppressWarnings("unchecked")
private static CompressionLibrary initCompressionLibrary(String libraryClass) {

    Class<? extends CompressionLibrary> compressionLibraryClass;
    try {/*  ww w.j av a2  s.  c  o  m*/
        compressionLibraryClass = (Class<? extends CompressionLibrary>) Class.forName(libraryClass);
    } catch (ClassNotFoundException e1) {
        LOG.error(e1);
        return null;
    }

    if (compressionLibraryClass == null) {
        LOG.error("Cannot load compression library " + libraryClass);
        return null;
    }

    Constructor<? extends CompressionLibrary> constructor;
    try {
        constructor = compressionLibraryClass.getConstructor(String.class);
    } catch (SecurityException e) {
        LOG.error(e);
        return null;
    } catch (NoSuchMethodException e) {
        LOG.error(e);
        return null;
    }
    if (constructor == null) {
        LOG.error("Cannot find matching constructor for class " + compressionLibraryClass.toString());
        return null;
    }

    CompressionLibrary compressionLibrary;

    try {
        compressionLibrary = constructor.newInstance(getNativeLibraryPath(libraryClass));
    } catch (IllegalArgumentException e) {
        LOG.error(StringUtils.stringifyException(e));
        return null;
    } catch (InstantiationException e) {
        LOG.error(StringUtils.stringifyException(e));
        return null;
    } catch (IllegalAccessException e) {
        LOG.error(StringUtils.stringifyException(e));
        return null;
    } catch (InvocationTargetException e) {
        LOG.error(StringUtils.stringifyException(e));
        return null;
    }

    return compressionLibrary;
}

From source file:de.halfbit.featured.FeatureHost.java

/**
 * Get a feature by its classname, which is registered in the feature host.
 *
 * @param featureClass feature class/*from   ww  w .  j  a  v a 2s .co m*/
 * @return registered feature of {@code null}
 */
@Nullable
public <F extends Feature> F getFeature(@NonNull Class<F> featureClass) {
    //noinspection unchecked
    return (F) mFeatures.get(featureClass.toString());
}

From source file:net.ymate.platform.core.beans.intercept.InterceptProxy.java

private List<Class<? extends IInterceptor>> __doGetBeforeIntercepts(Class<?> targetClass, Method targetMethod) {
    String _cacheKey = DigestUtils.md5Hex(targetClass.toString() + targetMethod.toString());
    ///*from w ww. ja  va 2s  .  c  om*/
    if (__beforeInterceptsCache.containsKey(_cacheKey)) {
        return __beforeInterceptsCache.get(_cacheKey);
    }
    synchronized (__beforeCacheLocker) {
        List<Class<? extends IInterceptor>> _classes = __beforeInterceptsCache.get(_cacheKey);
        if (_classes != null) {
            return _classes;
        }
        _classes = InterceptAnnoHelper.getBeforeIntercepts(targetClass, targetMethod);
        //
        if (!_classes.isEmpty()) {
            __beforeInterceptsCache.put(_cacheKey, _classes);
        }
        //
        return _classes;
    }
}

From source file:net.ymate.platform.core.beans.intercept.InterceptProxy.java

private List<Class<? extends IInterceptor>> __doGetAfterIntercepts(Class<?> targetClass, Method targetMethod) {
    String _cacheKey = DigestUtils.md5Hex(targetClass.toString() + targetMethod.toString());
    ////from  ww  w.  j  a v a2s.  c o m
    if (__afterInterceptsCache.containsKey(_cacheKey)) {
        return __afterInterceptsCache.get(_cacheKey);
    }
    synchronized (__afterCacheLocker) {
        List<Class<? extends IInterceptor>> _classes = __afterInterceptsCache.get(_cacheKey);
        if (_classes != null) {
            return _classes;
        }
        _classes = InterceptAnnoHelper.getAfterIntercepts(targetClass, targetMethod);
        //
        if (!_classes.isEmpty()) {
            __afterInterceptsCache.put(_cacheKey, _classes);
        }
        //
        return _classes;
    }
}

From source file:org.coding.git.api.CodingNetApiUtil.java

@NotNull
public static <T> T fromJson(@Nullable JsonElement json, @NotNull Class<T> classT) throws IOException {
    if (json == null) {
        throw new CodingNetJsonException("Unexpected empty response");
    }//from  ww w . j  ava 2 s.  co  m

    T res;
    try {
        //cast as workaround for early java 1.6 bug
        //noinspection RedundantCast
        res = (T) gson.fromJson(json, classT);
    } catch (ClassCastException e) {
        throw new CodingNetJsonException("Parse exception while converting JSON to object " + classT.toString(),
                e);
    } catch (JsonParseException e) {
        throw new CodingNetJsonException("Parse exception while converting JSON to object " + classT.toString(),
                e);
    }
    if (res == null) {
        throw new CodingNetJsonException("Empty Json response");
    }
    return res;
}

From source file:org.apache.hama.bsp.BSPMaster.java

public static BSPMaster constructMaster(Class<? extends BSPMaster> masterClass, final Configuration conf) {
    try {/*from   ww  w.  j a va2 s .  c o m*/
        Constructor<? extends BSPMaster> c = masterClass.getConstructor(Configuration.class);
        return c.newInstance(conf);
    } catch (Exception e) {
        throw new RuntimeException("Failed construction of " + "Master: " + masterClass.toString()
                + ((e.getCause() != null) ? e.getCause().getMessage() : ""), e);
    }
}

From source file:de.hackerspacebremen.format.JSONFormatter.java

private String getGetter(final String fieldName, final Class<?> type) {
    final StringBuilder sBuilder = new StringBuilder();
    if (type.toString().equals("boolean")) {
        sBuilder.append("is");
    } else {// ww  w.j  a v  a2  s .  c o m
        sBuilder.append("get");
    }
    sBuilder.append(this.firstToUpperCharacter(fieldName));
    return sBuilder.toString();
}

From source file:org.eurekastreams.commons.search.bootstrap.SearchIndexManager.java

/**
 * Purge & index all entities with the input class and name.
 *
 * @param entityClass/*  w  w  w. j a v a2  s .  c om*/
 *            the type of entities to reindex into search index.
 *
 * @param entityName
 *            the name of the entity to reindex
 *
 * @param search
 *            the FullTextSession to use
 */
@SuppressWarnings("unchecked")
public void reindexEntities(final Class entityClass, final String entityName, final FullTextSession search) {
    log.info("reindexEntities(" + entityClass.toString() + ", " + entityName + ")");

    // purge first
    purgeSearchIndex(entityClass, search);

    log.info("Creating query to find batches of " + entityName);
    Query q = search.createQuery("FROM " + entityName)
            // set the result transformer
            //        .setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY) <TODO COMMENTED OUT>
            // minimize cache
            .setCacheMode(CacheMode.IGNORE)
            // limit fetch size
            .setFetchSize(fetchBatchSize);
    log.info("setting scroll mode to FORWARD_ONLY for " + entityName);
    ScrollableResults scroll = q.scroll(ScrollMode.FORWARD_ONLY);

    int batch = 0;
    while (scroll.next()) {
        batch++;
        search.index(scroll.get(0));
        if (batch % flushBatchSize == 0) {
            if (log.isInfoEnabled()) {
                log.info("Flushing " + entityName + " - " + batch);
            }

            // no need to call s.flush()
            // we don't change anything
            search.flushToIndexes();
            search.clear();
        }
    }

    log.info("Flushing " + entityName + " - " + batch + " (final)");
    search.flushToIndexes();
    search.clear();

    log.info("Optimizing index for " + entityName);
    search.getSearchFactory().optimize(entityClass);
}