List of usage examples for org.apache.commons.lang3 StringUtils startsWith
public static boolean startsWith(final CharSequence str, final CharSequence prefix)
Check if a CharSequence starts with a specified prefix.
null s are handled without exceptions.
From source file:eu.openanalytics.rsb.RestJobsITCase.java
@After public void cleanupResults() throws IOException { final Configuration configuration = getConfiguration(); if (configuration == null) { return;//w w w . j a v a 2 s.c om } final File[] testResultFiles = configuration.getResultsDirectory().listFiles(new FilenameFilter() { public boolean accept(final File dir, final String name) { return StringUtils.startsWith(name, TEST_APPLICATION_NAME_PREFIX); } }); if (testResultFiles == null) { return; } for (final File testResultFile : testResultFiles) { FileUtils.deleteQuietly(testResultFile); } }
From source file:gobblin.metrics.event.sla.SlaEventSubmitter.java
/** * Construct an {@link SlaEventSubmitter} by extracting Sla event metadata from the properties. See * {@link SlaEventKeys} for keys to set in properties * <p>//from w w w. j a v a 2s . c o m * The <code>props</code> MUST have required property {@link SlaEventKeys#DATASET_URN_KEY} set.<br> * All properties with prefix {@link SlaEventKeys#EVENT_ADDITIONAL_METADATA_PREFIX} will be automatically added as * event metadata * </p> * <p> * Use {@link SlaEventSubmitter#builder()} to build an {@link SlaEventSubmitter} directly with event metadata. * </p> * * @param submitter used to submit the event * @param name of the event * @param props reference that contains event metadata */ public SlaEventSubmitter(EventSubmitter submitter, String name, Properties props) { this.eventName = name; this.eventSubmitter = submitter; this.datasetUrn = props.getProperty(SlaEventKeys.DATASET_URN_KEY); if (props.containsKey(SlaEventKeys.DATASET_URN_KEY)) { this.datasetUrn = props.getProperty(SlaEventKeys.DATASET_URN_KEY); } else { this.datasetUrn = props.getProperty(ConfigurationKeys.DATASET_URN_KEY); } this.partition = props.getProperty(SlaEventKeys.PARTITION_KEY); this.originTimestamp = props.getProperty(SlaEventKeys.ORIGIN_TS_IN_MILLI_SECS_KEY); this.upstreamTimestamp = props.getProperty(SlaEventKeys.UPSTREAM_TS_IN_MILLI_SECS_KEY); this.completenessPercentage = props.getProperty(SlaEventKeys.COMPLETENESS_PERCENTAGE_KEY); this.recordCount = props.getProperty(SlaEventKeys.RECORD_COUNT_KEY); this.previousPublishTimestamp = props.getProperty(SlaEventKeys.PREVIOUS_PUBLISH_TS_IN_MILLI_SECS_KEY); this.dedupeStatus = props.getProperty(SlaEventKeys.DEDUPE_STATUS_KEY); this.isFirstPublish = props.getProperty(SlaEventKeys.IS_FIRST_PUBLISH); this.additionalMetadata = Maps.newHashMap(); for (Entry<Object, Object> entry : props.entrySet()) { if (StringUtils.startsWith(entry.getKey().toString(), SlaEventKeys.EVENT_ADDITIONAL_METADATA_PREFIX)) { this.additionalMetadata.put(StringUtils.removeStart(entry.getKey().toString(), SlaEventKeys.EVENT_ADDITIONAL_METADATA_PREFIX), entry.getValue().toString()); } } }
From source file:com.erudika.para.core.App.java
public static final String id(String id) { if (StringUtils.startsWith(id, prefix)) { return prefix.concat(Utils.noSpaces(Utils.stripAndTrim(id.replaceAll(prefix, ""), " "), "-")); } else if (id != null) { return prefix.concat(Utils.noSpaces(Utils.stripAndTrim(id, " "), "-")); } else {//ww w. ja va 2 s. c o m return null; } }
From source file:ch.cyberduck.core.googledrive.AbstractDriveListService.java
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try {//w w w. j av a 2s.co m final AttributedList<Path> children = new AttributedList<>(); String page = null; do { final FileList list = session.getClient().files().list() // Whether Team Drive items should be included in results .setIncludeTeamDriveItems(true) // Whether the requesting application supports Team Drives .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")) .setQ(this.query(directory, listener)).setOrderBy("name").setPageToken(page) .setFields(fields).setPageSize(pagesize).execute(); if (log.isDebugEnabled()) { log.debug(String.format("Chunk of %d retrieved", list.getFiles().size())); } for (File f : list.getFiles()) { final PathAttributes properties = this.toAttributes(f); if (properties == null) { continue; } final String filename; if (!DRIVE_FOLDER.equals(f.getMimeType()) && StringUtils.startsWith(f.getMimeType(), GOOGLE_APPS_PREFIX)) { filename = String.format("%s.%s", PathNormalizer.name(f.getName()), urlFileWriter.getExtension()); } else { filename = PathNormalizer.name(f.getName()); } if (StringUtils.equals(filename, String.valueOf(Path.DELIMITER))) { continue; } // Use placeholder type to mark Google Apps document to download as web link file final EnumSet<AbstractPath.Type> type = DRIVE_FOLDER.equals(f.getMimeType()) ? EnumSet.of(Path.Type.directory) : StringUtils.startsWith(f.getMimeType(), GOOGLE_APPS_PREFIX) ? EnumSet.of(Path.Type.file, Path.Type.placeholder) : EnumSet.of(Path.Type.file); final Path child = new Path(directory, filename, type, properties); children.add(child); } listener.chunk(directory, children); page = list.getNextPageToken(); if (log.isDebugEnabled()) { log.debug(String.format("Continue with next page token %s", page)); } } while (page != null); return children; } catch (IOException e) { throw new DriveExceptionMappingService().map("Listing directory failed", e, directory); } }
From source file:com.sonicle.webtop.core.app.servlet.PublicRequest.java
public JarFileResource getInternalPublicFile(WebTopApp wta, String serviceId, String relativePath) throws URISyntaxException, IOException { if (!StringUtils.startsWith(relativePath, PUBLIC_RESOURCES)) return null; String pathname = LangUtils.joinPaths(LangUtils.packageToPath(serviceId), relativePath); return wta.getJarResource(this.getClass().getResource("/" + pathname)); }
From source file:com.quancheng.saluki.boot.runner.GrpcServiceRunner.java
@Override public void run(String... arg0) throws Exception { System.out.println("Starting GRPC Server ..."); RpcServiceConfig rpcSerivceConfig = new RpcServiceConfig(); this.addRegistyAddress(rpcSerivceConfig); rpcSerivceConfig.setApplication(applicationName); this.addHostAndPort(rpcSerivceConfig); rpcSerivceConfig.setMonitorinterval(thrallProperties.getMonitorinterval()); Collection<Object> instances = getTypedBeansWithAnnotation(SalukiService.class); if (instances.size() > 0) { try {//from w ww . j a v a 2 s .c o m for (Object instance : instances) { SalukiService serviceAnnotation = instance.getClass().getAnnotation(SalukiService.class); String serviceName = serviceAnnotation.service(); Set<String> serviceNames = Sets.newHashSet(); Object target = instance; if (StringUtils.isBlank(serviceName)) { if (this.isGrpcServer(instance)) { throw new java.lang.IllegalArgumentException( "you use grpc stub service,must set service name,service instance is" + instance); } else { target = GrpcAopUtils.getTarget(target); Class<?>[] interfaces = ClassUtils.getAllInterfacesForClass(target.getClass()); for (Class<?> interfaceClass : interfaces) { String interfaceName = interfaceClass.getName(); if (StringUtils.startsWith(interfaceName, "com.quancheng")) { serviceNames.add(interfaceName); } } } } else { serviceNames.add(serviceName); } for (String realServiceName : serviceNames) { rpcSerivceConfig.addServiceDefinition(realServiceName, getGroup(serviceAnnotation), getVersion(serviceAnnotation), instance); } } } finally { Object healthInstance = new HealthImpl(applicationContext); BeanDefinitionRegistry beanDefinitonRegistry = (BeanDefinitionRegistry) applicationContext .getBeanFactory(); BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder .genericBeanDefinition(Health.class); beanDefinitonRegistry.registerBeanDefinition(Health.class.getName(), beanDefinitionBuilder.getRawBeanDefinition()); applicationContext.getBeanFactory().registerSingleton(Health.class.getName(), healthInstance); String group = thrallProperties.getGroup() != null ? thrallProperties.getGroup() : "default"; String version = thrallProperties.getVersion() != null ? thrallProperties.getVersion() : "1.0.0"; rpcSerivceConfig.addServiceDefinition(Health.class.getName(), group, version, healthInstance); } } this.rpcService = rpcSerivceConfig; rpcSerivceConfig.export(); System.out.println(String.format("GRPC server has started!You can do test by %s \n %s", "http://localhost:" + httpPort + "/doc", "http://saluki.dev.quancheng-ec.com")); }
From source file:com.nridge.core.app.mgr.ServiceTimer.java
/** * Convenience method that returns the value of an application * manager property using the concatenation of the property * prefix and suffix values. If the property is not found, * then the default value parameter will be returned. * * @param aSuffix Property name suffix. * @param aDefaultValue Default value./* w w w . java2 s .c om*/ * * @return Matching property value or the default value. */ public String getAppString(String aSuffix, String aDefaultValue) { String propertyName; if (StringUtils.startsWith(aSuffix, ".")) propertyName = mPropertyPrefix + aSuffix; else propertyName = mPropertyPrefix + "." + aSuffix; return mAppMgr.getString(propertyName, aDefaultValue); }
From source file:com.anrisoftware.globalpom.format.latlong.LatitudeFormat.java
private void formatCoordinate(StringBuffer buff, double d) { String s = sexagesimalFormatFactory.create(decimal).format(d); if (StringUtils.startsWith(s, "-")) { s = s.substring(1);//from w w w . j a v a 2s .co m } buff.append(s); if (signum(d) > 0.0) { buff.append(" "); buff.append(NORTH); } else { buff.append(" "); buff.append(SOUTH); } }
From source file:io.wcm.tooling.commons.contentpackagebuilder.ValueConverter.java
private String escapeStringValue(String value) { if (StringUtils.startsWith(value, "{")) { return "\\" + value; }/*from w w w. ja v a 2 s . c o m*/ return value; }
From source file:com.glaf.dts.web.rest.MxTableResource.java
@POST @Path("/delete") @ResponseBody//from w w w .ja va 2 s .c o m @Produces({ MediaType.APPLICATION_OCTET_STREAM }) public byte[] delete(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String tableName = request.getParameter("tableName"); String tableName_enc = request.getParameter("tableName_enc"); if (StringUtils.isNotEmpty(tableName_enc)) { tableName = RequestUtils.decodeString(tableName_enc); } if (StringUtils.isNotEmpty(tableName)) { tableName = tableName.toLowerCase(); if (StringUtils.startsWith(tableName, "mx_") || StringUtils.startsWith(tableName, "sys_") || StringUtils.startsWith(tableName, "jbpm_") || StringUtils.startsWith(tableName, "act_")) { return ResponseUtils.responseJsonResult(false); } tableDefinitionService.deleteTable(tableName); return ResponseUtils.responseJsonResult(true); } return ResponseUtils.responseJsonResult(false); }