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

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

Introduction

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

Prototype

public static String remove(String str, char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

Usage

From source file:com.fengduo.bee.commons.core.lang.ClassLoaderUtils.java

public static List<?> load(String classpath, ClassFilter filter) throws Exception {
    List<Object> objs = new ArrayList<Object>();
    URL resource = ClassLoaderUtils.class.getClassLoader().getResource(classpath);
    logger.debug("Search from {} ...", resource.getPath());
    List<String> classnameArray;
    if ("jar".equalsIgnoreCase(resource.getProtocol())) {
        String file = resource.getFile();
        String jarName = file.substring(file.indexOf("/"), (file.lastIndexOf("jar") + 3));
        classnameArray = getClassNamesInPackage(jarName, classpath);
    } else {// w  ww . ja va  2 s .  c  o m
        Collection<File> listFiles = FileUtils.listFiles(new File(resource.getPath()), null, false);
        String classNamePrefix = classpath.replaceAll("/", ".");
        classnameArray = new ArrayList<String>();
        for (File file : listFiles) {
            String name = file.getName();
            if (name.endsWith(".class") == false) {
                continue;
            }
            if (StringUtils.contains(name, '$')) {
                logger.warn("NOT SUPPORT INNERT CLASS" + file.getAbsolutePath());
                continue;
            }
            String classname = classNamePrefix + "." + StringUtils.remove(name, ".class");
            classnameArray.add(classname);
        }
    }

    for (String classname : classnameArray) {
        try {
            Class<?> loadClass = ClassLoaderUtils.class.getClassLoader().loadClass(classname);
            if (filter != null && !filter.filter(loadClass)) {
                logger.error("{}  {} ", classname, filter);
                continue;
            }
            // if (ClassLoaderUtil.class.isAssignableFrom(loadClass) == false) {
            // logger.error("{} ?????", classname);
            // continue;
            // }
            Object newInstance = loadClass.newInstance();
            objs.add(newInstance);
            logger.debug("load {}/{}.class success", resource.getPath(), classname);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("load " + resource.getPath() + "/" + classname + ".class failed", e);
        }
    }
    return objs;
}

From source file:com.rsmart.kuali.kfs.fp.batch.DisbursementVoucherInputFileType.java

/**
 * @see org.kuali.kfs.sys.batch.BatchInputFileType#getFileName(java.lang.String, java.lang.Object, java.lang.String)
 *///w  w w .  j av a  2  s  .  c  o m
public String getFileName(String principalId, Object parsedFileContents, String fileUserIdentifer) {
    Timestamp currentTimestamp = dateTimeService.getCurrentTimestamp();

    StringBuffer buf = new StringBuffer();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd_HHmmss");
    formatter.setLenient(false);
    formatter.format(currentTimestamp, buf, new FieldPosition(0));

    String fileName = FPConstants.DV_FILE_UPLOAD_FILE_PREFIX + principalId;
    if (StringUtils.isNotBlank(fileUserIdentifer)) {
        fileName += "_" + StringUtils.remove(fileUserIdentifer, " ");
    }
    fileName += "_" + buf.toString();

    return fileName;
}

From source file:at.pagu.soldockr.core.EmbeddedSolrServerFactory.java

/**
 * @param path Any Path expression valid for use with {@link ResourceUtils}
 * @return new instance of {@link EmbeddedSolrServer}
 * @throws ParserConfigurationException/*w w w  .j  a  v a 2  s. c  om*/
 * @throws IOException
 * @throws SAXException
 */
public final EmbeddedSolrServer createPathConfiguredSolrServer(String path)
        throws ParserConfigurationException, IOException, SAXException {
    String solrHome = System.getProperty(SOLR_HOME_SYSTEM_PROPERTY);

    if (StringUtils.isBlank(solrHome)) {
        solrHome = StringUtils.remove(ResourceUtils.getURL(path).toString(), "file:/");
    }
    return new EmbeddedSolrServer(new CoreContainer(solrHome, new File(solrHome + "/solr.xml")), null);
}

From source file:com.hmsinc.epicenter.model.permission.PasswordResetToken.java

public PasswordResetToken(EpiCenterUser user) {
    this.user = user;
    this.token = StringUtils.remove(UUID.randomUUID().toString().toUpperCase(), "-");
}

From source file:com.vmware.demo.EditController.java

@RequestMapping(value = "/edit", method = RequestMethod.POST)
public String save(HttpServletRequest request, Locale locale, Model model, Integer id, String name,
        String horizonUrl, String metaData) {
    logger.info("Edit save " + name);
    IdentityProvider idp;/*from w  w  w  .j av a 2s .  com*/
    if (0 == id) {
        idp = new IdentityProvider();
    } else {
        idp = organizationHandler.load(id);
    }

    // Cleanup input before saving
    metaData = StringUtils.remove(metaData, '\r');
    metaData = StringUtils.remove(metaData, '\n');

    try {
        // Initialize the SAML libraries by grabbing an instance of the service
        SamlService.getInstance();

        try {
            horizonUrl = SamlUtils.validate(metaData);
        } catch (Exception e) {
            if (e instanceof SSLHandshakeException) {
                model.addAttribute(ATTRIBUTE_ERROR_MSG, e.getLocalizedMessage());
            } else {
                throw e;
            }
        }
        if (null != horizonUrl) {
            idp.setMetaData(metaData);
            idp.setHorizonUrl(horizonUrl);
            organizationHandler.save(idp);
        }
    } catch (Exception e) {
        model.addAttribute(ATTRIBUTE_ERROR_MSG, e.getLocalizedMessage());
        return "edit";
    }
    model.addAttribute("identityProviders", organizationHandler.getAllIdentityProviders());
    model.addAttribute("spMetaDataUsername",
            ListController.generateMetaData(request, "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"));
    model.addAttribute("spMetaDataEmail",
            ListController.generateMetaData(request, "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"));
    return "list";
}

From source file:eu.databata.engine.util.PropagationUtils.java

public static String dos2Unix(String s) {
    return StringUtils.remove(s, '\r');
}

From source file:de.hybris.platform.acceleratorfacades.urlencoder.impl.DefaultUrlEncoderFacade.java

@Deprecated
@Override//w  w w. java2  s.c  o  m
public UrlEncoderPatternData patternForUrlEncoding(final String uri, final String contextPath,
        final boolean newSession) {
    final List<UrlEncoderData> urlEncodingAttributes = variablesForUrlEncoding();
    final UrlEncoderPatternData patternData = new UrlEncoderPatternData();
    final String[] splitUrl = StringUtils.split(uri, "/");
    int splitUrlCounter = (ArrayUtils.isNotEmpty(splitUrl)
            && (StringUtils.remove(contextPath, "/").equals(splitUrl[0]))) ? 1 : 0;
    for (final UrlEncoderData urlEncoderData : urlEncodingAttributes) {
        boolean applicationDriven = false;
        if ((splitUrlCounter) < splitUrl.length) {
            String tempValue = splitUrl[splitUrlCounter];
            if (!isValid(urlEncoderData.getAttributeName(), tempValue)) {
                tempValue = urlEncoderData.getDefaultValue();
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Encoding attributes are absent. Injecting default value :  [" + tempValue + "]");
                }
            }
            final UrlEncodingAttributeManager attributeManager = getUrlEncoderService()
                    .getUrlEncodingAttrManagerMap().get(urlEncoderData.getAttributeName());
            //Check if its driven by user and if so redirect
            if (!newSession && !StringUtils.equalsIgnoreCase(urlEncoderData.getCurrentValue(),
                    attributeManager.getCurrentValue())) {
                urlEncoderData.setCurrentValue(attributeManager.getCurrentValue());
                patternData.setRedirectRequired(true);
                applicationDriven = true;
            }
            if (!applicationDriven) {
                urlEncoderData.setCurrentValue(tempValue);
            }
            splitUrlCounter++;
        } else {
            break;
        }
    }
    patternData.setPattern(extractEncodingPattern(urlEncodingAttributes));

    return patternData;
}

From source file:com.hangum.tadpole.sql.query.TadpoleSystem_SchemaHistory.java

/**
 * save schema_history //  w  ww . j  a v a2s . c o m
 * 
 * @param user_seq
 * @param userDB
 * @param strSQL
 */
public static SchemaHistoryDAO save(int user_seq, UserDBDAO userDB, String strSQL) {
    SchemaHistoryDAO schemaDao = new SchemaHistoryDAO();

    try {
        //
        //
        //
        String strWorkSQL = strSQL.replaceAll("(\r\n|\n|\r)", ""); // ? .
        strWorkSQL = strWorkSQL.replaceAll("\\p{Space}", " "); // ?  .
        if (logger.isDebugEnabled())
            logger.debug("[start sql]\t" + strWorkSQL);

        String[] arrSQL = StringUtils.split(strWorkSQL);
        String strWorkType = arrSQL[0];

        // object type
        String strObjecType = arrSQL[1];

        // objectId
        String strObjectId = StringUtils.remove(arrSQL[2], "(");

        if (StringUtils.equalsIgnoreCase("or", strObjecType)) {
            strObjecType = arrSQL[3];
            strObjectId = StringUtils.remove(arrSQL[4], "(");
        }

        schemaDao = new SchemaHistoryDAO();
        schemaDao.setDb_seq(userDB.getSeq());
        schemaDao.setUser_seq(user_seq);

        schemaDao.setWork_type(strWorkType);
        schemaDao.setObject_type(strObjecType);
        schemaDao.setObject_id(strObjectId);

        schemaDao.setCreate_date(new Timestamp(System.currentTimeMillis()));

        SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
        SchemaHistoryDAO schemaHistoryDao = (SchemaHistoryDAO) sqlClient.insert("sqlHistoryInsert", schemaDao); //$NON-NLS-1$

        insertResourceData(schemaHistoryDao, strSQL);
    } catch (Exception e) {
        logger.error("Schema histor save error", e);
    }

    return schemaDao;
}

From source file:com.hangum.tadpole.engine.sql.parser.ddl.ParserDDL.java

/**
 * getObjectName//from   w  w w . jav  a2s.  c o m
 * 
 * @param matcher
 * @param sql
 * @return
 */
private String getObjectName(Matcher matcher, String sql) {
    int intEndIndex = matcher.end(1);
    int intContentLength = matcher.group(1).length();

    if (logger.isDebugEnabled()) {
        logger.debug("===DDL Parser======================================");
        logger.debug("SQL :" + sql);
        logger.debug("object name: " + matcher.group(1));
        logger.debug("intContentLength : " + intContentLength);
        logger.debug("intEndIndex : " + intEndIndex);
        logger.debug("start index: " + (intEndIndex - intContentLength));
        logger.debug("===DDL Parser======================================");
    }

    String objctName = StringUtils.substring(sql, (intEndIndex - intContentLength), intEndIndex);
    objctName = StringUtils.remove(objctName, "\"");
    objctName = StringUtils.remove(objctName, "'");
    objctName = StringUtils.remove(objctName, "`");

    return objctName;
}

From source file:es.emergya.comunications.MessageGenerator.java

/**
 * //from w  ww  .  j a  v a 2 s . c  om
 * @param tipo
 * @param prioridad
 * @param cuerpo
 * @param destino
 * @return
 */
@Transactional(readOnly = false, rollbackFor = Throwable.class, propagation = Propagation.REQUIRES_NEW)
public static Outbox sendMessage(Integer codigo, Integer tipo, Integer prioridad, String cuerpo, String destino)
        throws MessageGeneratingException {

    if (destino == null) {
        throw new MessageGeneratingException("Destino nulo.");
    }
    if (codigo == null) {
        throw new MessageGeneratingException("Mensaje sin codigo.");
    }
    if (tipo == null) {
        throw new MessageGeneratingException("Mensaje sin tipo.");
    }
    if (prioridad == null) {
        throw new MessageGeneratingException("Prioridad nula");
    }
    if (cuerpo == null) {
        cuerpo = "";
    }

    log.info("sendMessage(" + codigo + "," + tipo + "," + prioridad + "," + cuerpo + "," + destino + ")");

    try {
        Integer tipo_tetra = TipoMensajeConsultas.getTipoByCode(codigo).getTipoTetra();

        // Limpiamos las comillas:
        cuerpo = StringUtils.remove(cuerpo, "'");

        String datagramaTetra = getDatagrama(codigo, tipo, cuerpo);

        Outbox out = new Outbox();
        out.setMarcaTemporal(Calendar.getInstance().getTime());
        out.setDatagramaTetra(datagramaTetra);
        out.setPrioridad(prioridad);
        out.setDestino(StringUtils.leftPad(destino, LogicConstants.getInt("LONGITUD_ISSI", 8), '0'));
        out.setTipo(tipo_tetra);

        log.info("Enviamos el mensaje " + datagramaTetra + " a " + destino + " con prioridad " + prioridad);

        out = bandejaSalidaDAO.save(out);
        log.info("Enviando " + out);
        return out;
    } catch (Exception e) {
        throw new MessageGeneratingException("Error al generar mensaje", e);
    }
}