List of usage examples for java.text Normalizer normalize
public static String normalize(CharSequence src, Form form)
From source file:org.sonar.fortify.rule.element.FortifyRule.java
private static String slugify(String s) { return Normalizer.normalize(s, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "") .replaceAll("[^\\w+]", "-").replaceAll("\\s+", "-").replaceAll("_", "-").replaceAll("[-]+", "-") .replaceAll("^-", "").replaceAll("-$", "").toLowerCase(Locale.ENGLISH); }
From source file:es.juntadeandalucia.panelGestion.negocio.utiles.Utils.java
public static String removeSpecialChars(String strColumn) { String strNoSpecialChars = strColumn; if (strNoSpecialChars != null) { strNoSpecialChars = strNoSpecialChars.toLowerCase(); // removes white spaces strNoSpecialChars = strNoSpecialChars.replaceAll("\\s", "_"); // removes accents strNoSpecialChars = Normalizer.normalize(strNoSpecialChars, Normalizer.Form.NFD); strNoSpecialChars = Pattern.compile("\\p{InCombiningDiacriticalMarks}+").matcher(strNoSpecialChars) .replaceAll(""); }//from ww w .j ava 2 s . c o m return strNoSpecialChars; }
From source file:com.matthewcasperson.validation.ruleimpl.FailIfContainsHTMLValidationRule.java
/** * {@inheritDoc}/*from w ww. j a v a2s . c o m*/ */ @Override public String[] fixParams(final String name, final String url, final String[] params) throws ValidationFailedException { checkNotNull(name); checkArgument(!name.trim().isEmpty()); checkNotNull(url); checkArgument(!url.trim().isEmpty()); checkNotNull(params); checkArgument(params.length != 0, "PVF-BUG-0003: params should always have at least one value"); for (int paramIndex = 0, paramLength = params.length; paramIndex < paramLength; ++paramIndex) { String param = params[paramIndex]; if (allowAmpersands) { param = param.replaceAll("&", ""); } if (allowAccents) { param = Normalizer.normalize(param, Normalizer.Form.NFD); } if (allowEllipsis) { param = param.replaceAll(ELLIPSIS, ""); } if (param != null) { final String encoded = StringEscapeUtils.escapeHtml4(param); if (!encoded.equals(param)) { throw new ValidationFailedException( "PVF-SECURITY-0001: Parameter found to have special HTML characters.\nNAME: " + name + "\nVALUE: " + param + "\nURL: " + url); } } } return params; }
From source file:com.silverpeas.tags.navigation.links.LinkGeneratorImpl.java
/** * Suppresion des accents d'une chaine de caractres. * @param s/*from ww w . j a v a 2 s . co m*/ * @return */ private String stripAccents(String s) { s = Normalizer.normalize(s, Normalizer.Form.NFD); s = s.replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); return s; }
From source file:cn.org.once.cstack.model.Snapshot.java
public void setFullTag(String fullTag) { if (fullTag != null) { fullTag = fullTag.toLowerCase(); fullTag = Normalizer.normalize(fullTag, Normalizer.Form.NFD); fullTag = fullTag.replaceAll("[\\p{InCombiningDiacriticalMarks}]", ""); fullTag = fullTag.replaceAll("[^a-z0-9-]", ""); }// w w w .jav a2 s . c o m this.fullTag = fullTag; }
From source file:org.youtestit.core.controllers.createProject.AbstractCreateDocument.java
/** * Allow to generate path.//from w w w. j av a 2s. co m * * @return path String representation */ protected String generatePath(final String title) { final StrBuilder result = new StrBuilder(); result.append(parentPath); if (!parentPath.endsWith(PATH_SPLIT)) { result.append(PATH_SPLIT); } final StrBuilder projectPath = new StrBuilder(); projectPath.append(Normalizer.normalize(title, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "")); projectPath.replaceAll(" ", "_"); for (String item : TO_REPLACE) { projectPath.replaceAll(item, "-"); } result.append(projectPath.toString()); return result.toString().trim(); }
From source file:org.uiautomation.ios.server.application.LanguageDictionary.java
public boolean match(String content, String originalText) { String normalizedContent = Normalizer.normalize(content, norme); String normalizedOriginalText = Normalizer.normalize(originalText, norme); String pattern = getRegexPattern(normalizedOriginalText); try {/*from www.j a v a 2 s . co m*/ boolean regex = normalizedContent.matches(pattern); return regex; } catch (PatternSyntaxException e) { // TODO freynaud debug that } return false; }
From source file:de.unidue.inf.is.ezdl.dlcore.utils.StringUtils.java
public static String normalize(String s) { String result = Normalizer.normalize(s, java.text.Normalizer.Form.NFD); return result.replaceAll("", "ss").replaceAll("[^\\p{ASCII}]", ""); }
From source file:com.sp.Parser.Utils.java
public static String Strip(String Input) { // Input = Input.replaceAll("(\\b|_)(a|o)u+x?\\b", ""); // Input = Input.replaceAll("(\\b|_)l(e|a|es)\\b", ""); // Input = Input.replaceAll("(\\b|_)(m|t|s)(on|a|es)\\b", ""); // Input = Input.replaceAll("(\\b|_)une?\\b", ""); // Input = Input.replaceAll("(\\b|_)es?t\\b", ""); // Input = Input.replaceAll("(\\b|_)ce(lle)?s?\\b", ""); // Input = Input.replaceAll("(\\b|_)d(es?|u)\\b", ""); // Input = Input.replaceAll("(\\b|_)d(es?|u)\\b", ""); Input = StringUtils.replaceEachRepeatedly(Input.toLowerCase(), InputReplace, OutputReplace); Input = StringEscapeUtils.escapeSql(Input); Input = Normalizer.normalize(Input.toLowerCase(), Normalizer.Form.NFD); return (Input.replaceAll(" *", " ")).trim(); //return Input; }
From source file:org.kuali.ole.utility.CompressUtils.java
/** * Method to extract a given zipped bag file to a given output directory or to a temp directory if toDir is null. * * @param bagFilePath//from w w w. j a v a 2 s. c o m * @param toDir * @return * @throws IOException */ public File extractZippedBagFile(String bagFilePath, String toDir) throws IOException { File bagFile = new File(bagFilePath); File extractDir = null; if (toDir != null && toDir.trim().length() != 0) extractDir = new File(toDir); else extractDir = File.createTempFile("tmp", ".ext"); FileUtils.deleteQuietly(extractDir); extractDir.mkdirs(); byte[] buffer = new byte[BUFFER_SIZE]; ZipInputStream zip = new ZipInputStream(new BufferedInputStream(new FileInputStream(bagFile))); ZipEntry next; while ((next = zip.getNextEntry()) != null) { String name = next.getName().replace('\\', '/').replaceFirst("[^/]*/", ""); if (name.startsWith(DATA_DIR)) { File localFile = new File(extractDir, Normalizer.normalize(name.substring(DATA_DIR.length()), FILENAME_NORMALIZATION_FORM)); if (next.isDirectory()) { if (!localFile.exists() && !localFile.mkdir()) throw new IOException("error creating local directories in output directory"); } else { File parent = localFile.getParentFile(); if (!parent.exists() && !parent.mkdirs()) throw new IOException("error creating local directories in output directory"); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(localFile)); int bytesRead; while ((bytesRead = zip.read(buffer, 0, BUFFER_SIZE)) != -1) { bos.write(buffer, 0, bytesRead); } bos.close(); } } else { File localFile = new File(extractDir, name); if (next.isDirectory()) { if (!localFile.exists() && !localFile.mkdir()) throw new IOException("error creating local directories in output directory"); } else { File parent = localFile.getParentFile(); if (!parent.exists() && !parent.mkdirs()) throw new IOException("error creating local directories in output directory"); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(localFile)); int bytesRead; while ((bytesRead = zip.read(buffer, 0, BUFFER_SIZE)) != -1) { bos.write(buffer, 0, bytesRead); } bos.close(); } } } zip.close(); return extractDir; }