Example usage for org.apache.commons.lang StringUtils stripStart

List of usage examples for org.apache.commons.lang StringUtils stripStart

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils stripStart.

Prototype

public static String stripStart(String str, String stripChars) 

Source Link

Document

Strips any of a set of characters from the start of a String.

Usage

From source file:com.gemstone.gemfire.internal.security.GeodeSecurityUtil.java

public static Object postProcess(String regionPath, Object key, Object result) {
    if (postProcessor == null)
        return result;

    Subject subject = getSubject();

    if (subject == null)
        return result;

    String regionName = StringUtils.stripStart(regionPath, "/");
    return postProcessor.processRegionValue((Principal) subject.getPrincipal(), regionName, key, result);
}

From source file:info.magnolia.cms.core.HierarchyManager.java

private String makeRelative(String path) {
    return StringUtils.stripStart(path, "/"); //$NON-NLS-1$
}

From source file:info.magnolia.cms.core.DefaultHierarchyManager.java

private String makeRelative(String path) {
    return StringUtils.stripStart(path, "/");
}

From source file:eu.annocultor.tools.GeneratorOfXmlSchemaForConvertersDoclet.java

static void printConstructorSchema(ConstructorDoc constr, PrintWriter out) throws Exception {
    if (constr.modifierSpecifier() == Modifier.PUBLIC) {
        String affix = constr.annotations()[0].elementValues()[1].value().toString();
        affix = StringUtils.stripEnd(StringUtils.stripStart(affix, "\""), "\"");

        out.println("<!-- " + constr.qualifiedName() + constr.signature() + " -->");
        out.println("       <xs:element name=\"" + constr.qualifiedName() + "-" + affix
                + "\" substitutionGroup=\"ABSTRACT-RULE\" >");
        out.println("        <xs:complexType> ");
        out.println("         <xs:sequence>");

        findType(constr, new Formatter(out) {

            @Override//from w  w w  .jav  a 2 s . co  m
            public void formatElementStart(String name, String type, boolean array) {
                writer.print("           <xs:element name=\"" + name + "\" type=\"" + type + "\""
                        + (array ? " minOccurs=\"0\" maxOccurs=\"unbounded\" " : "") + ">");
            }

            @Override
            public void formatDocumentation(String doc) {
                writer.print("\n         <xs:annotation><xs:documentation xml:lang=\"en\">"
                        + StringEscapeUtils.escapeXml(doc) + "</xs:documentation></xs:annotation>");
            }

            @Override
            public void formatElementEnd(String name) {
                writer.print(" \n            </xs:element>");
            }

        });
    }
    out.println(ruleListenerDef);
    out.println("      </xs:sequence>");
    out.println("     </xs:complexType> ");
    out.println("    </xs:element>");
}

From source file:eu.annocultor.tools.GeneratorOfXmlSchemaForConvertersDoclet.java

static void printConstructorDoc(ConstructorDoc constr, PrintWriter out) throws Exception {
    if (constr.modifierSpecifier() == Modifier.PUBLIC) {
        String affix = constr.annotations()[0].elementValues()[1].value().toString();
        affix = StringUtils.stripEnd(StringUtils.stripStart(affix, "\""), "\"");
        out.println("  <h2 id=\"Constructor " + constr.name() + "-" + affix + "\">Constructor <code>" + affix
                + "</code></h2>");
        out.println();/*from w  w w  .  j ava2  s  . c  om*/
        out.println(" <p>" + constr.commentText() + "</p>");
        out.println();
        out.println(" <p>Sample use:</p>");
        out.println("<div class=\"source\"><pre>");

        out.println(StringEscapeUtils.escapeHtml("<ac:" + constr.qualifiedName() + "-" + affix + ">"));
        findType(constr, new Formatter(out) {

            @Override
            public void formatElementStart(String name, String type, boolean array) {
                writer.print(StringEscapeUtils.escapeHtml("  <ac:" + name + " rdf:datatype=\"" + type + "\">"));
            }

            @Override
            public void formatDocumentation(String doc) {
                writer.print(" <i style=\"font-family: Times\">" + StringEscapeUtils.escapeHtml(doc) + "</i> ");
            }

            @Override
            public void formatElementEnd(String name) {
                writer.println(StringEscapeUtils.escapeHtml("</ac:" + name + ">"));
            }

        });

        out.println(StringEscapeUtils.escapeHtml("</ac:" + constr.qualifiedName() + "-" + affix + ">"));
        out.println("</pre></div>");
    }
    out.println();
    out.flush();
}

From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java

private static void setCellValueTagNumberFormat(HSSFWorkbook wb, Cell cell, Object oneCellValue,
        String vendor) {//from w  w  w.jav a2s  .c  om
    if (oneCellValue == null) {
        cell.setCellValue(StringUtils.EMPTY);
        return;
    }

    String tagNum = StringUtils.trimToEmpty(oneCellValue.toString());
    tagNum = tagNum.replaceAll("\u00a0", StringUtils.EMPTY);
    tagNum = StringUtils.stripStart(tagNum, "0");

    if (StringUtils.contains(vendor, TOLL_COMPANY_SUN_PASS)) {
        if (StringUtils.startsWith(tagNum, "155")) {
            tagNum = StringUtils.stripEnd(tagNum, "0");
        }
    }

    cell.setCellValue(tagNum);
}

From source file:com.opengamma.examples.simulated.tool.ExampleDatabasePopulator.java

private static String unpackJar(URL resource) {
    String file = resource.getPath();
    if (file.contains(".jar!/")) {
        s_logger.info("Unpacking zip file located within a jar file: {}", resource);
        String jarFileName = StringUtils.substringBefore(file, "!/");
        if (jarFileName.startsWith("file:/")) {
            jarFileName = jarFileName.substring(5);
            if (SystemUtils.IS_OS_WINDOWS) {
                jarFileName = StringUtils.stripStart(jarFileName, "/");
            }/* w  w  w  .j  a  v  a 2 s  .  c om*/
        } else if (jarFileName.startsWith("file:/")) {
            jarFileName = jarFileName.substring(6);
        }
        jarFileName = StringUtils.replace(jarFileName, "%20", " ");
        String innerFileName = StringUtils.substringAfter(file, "!/");
        innerFileName = StringUtils.replace(innerFileName, "%20", " ");
        s_logger.info("Unpacking zip file found jar file: {}", jarFileName);
        s_logger.info("Unpacking zip file found zip file: {}", innerFileName);
        try {
            JarFile jar = new JarFile(jarFileName);
            JarEntry jarEntry = jar.getJarEntry(innerFileName);
            try (InputStream in = jar.getInputStream(jarEntry)) {
                File tempFile = File.createTempFile("simulated-examples-database-populator-", ".zip");
                tempFile.deleteOnExit();
                try (OutputStream out = new FileOutputStream(tempFile)) {
                    IOUtils.copy(in, out);
                }
                file = tempFile.getCanonicalPath();
            }
        } catch (IOException ex) {
            throw new OpenGammaRuntimeException("Unable to open file within jar file: " + resource, ex);
        }
        s_logger.debug("Unpacking zip file extracted to: {}", file);
    }
    return file;
}

From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java

private static void setCellValuePlateNumberFormat(HSSFWorkbook wb, Cell cell, Object oneCellValue,
        String vendor) {//from www.  j  a  v  a 2s  .co  m
    if (oneCellValue == null) {
        cell.setCellValue(StringUtils.EMPTY);
        return;
    }

    String plateNum = StringUtils.trimToEmpty(oneCellValue.toString());
    plateNum = plateNum.replaceAll("\u00a0", StringUtils.EMPTY);
    if (StringUtils.isEmpty(plateNum)) {
        cell.setCellValue(StringUtils.EMPTY);
        return;
    }

    if (StringUtils.contains(vendor, TOLL_COMPANY_EZ_PASS_NY)) {
        plateNum = StringUtils.stripStart(plateNum, "0");
        plateNum = StringUtils.substring(plateNum, 2);
    } else if (StringUtils.contains(vendor, TOLL_COMPANY_EZ_PASS_PA)) {
        plateNum = StringUtils.substring(plateNum, 3);
    }
    cell.setCellValue(plateNum);
}

From source file:au.edu.anu.portal.portlets.tweetal.servlet.TweetalServlet.java

private String replaceUserReference(String statusText) {
    Pattern p = Pattern.compile("@[a-zA-Z0-9_]+");
    Matcher m = p.matcher(statusText);

    // if we have a match anywhere in the string
    StringBuffer buf = new StringBuffer();
    while (m.find()) {
        //replace that portion that matched, with the link
        String linkId = StringUtils.stripStart(m.group(), "@");
        m.appendReplacement(buf,/*from ww  w. ja  v a  2 s . c  o  m*/
                String.format("<a target=\"_blank\" href=\"http://twitter.com/%s\">%s</a>", linkId, m.group()));
    }
    m.appendTail(buf);
    return buf.toString();
}

From source file:au.edu.anu.portal.portlets.tweetal.servlet.TweetalServlet.java

private String replaceHashTag(String statusText) {
    Pattern p = Pattern.compile("(\\s|\\A)#([^\\s]+)");
    Matcher m = p.matcher(statusText);

    // if we have a match anywhere in the string
    StringBuffer buf = new StringBuffer();
    while (m.find()) {
        //replace that portion that matched, with the link
        String matched = m.group();
        m.appendReplacement(buf,/*www . j  a v  a  2 s . co  m*/
                String.format("<a target=\"_blank\" href=\"http://twitter.com/search?q=%%23%s\">%s</a>",
                        StringUtils.stripStart(matched.substring(1), "#"), matched));
    }
    m.appendTail(buf);
    return buf.toString();
}