Example usage for org.apache.commons.lang3 ClassUtils getShortClassName

List of usage examples for org.apache.commons.lang3 ClassUtils getShortClassName

Introduction

In this page you can find the example usage for org.apache.commons.lang3 ClassUtils getShortClassName.

Prototype

public static String getShortClassName(String className) 

Source Link

Document

Gets the class name minus the package name from a String.

The string passed in is assumed to be a class name - it is not checked.

Note that this method differs from Class.getSimpleName() in that this will return "Map.Entry" whilst the java.lang.Class variant will simply return "Entry" .

Usage

From source file:com.autentia.tnt.faces.components.query.model.EntityCriteria.java

/**
 * Crea una nueva instancia de esta clase.
 * /*from  w ww .  j  a v a 2s .  co  m*/
 * @param entityClass la clase sobre el que aplica este criterio.
 * @param matchMode el {@link MatchMode} para los criterios.
 */
public EntityCriteria(Class<?> entityClass, MatchMode matchMode) {
    this(ClassUtils.getShortClassName(entityClass), entityClass, matchMode);
}

From source file:com.datatorrent.lib.io.WebSocketInputOperator.java

@Override
public void run() {
    try {/*from ww w .  ja  v  a 2  s .  co m*/
        connectionClosed = false;
        AsyncHttpClientConfigBean config = new AsyncHttpClientConfigBean();
        config.setIoThreadMultiplier(ioThreadMultiplier);
        config.setApplicationThreadPool(Executors.newCachedThreadPool(new ThreadFactory() {
            private long count = 0;

            @Override
            public Thread newThread(Runnable r) {
                Thread t = new Thread(r);
                t.setName(ClassUtils.getShortClassName(this.getClass()) + "-AsyncHttpClient-" + count++);
                return t;
            }

        }));

        if (client != null) {
            client.closeAsynchronously();
        }

        client = new AsyncHttpClient(config);
        connection = client.prepareGet(uri.toString()).execute(
                new WebSocketUpgradeHandler.Builder().addWebSocketListener(new WebSocketTextListener() {
                    @Override
                    public void onMessage(String string) {
                        LOG.debug("Got: " + string);
                        try {
                            T o = convertMessage(string);
                            if (!(skipNull && o == null)) {
                                outputPort.emit(o);
                            }
                        } catch (IOException ex) {
                            LOG.error("Got exception: ", ex);
                        }
                    }

                    @Override
                    public void onOpen(WebSocket ws) {
                        LOG.debug("Connection opened");
                    }

                    @Override
                    public void onClose(WebSocket ws) {
                        LOG.debug("Connection connectionClosed.");
                        connectionClosed = true;
                    }

                    @Override
                    public void onError(Throwable t) {
                        LOG.error("Caught exception", t);
                    }

                }).build()).get(5, TimeUnit.SECONDS);
    } catch (Exception ex) {
        LOG.error("Error reading from " + uri, ex);
        if (client != null) {
            client.close();
        }
        connectionClosed = true;
    }

}

From source file:com.datatorrent.lib.io.WebSocketOutputOperator.java

private void openConnection() throws IOException, ExecutionException, InterruptedException, TimeoutException {
    final AsyncHttpClientConfigBean config = new AsyncHttpClientConfigBean();
    config.setIoThreadMultiplier(ioThreadMultiplier);
    config.setApplicationThreadPool(Executors.newCachedThreadPool(new ThreadFactory() {
        @Override//from  w  ww . j av a 2 s.com
        public Thread newThread(Runnable r) {
            Thread t = new Thread(r);
            t.setName(ClassUtils.getShortClassName(this.getClass()) + "-AsyncHttpClient-" + count++);
            return t;
        }

    }));
    client = new AsyncHttpClient(config);
    uri = URI.create(uri.toString()); // force reparse after deserialization
    LOG.info("Opening URL: {}", uri);
    connection = client.prepareGet(uri.toString())
            .execute(new WebSocketUpgradeHandler.Builder().addWebSocketListener(new WebSocketTextListener() {
                @Override
                public void onMessage(String string) {
                }

                @Override
                public void onOpen(WebSocket ws) {
                    LOG.debug("Connection opened");
                }

                @Override
                public void onClose(WebSocket ws) {
                    LOG.debug("Connection closed.");
                }

                @Override
                public void onError(Throwable t) {
                    LOG.error("Caught exception", t);
                }

            }).build()).get(5, TimeUnit.SECONDS);
}

From source file:com.xylocore.copybook.generator.emit.CopybookClassEmitter.java

/**
 * FILLIN/*ww w  . j a  v a2  s. c  om*/
 * 
 * @exception   IOException
 */
private void generateSourceFileHeader() throws IOException {
    Metadata myMetadata = environment.getMetadata();
    String myPackageName = ClassUtils.getPackageName(myMetadata.getClassName());
    String myClassName = ClassUtils.getShortClassName(myMetadata.getClassName());

    emitter.clear().line("package ", myPackageName, ";").line();

    for (String myImportedClassName : importedClasses) {
        emitter.line("import ", myImportedClassName, ";");
    }

    emitter.line().line().line("public class ", myClassName).line1("extends")
            .line2(AbstractCopybook.class.getName()).line("{").write(writer).increment();
}

From source file:edu.umich.flowfence.common.QMDescriptor.java

public String printCall(Object[] args) {
    String format = getNameFormat();
    String argString = ArrayUtils.toString(args, "{}");
    return String.format(format, ClassUtils.getShortClassName(definingClass.getClassName()), methodName,
            // strip off {}
            argString.substring(1, argString.length() - 1));
}

From source file:jp.terasoluna.fw.util.StringUtil.java

/**
 * ???????????//from w  w w.j  a  va  2  s.c o m
 *
 * @param longClassName ??
 * @return ??
 */
public static String toShortClassName(String longClassName) {
    return ClassUtils.getShortClassName(longClassName);
}

From source file:candr.yoclip.DefaultParserHelpFactory.java

/**
 * Creates a usage description from the parser parameter.
 *
 * @param prefix       The parser parameter prefix (see {@link ParserOptions#getPrefix() getPrefix()} for more
 *                     information)./*from   w  ww  . j  a  v  a  2s .  c  o m*/
 * @param separator    The parser parameter name and value separator (see {@link ParserOptions#getSeparator()
 *                     getSeparator()} for more information}.
 * @param parserOption The parser parameter a usage will be generated for.
 * @return a usage string for the parser parameter.
 * @throws IllegalArgumentException if the {@code prefix} or {@code separator} parameter values are empty.
 * @throws NullPointerException     if the parser parameter is null.
 */
protected String createParserParameterUsage(final String prefix, final String separator,
        final ParserOption<T> parserOption) {
    if (StringUtils.isEmpty(prefix)) {
        throw new IllegalArgumentException("The ParserOption prefix cannot be empty.");
    }
    if (StringUtils.isEmpty(separator)) {
        throw new IllegalArgumentException("The ParserOption separator cannot be empty.");
    }

    final StrBuilder usage = new StrBuilder();

    if (parserOption.isProperties()) {
        final String name = parserOption.getNames()[0];
        usage.append(prefix).append(name).append("KEY=VALUE");

    } else if (parserOption.isArguments()) {
        usage.append("ARG");

    } else {
        final String[] names = parserOption.getNames();
        for (int i = 0; i < names.length; i++) {
            if (i > 0) {
                usage.append("|");
            }
            usage.append(prefix).append(names[i]);
        }
        if (parserOption.hasValue()) {
            usage.append(separator);
            final String typeDescription = ClassUtils.getShortClassName(parserOption.getType());
            usage.append(typeDescription.toUpperCase());
        }
    }

    return usage.toString();
}

From source file:com.gargoylesoftware.htmlunit.WebRequest.java

/**
 * Returns a string representation of this object.
 * @return a string representation of this object
 *///from www  .  j ava2 s  .co  m
@Override
public String toString() {
    final StringBuilder buffer = new StringBuilder();
    buffer.append(ClassUtils.getShortClassName(getClass()));
    buffer.append("[<");
    buffer.append("url=\"" + url_ + '"');
    buffer.append(", " + httpMethod_);
    buffer.append(", " + encodingType_);
    buffer.append(", " + requestParameters_);
    buffer.append(", " + additionalHeaders_);
    buffer.append(", " + credentials_);
    buffer.append(">]");
    return buffer.toString();
}

From source file:com.genologics.ri.userdefined.UDF.java

/**
 * Create a message for the MissingUDFException when {@code failMessage} is not set.
 *
 * @param thing The object the UDF is set on.
 * @param name The name of the UDF./*w w w . j  av  a2s .co m*/
 * @param failMessage The fail message supplied by the caller.
 *
 * @return A suitable failure message for the exception.
 */
private static String getMissingUDFMessage(Object thing, String name, String failMessage) {
    if (failMessage == null) {
        if (thing == null) {
            failMessage = "UDF \"" + name + "\" does not exist because 'thing' is null.";
        } else {
            String better = "UDF \"{0}\" does not exist on {1} {2}";
            if (thing instanceof LimsEntityLinkable<?>) {
                LimsEntityLinkable<?> linkable = (LimsEntityLinkable<?>) thing;
                failMessage = MessageFormat.format(better, name, ClassUtils.getShortClassName(thing.getClass()),
                        linkable.getLimsid());
            } else if (thing instanceof Locatable) {
                Locatable locatable = (Locatable) thing;
                failMessage = MessageFormat.format(better, name, ClassUtils.getShortClassName(thing.getClass()),
                        locatable.getUri());
            } else {
                failMessage = MessageFormat.format(better, name, ClassUtils.getShortClassName(thing.getClass()),
                        Integer.toHexString(System.identityHashCode(thing)));
            }
        }
    }
    return failMessage;
}

From source file:com.xylocore.copybook.generator.emit.CopybookClassEmitter.java

/**
 * FILLIN//from   w  ww.  j av  a  2s.c o  m
 * 
 * @exception   IOException
 */
private void generateElementsSource() throws IOException {
    String myClassName = ClassUtils.getShortClassName(environment.getMetadata().getClassName());

    emitter.clear().line("//").line("// Members").line("//").line().line()
            .line("private static final ", myClassName, " instance = new ", myClassName, "();").line().line()
            .line().line().line("//").line("// Class implementation").line("//").line().line()
            .line("public static ", myClassName, " getInstance()").line("{").line1("return instance;").line("}")
            .line().line().write(writer);

    generateRecordLengthMethods();

    for (Iterator<Element> myElementIterator = elementsOfInterest.iterator(); myElementIterator.hasNext();) {
        generateElementSource((DataElement) myElementIterator.next(), !myElementIterator.hasNext());
    }
}