Example usage for java.lang Class getSimpleName

List of usage examples for java.lang Class getSimpleName

Introduction

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

Prototype

public String getSimpleName() 

Source Link

Document

Returns the simple name of the underlying class as given in the source code.

Usage

From source file:com.planetmayo.debrief.satc_rcp.io.XStreamIO.java

private static void aliasFor(XStream xstream, Class<?> klass) {
    String simpleName = klass.getSimpleName();
    xstream.alias(Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1), klass);
}

From source file:Main.java

private static void putKeyValue(Class<?> clazz, String buildField, SortedMap<String, String> keysToValues) {
    try {/*from www  . java 2  s  .  c  o m*/
        Field field = clazz.getField(buildField);
        Object value = field.get(null);
        String key = clazz.getSimpleName().toLowerCase() + "." + buildField.toLowerCase();
        keysToValues.put(key, String.valueOf(value));
    } catch (SecurityException e) {
        // ignore
    } catch (NoSuchFieldException e) {
        // ignore
    } catch (IllegalAccessException e) {
        // ignore
    }
}

From source file:ReflectUtils.java

/**
 * Adds the class SimpleNames, comma sepearated and surrounded by paranthesis to the
 * call StringBuffer/* w  w w  .j a  v  a 2 s . c om*/
 * @param call
 * @param params
 * @return
 */
public static StringBuilder addParamsString(StringBuilder call, Class[] params) {
    call.append("(");
    boolean firstArg = true;
    for (Class arg : params) {
        if (firstArg) {
            firstArg = false;
        } else {
            call.append(", ");
        }
        call.append(arg.getSimpleName());
    }
    call.append(")");
    return call;
}

From source file:Main.java

private static void appendClassDerivation(Object object, StringBuilder builder) {
    builder.append(object.getClass().getSimpleName());
    Class<?> c = object.getClass().getSuperclass();
    String s = null;/*from   www.  java 2 s. c om*/
    while (c != null) {
        s = c.getSimpleName() + "." + s;
        c = c.getSuperclass();
    }
    builder.append(s);
}

From source file:com.github.thesmartenergy.sparql.generate.jena.engine.TestBase.java

static void setUpClass(Class clazz) throws Exception {
    LOG = Logger.getLogger(clazz);
    LOG.debug(clazz.getName());/*w w w  .  j a  va2  s.  c o m*/
    String dir = clazz.getSimpleName();
    dir = Character.toLowerCase(dir.charAt(0)) + (dir.length() > 1 ? dir.substring(1) : "");
    examplePath = clazz.getResource("/" + dir);

    exampleDir = new File(examplePath.toURI());

    // read location-mapping
    URI confUri = exampleDir.toURI().resolve("configuration.ttl");
    Model conf = RDFDataMgr.loadModel(confUri.toString());

    // initialize file manager
    fileManager = FileManager.makeGlobal();
    Locator loc = new LocatorFile(exampleDir.toURI().getPath());
    LocationMapper mapper = new LocationMapper(conf);
    fileManager.addLocator(loc);
    fileManager.setLocationMapper(mapper);
}

From source file:gaffer.example.gettingstarted.walkthrough.WalkthroughStrSubstitutor.java

private static String getJavaDocLink(final Class<?> clazz) {
    return "[" + clazz.getSimpleName() + "](" + JAVA_DOC_URL_PREFIX + clazz.getName().replaceAll("\\.", "/")
            + ".html)";
}

From source file:co.runrightfast.core.utils.JmxUtils.java

/**
 *
 * @param domain JMX domain/*from   w ww. j  a  va  2s.  c  om*/
 * @param mbeanType used to add a type attribute
 * @return ObjectName
 */
static ObjectName applicationMBeanObjectName(final String domain, @NonNull final Class<?> mbeanType) {
    checkArgument(isNotBlank(domain));
    try {
        return ObjectName.getInstance(domain, "type", mbeanType.getSimpleName());
    } catch (final MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
}

From source file:ips1ap101.ejb.core.BeanLocator.java

private static Object lookup(Class<?> local) {
    Bitacora.trace(BeanLocator.class, "lookup", local);
    String key = EAC.JNDI_EJB_LOOKUP_PATTERN;
    String pattern = EA.getString(key);
    String name = local.getSimpleName();
    String root = StringUtils.removeEnd(name, LOCAL_SUFFIX);
    String arg0 = root + BEANS_SUFFIX;
    String arg1 = local.getName();
    String jndi = MessageFormat.format(pattern, arg0, arg1);
    Bitacora.trace(key + "=" + pattern);
    Bitacora.trace(key + "=" + jndi);
    try {//from   www.j av a  2  s . c  om
        Object object = InitialContext.doLookup(jndi);
        boolean assignable = object != null && local.isAssignableFrom(object.getClass());
        Bitacora.trace(arg0 + "=" + object + ", assignable=" + assignable);
        return object;
    } catch (NamingException ex) {
        return null;
    }
}

From source file:com.adeptj.runtime.common.Servlets.java

private static String resolveServletName(Class<? extends HttpServlet> cls, String name,
        Dictionary<String, Object> props) {
    String servletName = name.isEmpty() ? cls.getSimpleName() : name;
    props.put(HTTP_WHITEBOARD_SERVLET_NAME, servletName);
    return servletName;
}

From source file:io.adeptj.runtime.common.Servlets.java

private static String handleName(Class<? extends HttpServlet> cls, String name,
        Dictionary<String, Object> props) {
    String servletName = name.isEmpty() ? cls.getSimpleName() : name;
    props.put(HTTP_WHITEBOARD_SERVLET_NAME, servletName);
    return servletName;
}