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

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

Introduction

In this page you can find the example usage for org.apache.commons.lang 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.

Usage

From source file:org.openvpms.web.component.im.edit.IMTableCollectionEditor.java

/**
 * Lays out the component./* ww w  .ja  v a 2s .  c o m*/
 *
 * @param context the layout context
 * @return the component
 */
protected Component doLayout(LayoutContext context) {
    container = new IMObjectCollectionComponent();
    container.setStyleName(Styles.CELL_SPACING);
    focusGroup = new FocusGroup(ClassUtils.getShortClassName(getClass()));

    table = new PagedIMTable<T>(createTableModel(context));
    table.getTable().addActionListener(new ActionListener() {
        public void onAction(ActionEvent event) {
            onEdit();
        }
    });

    doLayout(container, context);
    return container;
}

From source file:org.openvpms.web.component.im.select.Selector.java

/**
 * Constructs a {@link Selector}./* ww w  .  j a v a  2s .c o m*/
 *
 * @param buttonId the button identifier
 * @param style    determines the layout of the button(s)
 * @param editable determines if the selector is editable
 */
public Selector(String buttonId, ButtonStyle style, boolean editable) {
    this.buttonId = buttonId;
    buttonStyle = style;
    this.editable = editable;
    focusGroup = new FocusGroup(ClassUtils.getShortClassName(getClass()));
}

From source file:org.projectforge.core.BaseDao.java

@SuppressWarnings("unchecked")
private void getHistoryEntries(final Session session, final BaseSearchFilter filter, final Set<Integer> idSet,
        final Class<?> clazz, final boolean searchStringInHistory) {
    if (log.isDebugEnabled() == true) {
        log.debug("Searching in " + clazz);
    }/* w w  w  . ja va  2  s .  com*/
    // First get all history entries matching the filter and the given class.
    final String className = ClassUtils.getShortClassName(clazz);
    if (searchStringInHistory == true) {
        final StringBuffer buf = new StringBuffer();
        buf.append("(+className:").append(className);
        if (filter.getStartTimeOfModification() != null || filter.getStopTimeOfModification() != null) {
            final DateFormat df = new SimpleDateFormat(DateFormats.LUCENE_TIMESTAMP_MINUTE);
            df.setTimeZone(DateHelper.UTC);
            buf.append(" +timestamp:[");
            if (filter.getStartTimeOfModification() != null) {
                buf.append(df.format(filter.getStartTimeOfModification()));
            } else {
                buf.append("000000000000");
            }
            buf.append(" TO ");
            if (filter.getStopTimeOfModification() != null) {
                buf.append(df.format(filter.getStopTimeOfModification()));
            } else {
                buf.append("999999999999");
            }
            buf.append("]");
        }
        if (filter.getModifiedByUserId() != null) {
            buf.append(" +userName:").append(filter.getModifiedByUserId());
        }
        buf.append(") AND (");
        final String searchString = buf.toString() + modifySearchString(filter.getSearchString()) + ")";
        try {
            final FullTextSession fullTextSession = Search.getFullTextSession(getSession());
            final org.apache.lucene.search.Query query = createFullTextQuery(HISTORY_SEARCH_FIELDS, null,
                    searchString);
            if (query == null) {
                // An error occured:
                return;
            }
            final FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(query, HistoryEntry.class);
            fullTextQuery.setCacheable(true);
            fullTextQuery.setCacheRegion("historyItemCache");
            fullTextQuery.setProjection("entityId");
            final List<Object[]> result = fullTextQuery.list();
            if (result != null && result.size() > 0) {
                for (final Object[] oa : result) {
                    idSet.add((Integer) oa[0]);
                }
            }
        } catch (final Exception ex) {
            final String errorMsg = "Lucene error message: " + ex.getMessage() + " (for "
                    + this.getClass().getSimpleName() + ": " + searchString + ").";
            filter.setErrorMessage(errorMsg);
            log.info(errorMsg);
        }
    } else {
        final Criteria criteria = session.createCriteria(HistoryEntry.class);
        setCacheRegion(criteria);
        criteria.add(Restrictions.eq("className", className));
        if (filter.getStartTimeOfModification() != null && filter.getStopTimeOfModification() != null) {
            criteria.add(Restrictions.between("timestamp", filter.getStartTimeOfModification(),
                    filter.getStopTimeOfModification()));
        } else if (filter.getStartTimeOfModification() != null) {
            criteria.add(Restrictions.ge("timestamp", filter.getStartTimeOfModification()));
        } else if (filter.getStopTimeOfModification() != null) {
            criteria.add(Restrictions.le("timestamp", filter.getStopTimeOfModification()));
        }
        if (filter.getModifiedByUserId() != null) {
            criteria.add(Restrictions.eq("userName", filter.getModifiedByUserId().toString()));
        }
        criteria.setCacheable(true);
        criteria.setCacheRegion("historyItemCache");
        criteria.setProjection(Projections.property("entityId"));
        final List<Integer> idList = criteria.list();
        if (idList != null && idList.size() > 0) {
            for (final Integer id : idList) {
                idSet.add(id);
            }
        }
    }
}

From source file:org.projectforge.database.DatabaseDao.java

@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ)
public void reindex(final Class<?> clazz, final ReindexSettings settings, final StringBuffer buf) {
    if (currentReindexRun != null) {
        buf.append(" (cancelled due to another running index-job)");
        return;/*from   w  w w. ja  va  2 s .com*/
    }
    synchronized (this) {
        try {
            currentReindexRun = new Date();
            buf.append(ClassUtils.getShortClassName(clazz));
            final File file = new File(ConfigXml.getInstance().getApplicationHomeDir() + "/hibernate-search/"
                    + clazz.getName() + "/write.lock");
            if (file.exists() == true) {
                final Date lastModified = new Date(file.lastModified());
                final String message;
                if (System.currentTimeMillis() - file.lastModified() > 60000) { // Last modified date is older than 60 seconds.
                    message = "(*** write.lock with last modification '"
                            + DateTimeFormatter.instance().getFormattedDateTime(lastModified)
                            + "' exists (skip re-index). May-be your admin should delete this file (see log). ***)";
                    log.error(file.getAbsoluteFile() + " " + message);
                } else {
                    message = "(*** write.lock temporarily exists (skip re-index). ***)";
                    log.info(file.getAbsolutePath() + " " + message);
                }
                buf.append(" ").append(message);
            } else {
                reindex(clazz, settings);
            }
            buf.append(", ");
        } finally {
            currentReindexRun = null;
        }
    }
}

From source file:org.projectforge.database.xstream.XStreamSavingConverter.java

private String getClassname4History(final Class<?> cls) {
    return ClassUtils.getShortClassName(cls);
}

From source file:org.projectforge.framework.persistence.database.DatabaseDao.java

@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ)
public void reindex(final Class<?> clazz, final ReindexSettings settings, final StringBuffer buf) {
    if (currentReindexRun != null) {
        buf.append(" (cancelled due to another running index-job)");
        return;/*from w w  w .  j a v  a 2  s .c  om*/
    }
    synchronized (this) {
        try {
            currentReindexRun = new Date();
            buf.append(ClassUtils.getShortClassName(clazz));
            reindex(clazz, settings);
            buf.append(", ");
        } finally {
            currentReindexRun = null;
        }
    }
}

From source file:org.sapia.soto.freemarker.stm.FreemarkerIncludeStep.java

/**
 * @see org.sapia.soto.state.Step#getName()
 */
public String getName() {
    return ClassUtils.getShortClassName(getClass());
}

From source file:org.sapia.soto.state.code.GroovyStep.java

/**
 * @see org.sapia.soto.state.Step#getName()
 *//*w w w.  j a v a2  s  .  c  o m*/
public String getName() {
    if (_name == null) {
        return ClassUtils.getShortClassName(getClass());
    }

    return _name;
}

From source file:org.squale.squalix.util.parser.JavaParser.java

/**
 * <p>/* w  ww.j  ava  2 s.  co m*/
 * This method is used to convert method signature from bytecode back to source code e.g
 * <ul>
 * <b>from</b>
 * <li>loadProperties(Ljava/util/Properties;Ljava/util/List;Ljava/util/Properties;)</li>
 * <br />
 * <b>to</b>
 * <li>loadProperties(Properties,List,Properties)</li>
 * </ul>
 * </p>
 * <p>
 * It is particulary usefull as the aggregation of metrics in Squale could only be achieved if the comparison
 * between component is efficient.<br />
 * Please refer to the comments in the method core for more information.
 * </p>
 * @param pSignature the signature that has to be converted
 * @return a String representation of the signature in the "Squale format"
 * 
 */
public String getSignatureFromBytecode(String pSignature) {
    /*
     * Using Apache BCEL API to get an array of arguments that are not chopped as a generic method is needed. In
     * BCEL Utility only java.lang.* classes are chopped.
     */
    String[] returnedSignature = Utility.methodSignatureArgumentTypes(pSignature, false);
    String finalSignature = "";
    /* Iterating over the array or arguments */
    for (int i = 0; i < returnedSignature.length; i++) {
        /* first testing if the method is a representation of a static class method call */
        String singleArgument = chopStaticSignature(returnedSignature[i]);
        /* while the last element is not reached */
        if (i < returnedSignature.length - 1) {
            finalSignature += ClassUtils.getShortClassName(singleArgument) + ',';
        } else {
            finalSignature += ClassUtils.getShortClassName(singleArgument);
        }
    }
    return finalSignature;
}

From source file:org.squale.squalix.util.parser.JavaParser.java

/**
 * <p>//from  w w w.  java2 s.c  o  m
 * This method is used to decode constructor name in results containing bytecode so as to aggregate the metrics.
 * </p>
 * <p>
 * As constructors, at the JVM level, are regular methods that are identified by the well-known name "'<'init'>'",
 * one must check if the audited method matches the pattern <b>&lt;init&gt;</b>.
 * </p>
 * @param pJvmMethodName the name of the method in a byte-code format
 * @param pClassName the classname of the tested methos comes from
 * @return a String representation of the constructor
 */
public String getConstructorFromByte(String pJvmMethodName, String pClassName) {
    String constructorName = "";
    /* if the method extracted from the result file contains '<init>' */
    if (StringUtils.contains(pJvmMethodName, "<init>")) {
        /* replace it as it is a constructor */
        constructorName = ClassUtils.getShortClassName(pClassName);
    } else {
        /* else it is identical to the source code method name */
        constructorName = pJvmMethodName;
    }
    return constructorName;
}