Example usage for org.apache.commons.lang StringUtils substringAfter

List of usage examples for org.apache.commons.lang StringUtils substringAfter

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils substringAfter.

Prototype

public static String substringAfter(String str, String separator) 

Source Link

Document

Gets the substring after the first occurrence of a separator.

Usage

From source file:info.magnolia.module.delta.PartialBootstrapTask.java

protected String getOutputResourceName(final String resource, final String itemPath) {
    // get name as config.modules.xxx
    String inputResourceName = BootstrapUtil.getFilenameFromResource(resource, ".xml");
    //replacing all "/" with "."; getting string after first node
    String tmpitemPath = itemPath.replace("/", ".");

    tmpitemPath = StringUtils.removeStart(tmpitemPath, ".");
    tmpitemPath = StringUtils.substringAfter(tmpitemPath, ".");
    String outputResourceName = inputResourceName + "." + tmpitemPath;
    if (StringUtils.isNotEmpty(targetResource)) {
        outputResourceName = targetResource;
    }/*from  ww  w. jav  a 2 s . c  o  m*/
    return outputResourceName;
}

From source file:com.ghy.common.orm.hibernate.HibernateDao.java

/**
 * countHql./* www.  ja  va2  s .c  om*/
 * 
 * ???hql?,??hql?count?.
 */
private String prepareCountHql(String orgHql) {
    String fromHql = orgHql;
    // select??order by???count,?.
    fromHql = "from " + StringUtils.substringAfter(fromHql, "from");
    fromHql = StringUtils.substringBefore(fromHql, "order by");

    String countHql = "select count(*) " + fromHql;
    return countHql;
}

From source file:com.abssh.util.PropertyFilter.java

/**
 * @param filterName//from www .  ja v  a2s.  c o m
 *            ,???. eg. LIKES_NAME_OR_LOGIN_NAME
 * @param value
 *            .
 */
@SuppressWarnings("unchecked")
public PropertyFilter(final String filterName, final Object value, boolean flag) {

    String matchTypeStr = StringUtils.substringBefore(filterName, "_");
    String matchTypeCode = StringUtils.substring(matchTypeStr, 0, matchTypeStr.length() - 1);
    String propertyTypeCode = StringUtils.substring(matchTypeStr, matchTypeStr.length() - 1,
            matchTypeStr.length());
    try {
        matchType = Enum.valueOf(MatchType.class, matchTypeCode);
    } catch (RuntimeException e) {
        throw new IllegalArgumentException(
                "filter??" + filterName + ",.", e);
    }

    try {
        propertyType = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue();
    } catch (RuntimeException e) {
        throw new IllegalArgumentException(
                "filter??" + filterName + ",.", e);
    }

    String propertyNameStr = StringUtils.substringAfter(filterName, "_");
    propertyNames = propertyNameStr.split(PropertyFilter.OR_SEPARATOR);

    Assert.isTrue(propertyNames.length > 0,
            "filter??" + filterName + ",??.");
    // entity property.
    if (value != null && (value.getClass().isArray() || Collection.class.isInstance(value))) {
        // IN ?
        Object[] vObjects = null;
        if (value.getClass().isArray()) {
            vObjects = (Object[]) value;
        } else if (Collection.class.isInstance(value)) {
            vObjects = ((Collection) value).toArray();
        } else {
            vObjects = value.toString().split(",");
        }
        this.propertyValue = new Object[vObjects.length];
        for (int i = 0; i < vObjects.length; i++) {
            propertyValue[i] = ReflectionUtils.convertValue(vObjects[i], propertyType);
        }
    } else {
        Object tObject = ReflectionUtils.convertValue(value, propertyType);
        if (tObject != null && matchType == MatchType.LE && propertyType.getName().equals("java.util.Date")) {
            // LED ??tObject2010-08-13 00:00:00
            // ?2010-08-13 23:59:59
            Date leDate = (Date) tObject;
            Calendar c = GregorianCalendar.getInstance();
            c.setTime(leDate);
            c.set(Calendar.HOUR_OF_DAY, 23);
            c.set(Calendar.MINUTE, 59);
            c.set(Calendar.SECOND, 59);
            tObject = c.getTime();
        } else if (tObject != null && matchType == MatchType.LEN
                && propertyType.getName().equals("java.util.Date")) {
        } else if (tObject != null && matchType == MatchType.LIKE) {
            tObject = ((String) tObject).replace("%", "\\%").replace("_", "\\_");
        }
        this.propertyValue = new Object[] { tObject };
    }
}

From source file:com.hangum.tadpole.engine.sql.util.OracleObjectCompileUtils.java

/**
 * package compile/* w w w .j  a v a  2 s. c  o m*/
 * 
 * @param objectName
 * @param userDB
 */
public static String packageCompile(String strObjectName, UserDBDAO userDB) throws Exception {
    //TODO: RequestQuery?   ? ?.  
    ProcedureFunctionDAO packageDao = new ProcedureFunctionDAO();
    if (StringUtils.contains(strObjectName, '.')) {
        //??   ?? ...
        packageDao.setSchema_name(StringUtils.substringBefore(strObjectName, "."));
        packageDao.setPackagename(StringUtils.substringAfter(strObjectName, "."));
        packageDao.setName(StringUtils.substringAfter(strObjectName, "."));
    } else {
        //    ?    .
        packageDao.setSchema_name(userDB.getSchema());
        packageDao.setPackagename(strObjectName);
        packageDao.setName(strObjectName);
    }

    return packageCompile(packageDao, userDB, userDB.getDBDefine() == DBDefine.ORACLE_DEFAULT);
}

From source file:com.googlecode.jtiger.modules.ecside.util.ExtremeUtils.java

/**
 * Go through the request parameters and figure out which checkboxes are
 * selected./* w w w  .  j  a  va  2 s  . co  m*/
 * 
 * @param startsWithValue
 *            A way to identify all the checkboxes. For example ckbox_.
 */
public static List checkboxesSelected(HttpServletRequest request, String startsWithValue) {
    List results = new ArrayList();

    Enumeration parameterNames = request.getParameterNames();
    while (parameterNames.hasMoreElements()) {
        String parameterName = (String) parameterNames.nextElement();
        if (parameterName.startsWith(startsWithValue)) {
            results.add(StringUtils.substringAfter(parameterName, startsWithValue));
        }
    }

    return results;
}

From source file:info.magnolia.jcr.util.PropertiesImportExport.java

protected Object convertPropertyStringToObject(String valueStr) {
    if (contains(valueStr, ':')) {
        final String type = StringUtils.substringBefore(valueStr, ":");
        final String value = StringUtils.substringAfter(valueStr, ":");

        // there is no beanUtils converter for Calendar
        if (type.equalsIgnoreCase("date")) {
            return ISO8601.parse(value);
        } else if (type.equalsIgnoreCase("binary")) {
            return new ByteArrayInputStream(value.getBytes());
        } else {//from   ww w  .  j  a  v a2 s .co  m
            try {
                final Class<?> typeCl;
                if (type.equals("int")) {
                    typeCl = Integer.class;
                } else {
                    typeCl = Class.forName("java.lang." + StringUtils.capitalize(type));
                }
                return ConvertUtils.convert(value, typeCl);
            } catch (ClassNotFoundException e) {
                // possibly a stray :, let's ignore it for now
                return valueStr;
            }
        }
    }
    // no type specified, we assume it's a string, no conversion
    return valueStr;
}

From source file:jp.ac.tokushima_u.is.ll.common.orm.hibernate.HibernateDao.java

/**
 * count???HQL???????/*  w  w  w.j  ava  2s.  c o m*/
 *
 *?????HQL????????HQL??count???????
 */
protected long countHqlResult(final String hql, final Object... values) {
    String fromHql = hql;
    //select?order by?count????,???
    fromHql = "from " + StringUtils.substringAfter(fromHql, "from");
    fromHql = StringUtils.substringBefore(fromHql, "order by");

    String countHql = "select count(*) " + fromHql;

    try {
        Long count = findUnique(countHql, values);
        return count;
    } catch (Exception e) {
        throw new RuntimeException("hql can't be auto count, hql is:" + countHql, e);
    }
}

From source file:managedBeans.facturacion.ListadoFacturaMB.java

public void buscarFactura() {
    if (sedeActual == null) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
                "Error", "No se ha encontrado informacion de la sede"));
        return;//ww  w.j  av  a  2  s  . c o m
    }
    if (tipoFactura == 0) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
                "Error", "No se ha Seleccionado el tipo de factura"));
        return;
    }
    if (!factura.trim().isEmpty()) {
        try {
            numFactura = Integer.parseInt(factura);
        } catch (Exception e) {
            if (factura.contains("0")) {
                String numfact = StringUtils.substringAfter(factura, "0");
                try {
                    numFactura = Integer.parseInt(numfact);
                } catch (Exception ex) {
                    numFactura = 0;
                }
                //                    }
            } else {
                numFactura = 0;
            }
            if (numFactura == 0) {
                CfgDocumento documento;
                if (tipoFactura == 1) {
                    documento = documentoFacade.buscarDocumentoDeFacturaBySede(sedeActual);
                } else {
                    documento = documentoFacade.buscarDocumentoDeRemisionEspecialBySede(sedeActual);
                }
                String aux = documento.getPrefijoDoc();
                int init = aux.length();
                if (init < factura.length()) {
                    aux = factura.substring(init);
                    try {
                        numFactura = Integer.parseInt(aux);
                    } catch (Exception ex) {
                        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(
                                FacesMessage.SEVERITY_WARN, "Informacion", "Factura incorrecta"));
                        return;
                    }
                } else {
                    FacesContext.getCurrentInstance().addMessage(null,
                            new FacesMessage(FacesMessage.SEVERITY_WARN, "Informacion", "Factura incorrecta"));
                    return;
                }
            }
        }
    } else {
        numFactura = 0;
    }
    if (clienteSeleccionado != null || numFactura != 0 || fechaIncial != null || fechaFinal != null) {
        cargarFechasCalendar();
        if (tipoFactura == 1) {//muestra las facturas normales
            listadoFacturas = new LazyFacturaDataModel(documentosmasterFacade, sedeActual, clienteSeleccionado,
                    fechaIni, fechaFin, numFactura);
        } else {
            listadoFacturas = new LazyFacturaEspecialDataModel(documentosmasterFacade, sedeActual,
                    clienteSeleccionado, fechaIni, fechaFin, numFactura);
        }
        renderTablaFactura = true;
    } else {
        listadoFacturas = null;
        renderTablaFactura = false;
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN,
                "Informacion", "Ingresar al menos un parametro de busqueda"));
    }
    RequestContext.getCurrentInstance().update("IdFormListadoFacturas");
}

From source file:com.timtripcony.AbstractSmartDocumentModel.java

/**
 * Gets a field or multi-value field as a String, using toString() method
 * /*w  w  w.j av a 2  s  . co m*/
 * @param name
 *            String Item name to get value from
 * @return String value of the Item
 */
public String getValueAsString(final String name) {
    String retVal_ = "";
    try {
        if (null != getValue(name)) {
            if (Vector.class.equals(getValue(name).getClass())) {
                String value = getValue(name).toString();
                value = StringUtils.substringAfter(value, "[");
                retVal_ = StringUtils.substringBeforeLast(value, "]");
            } else {
                retVal_ = getValue(name).toString();
            }
        }
    } catch (Throwable t) {
        AppUtils.handleException(t);
    }
    return retVal_;
}

From source file:com.glluch.profilesparser.ProfileHtmlReader.java

private ArrayList<ECFMap> getLevel(String allTxt, String posterior, String f) {
    //throws java.lang.ArrayIndexOutOfBoundsException
    ArrayList<ECFMap> res = new ArrayList<>();
    String chunk;/*from   ww w . j a va 2s .  co  m*/
    if (f != null) {
        chunk = StringUtils.substringBetween(allTxt, posterior, f).trim();
    } else {
        chunk = StringUtils.substringAfter(allTxt, posterior).trim();
    }
    String prelevels = StringUtils.substringAfter(chunk, "Proficiency Levels");
    String[] levels = StringUtils.splitByWholeSeparator(prelevels, "Proficiency Level");
    //System.out.println("levels:\n"+levels.toString());
    int i = 0;
    while (i < levels.length) {
        if (levels[i].length() > 1) {
            String c3 = levels[i].substring(1, 2);
            HashMap<Integer, String> c0;
            c0 = parseCompName(posterior);

            String c1 = c0.get(0);
            String c2 = c0.get(1);
            //System.out.println(c1+" "+c2+", level "+c3);
            ECFMap em = new ECFMap(c1, c2, c3);
            res.add(em);
            //System.out.println(levels[i] + "\n-->" + levels[i].substring(1, 2));
        }
        i++;
    }
    return res;
}