List of usage examples for java.util.regex Pattern quote
public static String quote(String s)
From source file:gobblin.util.recordcount.IngestionRecordCountProvider.java
/** * The record count should be the last component before the filename extension. *///w w w . j a v a 2 s. c o m @Override public long getRecordCount(Path filepath) { String[] components = filepath.getName().split(Pattern.quote(SEPARATOR)); Preconditions.checkArgument( components.length >= 2 && StringUtils.isNumeric(components[components.length - 2]), String.format("Filename %s does not follow the pattern: FILENAME.RECORDCOUNT.EXTENSION", filepath)); return Long.parseLong(components[components.length - 2]); }
From source file:com.dell.asm.asmcore.asmmanager.util.deployment.HostnameUtil.java
public static boolean isValidHostNameTemplate(String hostName, ServiceTemplateComponent component) { // must not be empty and must contain a pattern that can result in a unique name if (StringUtils.isBlank(hostName) || !(hostName.contains(NUM_PATTERN) || hostName.contains(TAG_PATTERN) || hostName.contains(DNS_PATTERN))) { return false; }/*from w w w . j a v a2 s . c o m*/ // replace known patterns hostName = hostName.replaceAll(Pattern.quote(NUM_PATTERN), "1"); hostName = hostName.replaceAll(Pattern.quote(TAG_PATTERN), "123"); hostName = hostName.replaceAll(Pattern.quote(MODEL_PATTERN), "620"); hostName = hostName.replaceAll(Pattern.quote(VENDOR_PATTERN), "Dell"); hostName = hostName.replaceAll(Pattern.quote(DNS_PATTERN), "host"); return isValidHostName(hostName, component); }
From source file:org.zanata.sync.jobs.system.ResourceProducer.java
private static boolean isGitExecutableOnPath() { String tryNativeGit = System.getenv(TRY_NATIVE_GIT); if (Boolean.parseBoolean(tryNativeGit)) { Pattern pattern = Pattern.compile(Pattern.quote(File.pathSeparator)); return pattern.splitAsStream(System.getenv("PATH")).map(Paths::get) .anyMatch(path -> Files.exists(path.resolve("git"))); }//w ww . j a v a2 s .co m return false; }
From source file:com.pinterest.secor.parser.MessageParser.java
public MessageParser(SecorConfig config) { mConfig = config;//from w ww .j ava 2s. c o m if (mConfig.getMessageTimestampName() != null && !mConfig.getMessageTimestampName().isEmpty() && mConfig.getMessageTimestampNameSeparator() != null && !mConfig.getMessageTimestampNameSeparator().isEmpty()) { String separatorPattern = Pattern.quote(mConfig.getMessageTimestampNameSeparator()); mNestedFields = mConfig.getMessageTimestampName().split(separatorPattern); } }
From source file:com.orange.clara.cloud.servicedbdumper.config.AppConfig.java
@Bean public String dateFormatFile() { String finalDateFormat = dateFormat.replaceAll(Pattern.quote(" "), "-"); finalDateFormat = finalDateFormat.replaceAll(Pattern.quote(":"), ""); return finalDateFormat; }
From source file:ezbake.warehaus.WarehausUtils.java
public static String getPatternForURI(String uri) { return ".*\\:" + Pattern.quote(uri) + ".*"; }
From source file:com.mirth.connect.plugins.datatypes.hl7v2.ER7BatchAdaptorFactory.java
public ER7BatchAdaptorFactory(SourceConnector sourceConnector, SerializerProperties serializerProperties) { super(sourceConnector); HL7v2SerializationProperties serializationProperties = (HL7v2SerializationProperties) serializerProperties .getSerializationProperties(); batchProperties = (HL7v2BatchProperties) serializerProperties.getBatchProperties(); segmentDelimiter = StringUtil.unescape(serializationProperties.getSegmentDelimiter()); String pattern;//from w w w.j a v a2 s. c om if (serializationProperties.isConvertLineBreaks()) { pattern = "\r\n|\r|\n"; if (!(segmentDelimiter.equals("\r") || segmentDelimiter.equals("\n") || segmentDelimiter.equals("\r\n"))) { pattern += "|" + Pattern.quote(segmentDelimiter); } } else { pattern = Pattern.quote(segmentDelimiter); } lineBreakPattern = Pattern.compile(pattern); }
From source file:com.moss.appkeep.tools.cache.SimpleAppkeepComponentCache.java
private static String dirNameForUrl(String url) { try {/* w w w . j av a 2s . c o m*/ URL u = new URL(url); return u.getProtocol() + "_" + u.getHost() + "_" + u.getPort() + "_" + u.getPath().replaceAll(Pattern.quote("/"), "_"); } catch (MalformedURLException e) { throw new RuntimeException(e); } }
From source file:dk.netarkivet.common.utils.DomainUtils.java
/** Helper method for reading TLDs from settings. * Will read all settings, validate them as legal TLDs and * warn and ignore them if any are invalid. * Settings may be with or without prefix "." * @return a List of TLDs as Strings /* w w w. ja v a2 s .c o m*/ */ private static List<String> readTlds() { List<String> tlds = new ArrayList<String>(); for (String tld : Settings.getAll(CommonSettings.TLDS)) { if (tld.startsWith(".")) { tld = tld.substring(1); } if (!tld.matches(DOMAINNAME_CHAR_REGEX_STRING + "(" + DOMAINNAME_CHAR_REGEX_STRING + "|\\.)*")) { log.warn("Invalid tld '" + tld + "', ignoring"); continue; } tlds.add(Pattern.quote(tld)); } return tlds; }
From source file:edu.nimbus.glass.TopicManager.java
/** * // www . j a v a2 s . co m * Get the desired field from the message that is currently being stored. * @param field : String - Which field should be parsed. * @return Text message contained in the field. */ public String getField(String field) { String[] subfields = field.split(Pattern.quote(".")); try { JSONObject obj = new JSONObject(getOriginalMessage()); return getJSONMessageRec(obj.getJSONObject("msg"), subfields, 0); } catch (JSONException e) { e.printStackTrace(); return "JSON ERROR"; } }