List of usage examples for java.util.regex Pattern quote
public static String quote(String s)
From source file:net.oauth.jsontoken.crypto.MagicRsaPublicKey.java
private static PublicKey parseKey(String magicKey) { String[] pieces = magicKey.split(Pattern.quote(".")); if (pieces.length != 3) { throw new IllegalStateException("not a valid magic key: " + magicKey); }//from w w w .ja v a2 s .c om if (!pieces[0].equals("RSA")) { throw new IllegalStateException("unkown key type for magic key: " + pieces[0]); } String modulusString = pieces[1]; String exponentString = pieces[2]; byte[] modulusBytes = Base64.decodeBase64(modulusString); byte[] exponentBytes = Base64.decodeBase64(exponentString); BigInteger modulus = new BigInteger(modulusBytes); BigInteger exponent = new BigInteger(exponentBytes); RSAPublicKeySpec spec = new RSAPublicKeySpec(modulus, exponent); KeyFactory fac; try { fac = KeyFactory.getInstance("RSA"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("RSA key factory missing on platform", e); } try { return fac.generatePublic(spec); } catch (InvalidKeySpecException e) { throw new IllegalStateException("bad key in descripor doc: " + magicKey, e); } }
From source file:com.skcraft.launcher.creator.model.creator.ModFile.java
@JsonIgnore public String getCleanVersion() { String version = getVersion(); return version != null ? version.replaceAll("^" + Pattern.quote(gameVersion) + "\\-", "") .replaceAll("\\-" + Pattern.quote(gameVersion) + "$", "") : null; }
From source file:com.predic8.membrane.core.interceptor.registration.SecurityUtils.java
public static String extractSalt(String password) { return password.split(Pattern.quote("$"))[2]; }
From source file:classpackage.ChartGalaxy.java
public static XYDataset createDataset() { LabeledXYDataset series = new LabeledXYDataset(); List<String> vetorLinha = new ArrayList<>(); List<List> lista = new ArrayList<>(); try {/*from w w w .ja va2s .co m*/ FileReader arq = new FileReader("Arquivo.txt"); BufferedReader lerArq = new BufferedReader(arq); String linha = lerArq.readLine(); while (linha != null) { String caracteres = " #@_\\/*|"; String parts[] = linha.split("[" + Pattern.quote(caracteres) + "]"); for (String i : parts) { vetorLinha.add(i); } lista.add(vetorLinha); vetorLinha = new ArrayList<>(); linha = lerArq.readLine(); } for (int i = 0; i < lista.size(); i++) { // for (int j = 0; j < vetorLinha.size(); j++) { double a = Double.parseDouble(lista.get(i).get(0).toString()); double b = Double.parseDouble(lista.get(i).get(1).toString()); String label = lista.get(i).get(2).toString(); //System.out.println(lista.get(i).get(j)); //} series.add(a, b, label); } } catch (IOException e) { System.out.println(e.getMessage()); } return series; }
From source file:com.hd.stringcalculator.StringCalculator.java
public int add(String numbers) throws NegativeNumberException { if (numbers == null) { throw new NullPointerException(); } else if (numbers.isEmpty()) { return 0; }//ww w.jav a 2s . co m if (!numbers.matches( "-?[0-9]+((" + Pattern.quote(separator) + ")-?[0-9]+)*(" + Pattern.quote(separator) + ")?")) { throw new IllegalArgumentException("Bad character(s) in input string: " + numbers); } List<String> numbersList = Arrays .asList(numbers.split("(?<!" + Pattern.quote(separator) + ")" + Pattern.quote(separator))); List<String> negativeNumbers = new StringListFilter("[-][0-9]+").filter(numbersList); if (negativeNumbers.size() > 0) { throw new NegativeNumberException(StringUtils.join(negativeNumbers.iterator(), ", ")); } int sum = 0; for (String stringNumber : numbersList) { sum += Integer.valueOf(stringNumber); } return sum; }
From source file:dhz.skz.citaci.weblogger.WlFileFilter.java
public WlFileFilter(String nazivPostaje, Date zadnji, TimeZone timeZone) { this.zadnji = zadnji; this.nazivPostaje = Pattern.quote(nazivPostaje.toLowerCase()); this.timeZone = timeZone; formatter.setTimeZone(timeZone);//w w w .j a v a2 s. com }
From source file:dhz.skz.citaci.weblogger.zerospan.WlZeroSpanFileFilter.java
WlZeroSpanFileFilter(String nazivPostaje, Date zadnji, TimeZone timeZone) { this.zadnji = zadnji; this.nazivPostaje = Pattern.quote(nazivPostaje.toLowerCase()); this.timeZone = timeZone; formatter.setTimeZone(timeZone);//from w w w. j a v a2s .c o m }
From source file:dk.deck.resolver.AbstractArtifactResolver.java
protected String getArtifactItemPath(Artifact artifact) { String artifactPath = artifact.getGroupId().replaceAll(Pattern.quote("."), Matcher.quoteReplacement("/")) + "/" + artifact.getArtifactId(); String artifactVersionPath = artifactPath + "/" + artifact.getVersion(); String artifactFilename = artifact.getFileName(); String artifactItemPath = artifactVersionPath + "/" + artifactFilename; return artifactItemPath; }
From source file:com.google.android.vending.licensing.ResponseData.java
/** * Parses response string into ResponseData. * * @param responseData response data string * @throws IllegalArgumentException upon parsing error * @return ResponseData object//from w w w . j av a 2s . c om */ public static ResponseData parse(String responseData) { // Must parse out main response data and response-specific data. int index = responseData.indexOf(':'); String mainData, extraData; if (-1 == index) { mainData = responseData; extraData = ""; } else { mainData = responseData.substring(0, index); extraData = index >= responseData.length() ? "" : responseData.substring(index + 1); } String[] fields = TextUtils.split(mainData, Pattern.quote("|")); if (fields.length < 6) { throw new IllegalArgumentException("Wrong number of fields."); } ResponseData data = new ResponseData(); data.responseCode = Integer.parseInt(fields[0]); data.nonce = Integer.parseInt(fields[1]); data.packageName = fields[2]; data.versionCode = fields[3]; // Application-specific user identifier. data.userId = fields[4]; data.timestamp = Long.parseLong(fields[5]); data.extras = decodeExtras(extraData); return data; }
From source file:mitm.common.util.RegExprUtils.java
/** * Escapes all regular expression special chars from the input. *///w ww .j a v a 2s . c o m public static String escape(String input) { return Pattern.quote(input); }