Example usage for java.lang String endsWith

List of usage examples for java.lang String endsWith

Introduction

In this page you can find the example usage for java.lang String endsWith.

Prototype

public boolean endsWith(String suffix) 

Source Link

Document

Tests if this string ends with the specified suffix.

Usage

From source file:de.erdesignerng.util.JasperUtils.java

public static JasperPrint runJasperReport(File aModelXMLFile, File aJRXMLFile)
        throws JRException, FileNotFoundException {

    String theFileName = aJRXMLFile.getAbsolutePath();
    int p = theFileName.indexOf(".jrxml");
    String theTemplateName = theFileName.substring(0, p) + ".jasper";

    File theTemplateFile = new File(theTemplateName);

    JasperDesign theDesign = JRXmlLoader.load(new FileInputStream(aJRXMLFile));
    JRQuery theQuery = theDesign.getQuery();
    String theQueryText = null;/*from   w w w.j  av a 2  s  .c o  m*/

    if (theQuery != null) {
        theQueryText = theQuery.getText();
    }
    if (StringUtils.isEmpty(theQueryText)) {
        throw new RuntimeException("Cannot extract query from Jasper template");
    }

    Map<String, Object> theParams = new HashMap<>();
    theParams.put(JRParameter.REPORT_LOCALE, Locale.getDefault());

    String theSubreportDir = theTemplateFile.getParent();
    if (!theSubreportDir.endsWith(File.separator)) {
        theSubreportDir += File.separator;
    }
    theParams.put("SUBREPORT_DIR", theSubreportDir);

    JRXmlDataSource theDataSource = new JRXmlDataSource(aModelXMLFile, theQueryText);
    return JasperFillManager.fillReport(new FileInputStream(theTemplateFile), theParams, theDataSource);
}

From source file:de.micromata.tpsb.doc.parser.TypeUtils.java

License:asdf

public static String appendClassEnd(String t) {
    if (t == null) {
        return null;
    }//from   w w  w .ja  va2 s . c  o  m
    if (t.endsWith(".class") == true) {
        return t;
    }
    return t + ".class";
}

From source file:Main.java

/**
 * check if the pair is [UTF-16,UTF-16LE] [UTF-32, UTF-32LE],[UTF-16,UTF-16BE] [UTF-32,
 * UTF-32BE] etc.//from  w w w .jav  a  2s  .  co  m
 *
 * @param enc1 encoding style
 * @param enc2 encoding style
 * @return true if the encoding styles are compatible, or false otherwise
 */
private static boolean compatibleEncodings(String enc1, String enc2) {
    enc1 = enc1.toLowerCase(Locale.getDefault());
    enc2 = enc2.toLowerCase(Locale.getDefault());
    if (enc1.endsWith("be") || enc1.endsWith("le")) {
        enc1 = enc1.substring(0, enc1.length() - 2);
    }
    if (enc2.endsWith("be") || enc2.endsWith("le")) {
        enc2 = enc2.substring(0, enc2.length() - 2);
    }
    return enc1.equals(enc2);
}

From source file:org.bin01.db.verifier.Query.java

private static String clean(String sql) {
    sql = sql.replaceAll("\t", "  ");
    sql = sql.replaceAll("\n+", "\n");
    sql = sql.trim();/*from  w  w w.  j a  va  2  s.co  m*/
    while (sql.endsWith(";")) {
        sql = sql.substring(0, sql.length() - 1).trim();
    }
    return sql;
}

From source file:com.netflix.spinnaker.kork.eureka.EurekaComponents.java

private static String fixNamespace(String namespace) {
    return namespace.endsWith(".") ? namespace : namespace + ".";
}

From source file:by.stub.utils.StringUtils.java

public static boolean isWithinSquareBrackets(final String toCheck) {

    if (toCheck.startsWith("%5B") && toCheck.endsWith("%5D")) {
        return true;
    }//  ww  w  . j  a  v a 2  s  .co m

    return toCheck.startsWith("[") && toCheck.endsWith("]");
}

From source file:Main.java

public static String getAsTagValue(String value) {
    if (value != null && value.length() > 0) {

        // @author changes Medet, CDATA
        if (value.startsWith("<![CDATA[") && value.endsWith("]]>")) {
            return value;
        }/*from ww  w  . j a  v  a  2 s. c  o  m*/
        //

        String val = value.replace("&", "&amp;");
        val = val.replace("\n", "");
        val = val.replace("\"", "'");
        val = val.replace("\r", "");
        val = val.replace("\"", "&quot;");
        val = val.replace("<", "&lt;").replace(">", "&gt;");
        return val;
    } else {
        return "";
    }
}

From source file:org.freshrss.easyrss.network.url.AbsURL.java

private static String appendParams(final String str, final String param) {
    if (str.length() == 0 || str.endsWith("&")) {
        return str + param;
    } else {//from w  ww.  j a  v a 2s. c  o m
        return str + "&" + param;
    }
}

From source file:test.TestJavaService.java

/**
 * Make the special JSON encoding with both a schema and some number of CSV files must be provided
 * TODO at present there is no way to send "format" or "delimiter" members
 * @param schemaString a String containing the JSON schema
 * @param files the list of file names which are to be read to obtain CSV and whose names are to be decomposed to
 *   form type (table) names// w w  w . ja v a 2  s.c  o  m
 * @return the JSON encoding to send
 * @throws IOException 
 */
private static String makeSpecialJson(String schemaString, List<String> files) throws IOException {
    JsonObject result = new JsonObject();
    JsonObject schema = new JsonParser().parse(schemaString).getAsJsonObject();
    result.add("schema", schema);
    JsonObject data = new JsonObject();
    result.add("data", data);
    for (String file : files) {
        Path path = Paths.get(file);
        String csv = new String(Files.readAllBytes(path));
        String table = path.getFileName().toString();
        if (table.endsWith(".csv"))
            table = table.substring(0, table.length() - 4);
        data.add(table, new JsonPrimitive(csv));
    }
    return result.toString();
}