List of usage examples for java.lang String subSequence
public CharSequence subSequence(int beginIndex, int endIndex)
From source file:andlabs.lounge.lobby.util.parser.PlayParser.java
private String parseImageUrl(String html) { if (html != null && html.contains(PLAY_PATTERN_START)) { int start = html.indexOf(PLAY_PATTERN_START); start += PLAY_PATTERN_START.length() + 1; final String secondHalf = html.subSequence(start, start + 300).toString(); int end = secondHalf.indexOf(PLAY_PATTERN_END); final String imageString = secondHalf.substring(0, end); String returnString = ""; String[] strings = imageString.split("w"); for (int i = 0; i < strings.length - 1; i++) { returnString += strings[i] + "w"; }//from w w w. j a v a 2s .c om return returnString; } return null; }
From source file:org.opennms.protocols.vmware.VmwareConfigBuilder.java
private void saveVMwareGraphProperties() { StringBuffer buffer = new StringBuffer(); StringBuffer include = new StringBuffer(); HashMap<String, Boolean> generatedGraphs = new HashMap<String, Boolean>(); for (String collectionName : collections.keySet()) { Map<String, TreeSet<VMwareConfigMetric>> collection = collections.get(collectionName); for (String groupName : collection.keySet()) { TreeSet<VMwareConfigMetric> metrics = collection.get(groupName); for (VMwareConfigMetric vmwarePerformanceMetric : metrics) { Boolean generated = (generatedGraphs.get(vmwarePerformanceMetric.getAliasName()) == null ? false : generatedGraphs.get(vmwarePerformanceMetric.getAliasName())); if (!generated) { generatedGraphs.put(vmwarePerformanceMetric.getAliasName(), Boolean.TRUE); buffer.append(vmwarePerformanceMetric.getGraphDefinition(apiVersion)); include.append(vmwarePerformanceMetric.getInclude(apiVersion)); }// w ww .ja va 2 s . c om } } } final String content = include.toString(); saveFile("vmware" + apiVersion + "-graph-simple.properties", "reports=" + content.subSequence(0, content.length() - 4) + "\n\n" + buffer.toString()); }
From source file:com.baseproject.volley.toolbox.BasicNetwork.java
@Override public NetworkResponse performRequest(Request<?> request) throws VolleyError { long requestStart = SystemClock.elapsedRealtime(); while (true) { HttpResponse httpResponse = null; byte[] responseContents = null; Map<String, String> responseHeaders = new HashMap<String, String>(); try {/*ww w . ja v a 2s. c om*/ // Gather headers. Map<String, String> headers = new HashMap<String, String>(); addCacheHeaders(headers, request.getCacheEntry()); httpResponse = mHttpStack.performRequest(request, headers); StatusLine statusLine = httpResponse.getStatusLine(); int statusCode = statusLine.getStatusCode(); responseHeaders = convertHeaders(httpResponse.getAllHeaders()); // Handle cache validation. if (statusCode == HttpStatus.SC_NOT_MODIFIED) { return new NetworkResponse(HttpStatus.SC_NOT_MODIFIED, request.getCacheEntry() == null ? null : request.getCacheEntry().data, responseHeaders.get("Etag"), HttpHeaderParser.parseCharset(responseHeaders), true, request.getExpireTime()); } // Some responses such as 204s do not have content. We must check. if (httpResponse.getEntity() != null) { responseContents = entityToBytes(httpResponse.getEntity()); // TODO add to ensure download correct add by fenglei // long realLength = responseContents.length; // long requireLength = httpResponse.getEntity().getContentLength(); // if(realLength != requireLength && requireLength != -1) { // Log.i("Error", "realLength = " + realLength + ", requireLength = " + requireLength); // } if (responseContents != null && httpResponse.getEntity().getContentLength() > 0 && responseContents.length != httpResponse.getEntity().getContentLength()) { attemptRetryOnException("socket", request, new VolleyError(Util.buildHttpErrorMsg("failed", -1, "ContentLength Error"))); continue; } } else { // Add 0 byte response as a way of honestly representing a // no-content request. responseContents = new byte[0]; } // if the request is slow, log it. long requestLifetime = SystemClock.elapsedRealtime() - requestStart; logSlowRequests(requestLifetime, request, responseContents, statusLine); // if (statusCode < 200 || statusCode > 299) { // throw new IOException(); // } if (request.isUpdateCookie()) { Header[] cookies = httpResponse.getHeaders("Set-Cookie"); int count = cookies.length; int i = 0; StringBuilder cookieBuilder = new StringBuilder(); for (Header cookie : cookies) { String cookieStr = cookie.getValue(); i++; if (!TextUtils.isEmpty(cookieStr) && cookieStr.length() > 10) { int end = cookieStr.indexOf(" "); if (i == count) { cookieStr = cookieStr.subSequence(0, end - 1).toString(); } else { cookieStr = cookieStr.subSequence(0, end).toString(); } cookieBuilder.append(cookieStr).append(" "); } } if (cookieBuilder.length() > 0) { cookieBuilder.deleteCharAt(cookieBuilder.length() - 1); } request.setUpdateCookie(cookieBuilder.toString()); } return new NetworkResponse(statusCode, responseContents, responseHeaders.get("Etag"), HttpHeaderParser.parseCharset(responseHeaders), false, request.getExpireTime()); } catch (SocketTimeoutException e) { attemptRetryOnException("socket", request, new VolleyError( Util.buildHttpErrorMsg("failed", -1, HttpRequestManager.STATE_ERROR_TIMEOUT))); } catch (ConnectTimeoutException e) { attemptRetryOnException("connection", request, new VolleyError( Util.buildHttpErrorMsg("failed", -1, HttpRequestManager.STATE_ERROR_TIMEOUT))); } catch (MalformedURLException e) { throw new VolleyError(Util.buildHttpErrorMsg("failed", -1, HttpRequestManager.STATE_ERROR_MALFORMED_URL_EXCEPTION)); // throw new RuntimeException("Bad URL " + request.getUrl(), e); } catch (IOException e) { attemptRetryOnException("io", request, new VolleyError(e)); // int statusCode = 0; // NetworkResponse networkResponse = null; // if (httpResponse != null) { // statusCode = httpResponse.getStatusLine().getStatusCode(); // } else { // throw new NoConnectionError(e); // } // VolleyLog.e("Unexpected response code %d for %s", statusCode, request.getUrl()); // if (responseContents != null) { // networkResponse = new NetworkResponse(statusCode, responseContents, // responseHeaders, false); // if (statusCode == HttpStatus.SC_UNAUTHORIZED || // statusCode == HttpStatus.SC_FORBIDDEN) { // attemptRetryOnException("auth", // request, new AuthFailureError(networkResponse)); // } else { // // TODO: Only throw ServerError for 5xx status codes. // throw new ServerError(networkResponse); // } // } else { // throw new NetworkError(networkResponse); // } } } }
From source file:de.hybris.platform.assistedservicestorefront.controllers.cms.AssistedServiceComponentController.java
protected String getCustomerJSON(final CustomerModel customer) throws UnsupportedEncodingException { final String cardNumber = customer.getDefaultPaymentInfo() instanceof CreditCardPaymentInfoModel ? ((CreditCardPaymentInfoModel) customer.getDefaultPaymentInfo()).getNumber() : null;/* w w w .ja v a2s .c o m*/ final String last4Digits = cardNumber == null ? "----" : cardNumber .subSequence(cardNumber.length() >= 4 ? cardNumber.length() - 4 : 0, cardNumber.length()) .toString(); final String formattedCreationDate = customer.getCreationtime() != null ? new SimpleDateFormat("dd/MM/YYYY").format(customer.getCreationtime()) : "--/--/----"; return String.format("{email:'%s',value:'%s',date:'%s',card:'%s'", XSSEncoder.encodeJavaScript(customer.getUid()), XSSEncoder.encodeJavaScript(customer.getName()), formattedCreationDate, last4Digits); }
From source file:de.micromata.genome.gwiki.plugin.confluenceimporter_1_0.confluence.ConfluenceImporter.java
protected String patchInternalLinks(GWikiContext wikiContext, String body, String pathPrefix) { String regexp = "\\[([^\n]+?)\\]"; Pattern p = Pattern.compile(regexp); Matcher m = p.matcher(body);/*from w w w .ja v a 2 s . c om*/ StringBuilder sb = new StringBuilder(); int lastEnd = 0; while (m.find() == true) { int start = m.start(); int end = m.end(); sb.append(body.subSequence(lastEnd, start)); String linkb = m.group(1); lastEnd = end; sb.append("[").append(patchLinkBody(wikiContext, linkb, pathPrefix)).append("]"); } sb.append(body.substring(lastEnd)); return sb.toString(); }
From source file:org.apache.james.jdkim.tagvalue.SignatureRecordImpl.java
/** * @see org.apache.james.jdkim.api.SignatureRecord#getHashAlgo() *//*from w w w. ja v a2 s . c om*/ public CharSequence getHashAlgo() { String a = getValue("a").toString(); int pHyphen = a.indexOf('-'); if (pHyphen == -1) throw new IllegalStateException("Invalid hash method: " + a); if (a.length() > pHyphen + 3 && a.charAt(pHyphen + 1) == 's' && a.charAt(pHyphen + 2) == 'h' && a.charAt(pHyphen + 3) == 'a') { return "sha-" + a.subSequence(pHyphen + 4, a.length()); } else return a.subSequence(pHyphen + 1, a.length()); }
From source file:servlet.CinemaControl.java
protected void doListMSsOfCinemas(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); HttpSession session = request.getSession(); ServletContext sc = getServletContext(); String db_driver = sc.getInitParameter("db_driver"), db_url = sc.getInitParameter("db_url"), db_user = sc.getInitParameter("db_user"), db_password = sc.getInitParameter("db_password"); String db_q_cinemas = "SELECT * FROM Cinema;"; String db_q_houses = "SELECT * FROM House WHERE cinemaID = ?;"; String db_q_movieSessions = "SELECT * FROM MovieSession WHERE houseID = ?;"; String db_q_movies = "SELECT * FROM Movie WHERE movieID = ?;"; String db_q1_0 = "SELECT categoryName" + " FROM category c, movie_category mc, movie m" + " WHERE c.categoryID = mc.categoryID" + " AND m.movieID = mc.movieID" + " AND m.movieID = ?;"; String db_q1_1 = "SELECT actorName" + " FROM actor a, movie_actor ma, movie m" + " WHERE a.actorID = ma.actorID" + " AND ma.movieID = m.movieID" + " AND m.movieID = ?;"; String db_q1_2 = "SELECT image FROM movie m, movieImage mi" + " WHERE m.movieID = mi.movieID" + " AND m.movieID = ?;"; String db_q1_3 = "SELECT video" + " FROM movie m, movieVideo mv" + " WHERE m.movieID = mv.movieID" + " AND m.movieID = ?;"; try {//ww w . j a va 2 s . c o m JSONObject jso0 = new JSONObject(); JSONArray jsa0 = new JSONArray(); jso0.put("cinemas", jsa0); Class.forName(db_driver); Connection conn = DriverManager.getConnection(db_url, db_user, db_password); Statement statmt1 = conn.createStatement(); ResultSet rs1 = statmt1.executeQuery(db_q_cinemas); ResultSetMetaData rsmd1 = rs1.getMetaData(); int numOfColumns1 = rsmd1.getColumnCount(); while (rs1.next()) { JSONObject jso1 = new JSONObject(); jsa0.put(jso1); for (int i = 1; i <= numOfColumns1; i++) { jso1.put(rsmd1.getColumnLabel(i), rs1.getString(i)); } int cinemaID = Integer.parseInt(jso1.getString("cinemaID")); JSONArray jsa1 = new JSONArray(); jso1.put("houses", jsa1); PreparedStatement statmt2 = conn.prepareStatement(db_q_houses); statmt2.setInt(1, cinemaID); if (statmt2.execute()) { ResultSet rs2 = statmt2.getResultSet(); ResultSetMetaData rsmd2 = rs2.getMetaData(); int numOfColumns2 = rsmd2.getColumnCount(); while (rs2.next()) { JSONObject jso2 = new JSONObject(); jsa1.put(jso2); for (int j = 1; j <= numOfColumns2; j++) { jso2.put(rsmd2.getColumnLabel(j), rs2.getString(j)); } int houseID = Integer.parseInt(jso2.getString("houseID")); JSONArray jsa2 = new JSONArray(); jso2.put("movieSessions", jsa2); PreparedStatement statmt3 = conn.prepareStatement(db_q_movieSessions); statmt3.setInt(1, houseID); if (statmt3.execute()) { ResultSet rs3 = statmt3.getResultSet(); ResultSetMetaData rsmd3 = rs3.getMetaData(); int numOfColumns3 = rsmd3.getColumnCount(); while (rs3.next()) { JSONObject jso3 = new JSONObject(); jsa2.put(jso3); for (int k = 1; k <= numOfColumns3; k++) { jso3.put(rsmd3.getColumnLabel(k), rs3.getString(k)); } String playtime = jso3.getString("playtime"); jso3.put("date", playtime.substring(0, 10)); jso3.put("time", playtime.subSequence(11, 16)); int movieID = Integer.parseInt(jso3.getString("movieID")); JSONArray jsa3 = new JSONArray(); jso3.put("movies", jsa3); PreparedStatement statmt4 = conn.prepareStatement(db_q_movies); statmt4.setInt(1, movieID); if (statmt4.execute()) { ResultSet rs4 = statmt4.getResultSet(); ResultSetMetaData rsmd4 = rs4.getMetaData(); int numOfColumns4 = rsmd4.getColumnCount(); while (rs4.next()) { JSONObject jso4 = new JSONObject(); jsa3.put(jso4); for (int l = 1; l <= numOfColumns4; l++) { jso4.put(rsmd4.getColumnLabel(l), rs4.getString(l)); } //add categories JSONArray jsa1_0 = new JSONArray(); jso4.put("categories", jsa1_0); PreparedStatement statmt1_0 = conn.prepareStatement(db_q1_0); statmt1_0.setInt(1, movieID); if (statmt1_0.execute()) { ResultSet rs1_0 = statmt1_0.getResultSet(); while (rs1_0.next()) { jsa1_0.put(rs1_0.getString(1)); } } //add actors JSONArray jsa1_1 = new JSONArray(); jso4.put("actors", jsa1_1); PreparedStatement statmt1_1 = conn.prepareStatement(db_q1_1); statmt1_1.setInt(1, movieID); if (statmt1_1.execute()) { ResultSet rs1_1 = statmt1_1.getResultSet(); while (rs1_1.next()) { jsa1_1.put(rs1_1.getString(1)); } } //add images JSONArray jsa1_2 = new JSONArray(); jso4.put("movieImages", jsa1_2); PreparedStatement statmt1_2 = conn.prepareStatement(db_q1_2); statmt1_2.setInt(1, movieID); if (statmt1_2.execute()) { ResultSet rs1_2 = statmt1_2.getResultSet(); while (rs1_2.next()) { jsa1_2.put(rs1_2.getString(1)); } } //add videos JSONArray jsa1_3 = new JSONArray(); jso4.put("movieVideos", jsa1_3); PreparedStatement statmt1_3 = conn.prepareStatement(db_q1_3); statmt1_3.setInt(1, movieID); if (statmt1_3.execute()) { ResultSet rs1_3 = statmt1_3.getResultSet(); while (rs1_3.next()) { jsa1_3.put(rs1_3.getString(1)); } } } } } } } } } out.println(jso0.toString()); } catch (ClassNotFoundException ex) { Logger.getLogger(CinemaControl.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(CinemaControl.class.getName()).log(Level.SEVERE, null, ex); } catch (JSONException ex) { Logger.getLogger(CinemaControl.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.emr.utilities.CSVLoader.java
/** * Parse CSV file using OpenCSV library and load in * given database table. //from w ww.j av a 2s . c o m * @param csvFile {@link String} Input CSV file * @param tableName {@link String} Database table name to import data * @param truncateBeforeLoad {@link boolean} Truncate the table before inserting * new records. * @param destinationColumns {@link String[]} Array containing the destination columns */ public void loadCSV(String csvFile, String tableName, boolean truncateBeforeLoad, String[] destinationColumns, List columnsToBeMapped) throws Exception { CSVReader csvReader = null; if (null == this.connection) { throw new Exception("Not a valid connection."); } try { csvReader = new CSVReader(new FileReader(csvFile), this.seprator); } catch (Exception e) { String stacktrace = org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e); JOptionPane.showMessageDialog(null, "Error occured while executing file. Error Details: " + stacktrace, "File Error", JOptionPane.ERROR_MESSAGE); throw new Exception("Error occured while executing file. " + stacktrace); } String[] headerRow = csvReader.readNext(); if (null == headerRow) { throw new FileNotFoundException( "No columns defined in given CSV file." + "Please check the CSV file format."); } //Get indices of columns to be mapped List mapColumnsIndices = new ArrayList(); for (Object o : columnsToBeMapped) { String column = (String) o; column = column.substring(column.lastIndexOf(".") + 1, column.length()); int i; for (i = 0; i < headerRow.length; i++) { if (headerRow[i].equals(column)) { mapColumnsIndices.add(i); } } } String questionmarks = StringUtils.repeat("?,", headerRow.length); questionmarks = (String) questionmarks.subSequence(0, questionmarks.length() - 1); String query = SQL_INSERT.replaceFirst(TABLE_REGEX, tableName); query = query.replaceFirst(KEYS_REGEX, StringUtils.join(destinationColumns, ",")); query = query.replaceFirst(VALUES_REGEX, questionmarks); String log_query = query.substring(0, query.indexOf("VALUES(")); String[] nextLine; Connection con = null; PreparedStatement ps = null; PreparedStatement ps2 = null; PreparedStatement reader = null; ResultSet rs = null; try { con = this.connection; con.setAutoCommit(false); ps = con.prepareStatement(query); File file = new File("sqlite/db"); if (!file.exists()) { file.createNewFile(); } db = new SQLiteConnection(file); db.open(true); //if destination table==person, also add an entry in the table person_identifier //get column indices for the person_id and uuid columns int person_id_column_index = -1; int uuid_column_index = -1; int maxLength = 100; int firstname_index = -1; int middlename_index = -1; int lastname_index = -1; int clanname_index = -1; int othername_index = -1; if (tableName.equals("person")) { int i; ps2 = con.prepareStatement( "insert ignore into person_identifier(person_id,identifier_type_id,identifier) values(?,?,?)"); for (i = 0; i < headerRow.length; i++) { if (headerRow[i].equals("person_id")) { person_id_column_index = i; } if (headerRow[i].equals("uuid")) { uuid_column_index = i; } /*if(headerRow[i].equals("first_name")){ System.out.println("Found firstname index: " + i); firstname_index=i; } if(headerRow[i].equals("middle_name")){ System.out.println("Found firstname index: " + i); middlename_index=i; } if(headerRow[i].equals("last_name")){ System.out.println("Found firstname index: " + i); lastname_index=i; } if(headerRow[i].equals("clan_name")){ System.out.println("Found firstname index: " + i); clanname_index=i; } if(headerRow[i].equals("other_name")){ System.out.println("Found firstname index: " + i); othername_index=i; }*/ } } if (truncateBeforeLoad) { //delete data from table before loading csv try (Statement stmnt = con.createStatement()) { stmnt.execute("DELETE FROM " + tableName); stmnt.close(); } } if (tableName.equals("person")) { try (Statement stmt2 = con.createStatement()) { stmt2.execute( "ALTER TABLE person CHANGE COLUMN first_name first_name VARCHAR(50) NULL DEFAULT NULL AFTER person_guid,CHANGE COLUMN middle_name middle_name VARCHAR(50) NULL DEFAULT NULL AFTER first_name,CHANGE COLUMN last_name last_name VARCHAR(50) NULL DEFAULT NULL AFTER middle_name;"); stmt2.close(); } } final int batchSize = 1000; int count = 0; Date date = null; while ((nextLine = csvReader.readNext()) != null) { if (null != nextLine) { int index = 1; int person_id = -1; String uuid = ""; int identifier_type_id = 3; if (tableName.equals("person")) { reader = con.prepareStatement( "select identifier_type_id from identifier_type where identifier_type_name='UUID'"); rs = reader.executeQuery(); if (!rs.isBeforeFirst()) { //no uuid row //insert it Integer numero = 0; Statement stmt = con.createStatement(); numero = stmt.executeUpdate( "insert into identifier_type(identifier_type_id,identifier_type_name) values(50,'UUID')", Statement.RETURN_GENERATED_KEYS); ResultSet rs2 = stmt.getGeneratedKeys(); if (rs2.next()) { identifier_type_id = rs2.getInt(1); } rs2.close(); stmt.close(); } else { while (rs.next()) { identifier_type_id = rs.getInt("identifier_type_id"); } } } int counter = 1; String temp_log = log_query + "VALUES("; //string to be logged for (String string : nextLine) { //if current index is in the list of columns to be mapped, we apply that mapping for (Object o : mapColumnsIndices) { int i = (int) o; if (index == (i + 1)) { //apply mapping to this column string = applyDataMapping(string); } } if (tableName.equals("person")) { //get person_id and uuid if (index == (person_id_column_index + 1)) { person_id = Integer.parseInt(string); } if (index == (uuid_column_index + 1)) { uuid = string; } } //check if string is a date if (string.matches("\\d{2}-[a-zA-Z]{3}-\\d{4} \\d{2}:\\d{2}:\\d{2}") || string.matches("\\d{2}-[a-zA-Z]{3}-\\d{4}")) { java.sql.Date dt = formatDate(string); temp_log = temp_log + "'" + dt.toString() + "'"; ps.setDate(index++, dt); } else { if ("".equals(string)) { temp_log = temp_log + "''"; ps.setNull(index++, Types.NULL); } else { temp_log = temp_log + "'" + string + "'"; ps.setString(index++, string); } } if (counter < headerRow.length) { temp_log = temp_log + ","; } else { temp_log = temp_log + ");"; System.out.println(temp_log); } counter++; } if (tableName.equals("person")) { if (!"".equals(uuid) && person_id != -1) { ps2.setInt(1, person_id); ps2.setInt(2, identifier_type_id); ps2.setString(3, uuid); ps2.addBatch(); } } ps.addBatch(); } if (++count % batchSize == 0) { ps.executeBatch(); if (tableName.equals("person")) { ps2.executeBatch(); } } } ps.executeBatch(); // insert remaining records if (tableName.equals("person")) { ps2.executeBatch(); } con.commit(); } catch (Exception e) { if (con != null) con.rollback(); if (db != null) db.dispose(); String stacktrace = org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e); JOptionPane.showMessageDialog(null, "Error occured while executing file. Error Details: " + stacktrace, "File Error", JOptionPane.ERROR_MESSAGE); throw new Exception("Error occured while executing file. " + stacktrace); } finally { if (null != reader) reader.close(); if (null != ps) ps.close(); if (null != ps2) ps2.close(); if (null != con) con.close(); csvReader.close(); } }
From source file:de.jaetzold.networking.SimpleServiceDiscovery.java
/** * Comma separated List of IP adresses of available network interfaces * @param useIPv4// ww w. j a va 2 s . co m * @return */ public static String getIPAddress(boolean useIPv4) { String addresses = ""; try { List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface intf : interfaces) { List<InetAddress> addrs = Collections.list(intf.getInetAddresses()); for (InetAddress addr : addrs) { if (!addr.isLoopbackAddress()) { String sAddr = addr.getHostAddress().toUpperCase(); boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr); if (useIPv4) { if (isIPv4) addresses += sAddr + ", "; } else { if (!isIPv4) { int delim = sAddr.indexOf('%'); // drop ip6 port suffix if (delim < 0) addresses += sAddr + ", "; else addresses += sAddr.substring(0, delim) + ", "; } } } } } } catch (Exception ex) { } // for now eat exceptions if (addresses == null || addresses.length() <= 3) return ""; return addresses.subSequence(0, addresses.length() - 2).toString(); }
From source file:org.kew.rmf.core.lucene.LuceneUtils.java
public static String buildQuery(List<Property> properties, Map<String, String> map, boolean dedupl) { StringBuffer sb = new StringBuffer(); if (dedupl) { // Be sure not to return self: sb.append("NOT " + Configuration.ID_FIELD_NAME + ":" + map.get(Configuration.ID_FIELD_NAME)); }//from w ww . j a v a2 s . c o m for (Property p : properties) { if (p.isUseInSelect() || p.isUseInNegativeSelect()) { String authorityName = p.getAuthorityColumnName() + Configuration.TRANSFORMED_SUFFIX; String value = map.get(p.getQueryColumnName() + Configuration.TRANSFORMED_SUFFIX); // super-csv treats blank as null, we don't for now value = (value != null) ? value : ""; String quotedValue = "\"" + value + "\""; if (p.isUseInSelect()) { if (StringUtils.isNotBlank(value)) { if (p.getMatcher().isExact()) { if (sb.length() > 0) sb.append(" AND "); sb.append(authorityName + ":" + quotedValue); } if (p.isIndexLength()) { int low = Math.max(0, value.length() - 2); int high = value.length() + 2; if (sb.length() > 0) sb.append(" AND "); sb.append(authorityName).append(Configuration.LENGTH_SUFFIX); sb.append(String.format(":[%02d TO %02d]", low, high)); } if (p.isIndexInitial()) { if (sb.length() > 0) sb.append(" AND "); sb.append(authorityName).append(Configuration.INITIAL_SUFFIX).append(':') .append(quotedValue.substring(0, 2)).append('"'); } if (p.isUseWildcard()) { if (sb.length() > 0) sb.append(" AND "); sb.append(authorityName).append(":") .append(quotedValue.subSequence(0, quotedValue.length() - 1)).append("~0.5\""); } } } else { // isUseInNegativeSelect if (StringUtils.isNotBlank(value)) { if (sb.length() > 0) { sb.append(" AND"); } sb.append(" NOT " + authorityName + ":" + quotedValue); } } } } return sb.toString(); }