congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
StringUtils.addStart
Code IndexAdd Tabnine to your IDE (free)

How to use
addStart
method
in
ro.pippo.core.util.StringUtils

Best Java code snippets using ro.pippo.core.util.StringUtils.addStart (Showing top 18 results out of 315)

origin: pippo-java/pippo

/**
 * Prefix the given path with the application path.
 *
 * @param path
 * @return an absolute path
 */
protected String prefixApplicationPath(String path) {
  return applicationPath + StringUtils.addStart(path, "/");
}
origin: pippo-java/pippo

@Override
public void ignorePaths(String... pathPrefixes) {
  for (String pathPrefix : pathPrefixes) {
    this.ignorePaths.add(StringUtils.addStart(pathPrefix, "/"));
  }
}
origin: pippo-java/pippo

private String concatUriPattern(String prefix, String uriPattern) {
  uriPattern = StringUtils.addStart(StringUtils.addStart(uriPattern, "/"), prefix);
  return "/".equals(uriPattern) ? uriPattern : StringUtils.removeEnd(uriPattern, "/");
}
origin: pippo-java/pippo

@Override
public void setContextPath(String contextPath) {
  if (StringUtils.isNullOrEmpty(contextPath) || "/".equals(contextPath.trim())) {
    this.contextPath = "";
  } else {
    this.contextPath = StringUtils.addStart(contextPath, "/");
  }
}
origin: pippo-java/pippo

private void addCookie(Cookie cookie) {
  checkCommitted();
  if (StringUtils.isNullOrEmpty(cookie.getPath())) {
    cookie.setPath(StringUtils.addStart(contextPath, "/"));
  }
  getCookieMap().put(cookie.getName(), cookie);
}
origin: pippo-java/pippo

@Override
public void setApplicationPath(String applicationPath) {
  if (StringUtils.isNullOrEmpty(applicationPath) || "/".equals(applicationPath.trim())) {
    this.applicationPath = "";
  } else {
    this.applicationPath = StringUtils.removeEnd(StringUtils.addStart(applicationPath, "/"), "/");
  }
}
origin: pippo-java/pippo

/**
 * Redirects the browser to a path relative to the Pippo application root. For
 * example, redirectToApplicationPath("/contacts") might redirect the browser to
 * http://localhost/myContext/myApp/contacts
 * <p>This method commits the response.</p>
 *
 * @param path
 */
public void redirectToApplicationPath(String path) {
  if ("".equals(applicationPath)) {
    // application path is the root
    redirect(path);
  } else {
    redirect(applicationPath + StringUtils.addStart(path, "/"));
  }
}
origin: pippo-java/pippo

protected List<DirEntry> getDirEntries(RouteContext routeContext, File dir, String absoluteDirUri) {
  List<DirEntry> list = new ArrayList<>();
  for (File file : getFiles(dir)) {
    String fileUrl = routeContext.getRequest().getApplicationPath()
      + StringUtils.removeEnd(StringUtils.addStart(absoluteDirUri, "/"), "/")
      + StringUtils.addStart(file.getName(), "/");
    list.add(new DirEntry(fileUrl, file));
  }
  if (comparator != null) {
    list.sort(comparator);
  }
  if (!directory.equals(dir)) {
    File upDir = new File(dir, "../");
    list.add(0, new DirEntry(routeContext.getRequest().getApplicationPath()
      + StringUtils.removeEnd(StringUtils.addStart(absoluteDirUri, "/"), "/")
      + StringUtils.addStart(upDir.getName(), "/"), upDir));
  }
  return list;
}
origin: pippo-java/pippo

/**
 * Redirects the browser to a path relative to the application context. For
 * example, redirectToContextPath("/contacts") might redirect the browser to
 * http://localhost/myContext/contacts
 * <p>This method commits the response.</p>
 *
 * @param path
 */
public void redirectToContextPath(String path) {
  if ("".equals(contextPath)) {
    // context path is the root
    redirect(path);
  } else {
    redirect(contextPath + StringUtils.addStart(path, "/"));
  }
}
origin: pippo-java/pippo

@Override
public void init(ServletConfig servletConfig) {
  if (System.getProperty("pippo.hideLogo") == null) {
    log.info(PippoUtils.getPippoLogo());
  }
  // check for runtime mode in filter init parameter
  String mode = servletConfig.getInitParameter(MODE_PARAM);
  if (!StringUtils.isNullOrEmpty(mode)) {
    System.setProperty(PippoConstants.SYSTEM_PROPERTY_PIPPO_MODE, mode);
  }
  if (application == null) {
    createApplication(servletConfig);
    log.debug("Created application '{}'", application);
  }
  ServletContext servletContext = servletConfig.getServletContext();
  // save the servlet context object in application
  application.setServletContext(servletContext);
  // set the application as an attribute of the servlet container
  if (servletContext.getAttribute(WebServer.PIPPO_APPLICATION) == null) {
    servletContext.setAttribute(WebServer.PIPPO_APPLICATION, application);
  }
  String contextPath = StringUtils.addStart(servletContext.getContextPath(), "/");
  application.getRouter().setContextPath(contextPath);
  log.debug("Serving application on context path '{}'", contextPath);
  log.debug("Initializing Route Dispatcher");
  routeDispatcher = new RouteDispatcher(application);
  routeDispatcher.init();
  String runtimeMode = application.getRuntimeMode().toString().toUpperCase();
  log.info("Pippo started ({})", runtimeMode);
}
origin: pippo-java/pippo

String contextPath = StringUtils.addStart(servletContext.getContextPath(), "/");
application.getRouter().setContextPath(contextPath);
origin: pippo-java/pippo

if (methodPaths.length == 0) {
  String fullPath = StringUtils.addStart(controllerPath, "/");
      .filter(Objects::nonNull)
      .collect(Collectors.joining("/"));
    String fullPath = StringUtils.addStart(path, "/");
origin: pippo-java/pippo

private void sendDirectoryListing(RouteContext routeContext, File dir) {
  String absoluteDirUri = getUrlPath() + StringUtils.addStart(directory.toPath().relativize(dir.toPath()).toString(), "/");
  if (StringUtils.isNullOrEmpty(directoryTemplate)) {
    // Generate primitive, default directory listing
    String page = generateDefaultDirectoryListing(routeContext, dir, absoluteDirUri);
    routeContext.html().send(page);
  } else {
    // Render directory listing template
    int numFiles = 0;
    int numDirs = 0;
    long diskUsage = 0;
    List<DirEntry> dirEntries = getDirEntries(routeContext, dir, absoluteDirUri);
    for (DirEntry dirEntry : dirEntries) {
      if (dirEntry.isFile()) {
        numFiles++;
        diskUsage += dirEntry.getSize();
      } else if (dirEntry.isDirectory() && !dirEntry.getName().contains("..")) {
        numDirs++;
      }
    }
    routeContext.setLocal("dirUrl", absoluteDirUri);
    routeContext.setLocal("dirPath", absoluteDirUri.substring(getUrlPath().length()));
    routeContext.setLocal("dirEntries", dirEntries);
    routeContext.setLocal("numDirs", numDirs);
    routeContext.setLocal("numFiles", numFiles);
    routeContext.setLocal("diskUsage", diskUsage);
    routeContext.render(directoryTemplate);
  }
}
origin: com.gitblit.fathom/fathom-rest

private String uriFor(String routeUriPattern) {
  String uri = addStart(addStart(routeUriPattern, "/"), routeGroupUriPattern);
  return "/".equals(uri) ? uri : StringUtils.removeEnd(uri, "/");
}
origin: gitblit/fathom

private String uriFor(String routeUriPattern) {
  String uri = addStart(addStart(routeUriPattern, "/"), routeGroupUriPattern);
  return "/".equals(uri) ? uri : StringUtils.removeEnd(uri, "/");
}
origin: com.gitblit.fathom/fathom-rest

String fullPath = StringUtils.addStart(StringUtils.removeEnd(controllerPath, "/"), "/");
ControllerHandler handler = new ControllerHandler(injector, controllerClass, method.getName());
handler.validateMethodArgs(fullPath);
  String fullPath = StringUtils.addStart(StringUtils.removeEnd(path, "/"), "/");
origin: ro.pippo/pippo-controller

if (methodPaths.length == 0) {
  String fullPath = StringUtils.addStart(controllerPath, "/");
      .filter(Objects::nonNull)
      .collect(Collectors.joining("/"));
    String fullPath = StringUtils.addStart(path, "/");
origin: gitblit/fathom

String fullPath = StringUtils.addStart(StringUtils.removeEnd(controllerPath, "/"), "/");
ControllerHandler handler = new ControllerHandler(injector, controllerClass, method.getName());
handler.validateMethodArgs(fullPath);
  String fullPath = StringUtils.addStart(StringUtils.removeEnd(path, "/"), "/");
ro.pippo.core.utilStringUtilsaddStart

Javadoc

Adds a substring only if the source string does not already start with the substring, otherwise returns the source string.

A null source string will return null. An empty ("") source string will return the empty string. A null search string will return the source string.

 
StringUtils.addStart(null, *)      =  
StringUtils.addStart("", *)        =  
StringUtils.addStart(*, null)      =  
StringUtils.addStart("domain.com", "www.")  = "www.domain.com" 
StringUtils.addStart("abc123", "abc")    = "abc123" 

Popular methods of StringUtils

  • isNullOrEmpty
  • removeStart
  • removeEnd
  • addEnd
  • format
  • getFileExtension
    Returns the file extension of the value without the dot or an empty string.
  • getList
  • getPrefix
    Returns the prefix of the input string from 0 to the first index of the delimiter OR it returns the

Popular in Java

  • Reading from database using SQL prepared statement
  • setContentView (Activity)
  • addToBackStack (FragmentTransaction)
  • putExtra (Intent)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now