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:kenh.expl.Environment.java
/** * Load function packages through system properties *//*from w w w .jav a 2 s. com*/ private void loadFunctionPackages_SystemProperties() { Properties p = System.getProperties(); Set keys = p.keySet(); for (Object key_ : keys) { if (key_ instanceof String) { String key = (String) key_; if (StringUtils.startsWith(key, FUNCTION_PATH_PREFIX + ".")) { String name = StringUtils.substringAfter(key, FUNCTION_PATH_PREFIX + "."); String funcPackage = p.getProperty(key); setFunctionPackage(name, funcPackage); } } } }
From source file:com.sonicle.webtop.core.app.servlet.PublicRequest.java
public static void writeFile(HttpServletRequest request, HttpServletResponse response, Resource resource) throws Exception { InputStream is = null;//from w w w .j a v a2 s . co m OutputStream os = null; try { String mimeType = ServletUtils.guessMimeType(resource.getFilename()); ServletUtils.setContentTypeHeader(response, mimeType); if (StringUtils.startsWith(mimeType, "image")) { ServletUtils.setCacheControlPrivateMaxAge(response, 60 * 60 * 24); } else { ServletUtils.setCacheControlPrivateNoCache(response); } os = ServletUtils.prepareForStreamCopy(request, response, mimeType, (int) resource.getSize(), ServletUtils.GZIP_MIN_THRESHOLD); is = resource.getInputStream(); ServletUtils.transferStreams(is, os); } finally { IOUtils.closeQuietly(os); IOUtils.closeQuietly(is); } }
From source file:de.jcup.egradle.codeassist.dsl.gradle.GradleDSLTypeProvider.java
@Override public Type getType(String name) { ensureApiMappingLoaded();//from ww w .j a v a 2 s . c om if (StringUtils.isBlank(name)) { return null; } Type type = nameToTypeMapping.get(name); if (type != null) { return type; } /* currently no support for java types */ if (StringUtils.startsWith(name, "java.")) { return null; } /* no support for sun parts too */ if (StringUtils.startsWith(name, "sun.")) { return null; } if (unresolveableNames.contains(name)) { /* already tried to load */ return null; } /* try to load */ String nameToUseForLoading = name; String longName = apiMapping.get(name); if (longName != null) { /* * long name wellknown - so load with this one and register short * name as well */ type = getType(longName); if (type == null) { unresolveableNames.add(name); return null; } /* found by long name - so register short name too: */ nameToTypeMapping.put(name, type); return type; } try { type = fileLoader.loadType(nameToUseForLoading); } catch (IOException e) { getErrorHandler().handleError("Cannot load dsl type:" + name, e); } if (type == null) { unresolveableNames.add(name); return null; } /* * Put uninitialized type - so avoiding endless loops while collecting. * This means: no inherited methods etc. But when doing this and a loop * exists, at this time not all information is available and inheritance * will not work */ nameToTypeMapping.put(name, type); if (!(type instanceof ModifiableType)) { return type; } ModifiableType modifiableType = (ModifiableType) type; /* inheritance */ if (type.isInterface()) { /* interface logic */ Set<TypeReference> interfaces = type.getInterfaces(); for (TypeReference ref : interfaces) { String interfaceAsString = ref.getTypeAsString(); Type interfaceType = getType(interfaceAsString); if (interfaceType != null) { modifiableType.extendFrom(interfaceType); } } } else { String superTypeAsString = type.getSuperTypeAsString(); /* class */ if (StringUtils.isNotBlank(superTypeAsString)) { Type superType = getType(superTypeAsString); if (superType != null) { modifiableType.extendFrom(superType); } } } /* initialize type */ initInterfaceReferences(modifiableType); initMethods(type); initProperties(type); return type; }
From source file:com.mgmtp.jfunk.core.mail.MailAccount.java
/** * Allows to set a new mail address. This is only possible when mail subaddressing is active and * the new mail address belongs to the defined mail accountId. */*w w w . j a v a 2s. co m*/ * @param address * the new mail address */ public void setAddress(final String address) { // Do we have a subaddressing account? Preconditions.checkArgument(StringUtils.startsWith(this.address, accountId + "+"), "Mail address can only be changed when subaddressing is active"); Preconditions.checkArgument(StringUtils.startsWith(address, accountId), "New mail address %s does not start with accountId=%s", address, accountId); log.info("Changing mail address from {} to {}", this.address, address); this.address = address; }
From source file:de.tuberlin.uebb.jbop.optimizer.array.ArrayHelper.java
private static boolean isArray(final AbstractInsnNode fieldNode) { if (!(fieldNode instanceof FieldInsnNode)) { return false; }//from w ww . ja va 2 s .c o m return StringUtils.startsWith(((FieldInsnNode) fieldNode).desc, "["); }
From source file:de.micromata.genome.gwiki.controls.GWikiLoginActionBean.java
protected Object checkSecureLogin() { String httpsRed = LocalSettings.get().get("gwiki.public.url.https"); if (StringUtils.isBlank(httpsRed) == true) { return null; }/*from w w w. java2 s. co m*/ StringBuffer reqUri = wikiContext.getRequest().getRequestURL(); if (StringUtils.startsWith(reqUri.toString(), "https:") == true) { return null; } String thisUrl = wikiContext.getRealPathInfo(); String retUrl = httpsRed + thisUrl; try { wikiContext.getResponse().sendRedirect(retUrl); } catch (IOException ex) { throw new RuntimeIOException(ex); } return noForward(); }
From source file:com.nridge.connector.common.con_com.publish.PSolr.java
/** * Convenience method that returns the value of a property using * the concatenation of the property prefix and suffix values. * * @param aSuffix Property name suffix.//from w w w.j a va2s. c o m * @return Matching property value. */ private String getCfgString(String aSuffix) { String propertyName; if (StringUtils.startsWith(aSuffix, ".")) propertyName = mCfgPropertyPrefix + aSuffix; else propertyName = mCfgPropertyPrefix + "." + aSuffix; return mAppMgr.getString(propertyName); }
From source file:io.wcm.devops.conga.resource.ResourceLoader.java
/** * If an explicit resource type is declared via prefix return only this. Otherwise return all. * @param path Path/*from w w w .ja va2s .com*/ * @return Supported resource types */ private List<ResourceType> getSupportedResourceTypes(String path) { // check for explicit path specification for (ResourceType resourceType : ResourceType.values()) { if (StringUtils.startsWith(path, resourceType.getPrefix())) { return ImmutableList.of(resourceType); } } // otherwise check all resource types in order of definition in enum return ImmutableList.copyOf(ResourceType.values()); }
From source file:cgeo.geocaching.connector.AbstractConnector.java
@Override @Nullable//from w w w . j a va2 s . c om public String getGeocodeFromUrl(@NonNull final String url) { final String urlPrefix = getCacheUrlPrefix(); if (StringUtils.isEmpty(urlPrefix) || StringUtils.startsWith(url, urlPrefix)) { final String geocode = url.substring(urlPrefix.length()); if (canHandle(geocode)) { return geocode; } } return null; }
From source file:com.erudika.para.storage.AWSFileStore.java
@Override public boolean delete(String path) { if (StringUtils.startsWith(path, "/")) { path = path.substring(1);/*from w ww .j av a2 s .c o m*/ } if (!StringUtils.isBlank(path)) { s3.deleteObject(bucket, path); return true; } return false; }