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:de.iteratec.iteraplan.businesslogic.reports.query.type.TechnicalComponentReleaseTypeQu.java

private TechnicalComponentReleaseTypeQu() {
    super(ClassUtils.getShortClassName(TechnicalComponentRelease.class), "tcr");
    addSpecialPropertyHQLString(PROPERTY_STARTDATE, new String[] { "is", "null" });
    addSpecialPropertyHQLString(PROPERTY_ENDDATE, new String[] { "is", "null" });
}

From source file:com.vangent.hieos.services.xds.bridge.activity.AbstractGetDocumentsSQActivity.java

/**
 * Method description
 *
 *
 * @return
 */
@Override
public String getName() {
    return ClassUtils.getShortClassName(getClass());
}

From source file:de.anhquan.config4j.internal.ConfigHandler.java

private Object invokeGetter(Object proxy, Method method) {
    @SuppressWarnings("unchecked")
    Class clsReturnType = method.getReturnType();

    String strReturnType = StringUtils.capitalize(ClassUtils.getShortClassName(clsReturnType));
    String configMethodName = "get" + strReturnType;

    String propName = findPropertyName(method);

    try {/*w  w  w .ja  v  a  2s  .  c  o m*/
        Method getter = Configuration.class.getMethod(configMethodName, String.class); //String.class is for propName
        return getter.invoke(configuration, propName);
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {

        return findDefaultValue(method, clsReturnType);
    }
    return null;
}

From source file:com.alibaba.otter.shared.arbitrate.impl.setl.rpc.monitor.AbstractProcessListener.java

protected synchronized void addReply(Long processId) {
    boolean isSuccessed = replyProcessIds.offer(processId);

    if (isSuccessed) {
        logger.debug("## {} add reply id [{}]", ClassUtils.getShortClassName(this.getClass()), processId);
    } else {/*  www.  j  a  va  2s  . c  om*/
        logger.warn("## {} dup reply id [{}]", ClassUtils.getShortClassName(this.getClass()), processId);
    }
}

From source file:info.magnolia.cms.util.RequestDispatchUtil.java

/**
 * Returns true if processing took place, even if it fails.
 *///from w  w w  . j a va  2  s.c  o  m
public static boolean dispatch(String targetUri, HttpServletRequest request, HttpServletResponse response) {

    if (targetUri == null) {
        return false;
    }

    if (targetUri.startsWith(REDIRECT_PREFIX)) {
        String redirectUrl = StringUtils.substringAfter(targetUri, REDIRECT_PREFIX);
        try {

            if (isInternal(redirectUrl)) {
                redirectUrl = request.getContextPath() + redirectUrl;
            }

            response.sendRedirect(response.encodeRedirectURL(redirectUrl));

        } catch (IOException e) {
            log.error("Failed to redirect to {}:{}", targetUri, e.getMessage());
        }
        return true;
    }

    if (targetUri.startsWith(PERMANENT_PREFIX)) {
        String permanentUrl = StringUtils.substringAfter(targetUri, PERMANENT_PREFIX);
        try {

            if (isInternal(permanentUrl)) {
                if (isUsingStandardPort(request)) {
                    permanentUrl = new URL(request.getScheme(), request.getServerName(),
                            request.getContextPath() + permanentUrl).toExternalForm();
                } else {
                    permanentUrl = new URL(request.getScheme(), request.getServerName(),
                            request.getServerPort(), request.getContextPath() + permanentUrl).toExternalForm();
                }
            }

            response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
            response.setHeader("Location", permanentUrl);

        } catch (MalformedURLException e) {
            log.error("Failed to create permanent url to redirect to {}:{}", targetUri, e.getMessage());
        }
        return true;
    }

    if (targetUri.startsWith(FORWARD_PREFIX)) {
        String forwardUrl = StringUtils.substringAfter(targetUri, FORWARD_PREFIX);
        try {
            request.getRequestDispatcher(forwardUrl).forward(request, response);
        } catch (Exception e) {
            log.error("Failed to forward to {} - {}:{}",
                    new Object[] { forwardUrl, ClassUtils.getShortClassName(e.getClass()), e.getMessage() });
        }
        return true;
    }

    return false;
}

From source file:com.baidu.fsg.uid.utils.NamingThreadFactory.java

/**
 * Get the method invoker's class name//ww w  .java  2 s .c om
 * 
 * @param depth
 * @return
 */
private String getInvoker(int depth) {
    Exception e = new Exception();
    StackTraceElement[] stes = e.getStackTrace();
    if (stes.length > depth) {
        return ClassUtils.getShortClassName(stes[depth].getClassName());
    }
    return getClass().getSimpleName();
}

From source file:ch.algotrader.adapter.ib.IBUtil.java

public static Contract getContract(Security security) {

    SecurityFamily securityFamily = security.getSecurityFamily();
    Validate.notNull(securityFamily.getExchange(), "securityFamily.exchange");

    Contract contract = new Contract();
    contract.m_exchange = securityFamily.getExchange().getIbCode();

    // use Conid if available
    if (security.getConid() != null) {

        contract.m_conId = Integer.parseInt(security.getConid());

    } else {/*  ww  w  .ja v  a 2s .  c  om*/

        contract.m_currency = securityFamily.getCurrency().toString();

        if (security instanceof Option) {

            Validate.notNull(securityFamily.getSymbolRoot(Broker.IB.name()), "securityFamily.baseSymbol");

            Option option = (Option) security;

            contract.m_secType = "OPT";
            contract.m_symbol = securityFamily.getSymbolRoot(Broker.IB.name());
            contract.m_primaryExch = securityFamily.getExchange().getIbCode();
            contract.m_strike = option.getStrike().doubleValue();
            contract.m_right = option.getOptionType().toString();
            contract.m_multiplier = decimalFormat.format(securityFamily.getContractSize(Broker.IB.name()));
            contract.m_expiry = dayFormat.format(DateTimeLegacy.toLocalDate(option.getExpiration()));

        } else if (security instanceof Future) {

            Validate.notNull(securityFamily.getSymbolRoot(Broker.IB.name()), "securityFamily.baseSymbol");

            Future future = (Future) security;

            contract.m_secType = "FUT";
            contract.m_symbol = securityFamily.getSymbolRoot(Broker.IB.name());
            contract.m_multiplier = decimalFormat.format(securityFamily.getContractSize(Broker.IB.name()));
            contract.m_expiry = future.getMonthYear();

        } else if (security instanceof Forex) {

            contract.m_secType = "CASH";
            contract.m_symbol = ((Forex) security).getBaseCurrency().name();

        } else if (security instanceof Stock) {

            Validate.notNull(security.getSymbol(), "securityFamily.symbol");

            contract.m_secType = "STK";
            contract.m_symbol = security.getSymbol();
            contract.m_primaryExch = securityFamily.getExchange().getIbCode();

        } else if (security instanceof Index) {

            Validate.notNull(security.getSymbol(), "securityFamily.symbol");

            contract.m_secType = "IND";
            contract.m_symbol = security.getSymbol();

        } else {

            throw new IllegalArgumentException(
                    "unsupported security type " + ClassUtils.getShortClassName(security.getClass()));
        }
    }

    return contract;
}

From source file:com.alibaba.otter.shared.arbitrate.impl.setl.rpc.monitor.AbstractProcessListener.java

/**
 * ???processIds?reply queue?processIds/*from ww w  .j  a  v  a  2 s.  c om*/
 */
protected synchronized void compareReply(List<Long> processIds) {
    Object[] replyIds = replyProcessIds.toArray();
    for (Object replyId : replyIds) {
        if (processIds.contains((Long) replyId) == false) { // reply id??processId
            // ?Listener???processprocessIdreply
            // ?processIds??process??
            if (CollectionUtils.isEmpty(processIds) == false) {
                Long processId = processIds.get(0);
                if (processId > (Long) replyId) { // ??processIdreplyId, processId
                    logger.info("## {} remove reply id [{}]", ClassUtils.getShortClassName(this.getClass()),
                            (Long) replyId);
                    replyProcessIds.remove((Long) replyId);
                }
            }
        }
    }
}

From source file:com.vangent.hieos.services.xds.bridge.activity.AddPatientIdActivity.java

/**
 * Method description
 *
 *
 * @return
 */
@Override
public String getName() {

    return ClassUtils.getShortClassName(getClass());
}

From source file:com.datatorrent.lib.multiwindow.SortedMovingWindow.java

@SuppressWarnings("unchecked")
@Override/*from w  w  w .ja va  2  s. co m*/
public void endWindow() {
    super.endWindow();
    tuplesInCurrentStreamWindow = new LinkedList<T>();
    if (lastExpiredWindowState == null) {
        // not ready to emit value or empty in a certain window
        return;
    }
    // Assumption: the expiring tuple and any tuple before are already sorted. So it's safe to emit tuples from sortedListInSlidingWin till the expiring tuple
    for (T expiredTuple : lastExpiredWindowState) {
        // Find sorted list for the given key
        PriorityQueue<T> sortedListForE = sortedListInSlidingWin.get(function.apply(expiredTuple));
        for (Iterator<T> iterator = sortedListForE.iterator(); iterator.hasNext();) {
            T minElemInSortedList = iterator.next();
            int k = 0;
            if (comparator == null) {
                if (expiredTuple instanceof Comparable) {
                    k = ((Comparable<T>) expiredTuple).compareTo(minElemInSortedList);
                } else {
                    errorOutput.emit(expiredTuple);
                    throw new IllegalArgumentException("Operator \""
                            + ClassUtils.getShortClassName(this.getClass()) + "\" encounters an invalid tuple "
                            + expiredTuple + "\nNeither the tuple is comparable Nor Comparator is specified!");
                }
            } else {
                k = comparator.compare(expiredTuple, minElemInSortedList);
            }
            if (k < 0) {
                // If the expiring tuple is less than the first element of the sorted list. No more tuples to emit
                break;
            } else {
                // Emit the element in sorted list if it's less than the expiring tuple
                outputPort.emit(minElemInSortedList);
                // remove the element from the sorted list
                iterator.remove();
            }
        }
    }
}