org.apache.commons.text.TextStringBuilder Java Examples
The following examples show how to use
org.apache.commons.text.TextStringBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreateIndexTransaction.java From Plan with GNU Lesser General Public License v3.0 | 6 votes |
private void createIndex(String tableName, String indexName, String... indexedColumns) { if (indexedColumns.length == 0) { throw new IllegalArgumentException("Can not create index without columns"); } boolean isMySQL = dbType == DBType.MYSQL; if (isMySQL) { boolean indexExists = query(MySQLSchemaQueries.doesIndexExist(indexName, tableName)); if (indexExists) return; } TextStringBuilder sql = new TextStringBuilder("CREATE INDEX "); if (!isMySQL) { sql.append("IF NOT EXISTS "); } sql.append(indexName).append(" ON ").append(tableName); sql.append(" ("); sql.appendWithSeparators(indexedColumns, ","); sql.append(')'); execute(sql.toString()); }
Example #2
Source File: ItemNameFormatter.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
@Override public String apply(String name) { String[] parts = StringUtils.split(name, '_'); TextStringBuilder builder = new TextStringBuilder(); builder.appendWithSeparators(Arrays.stream(parts).map(part -> new Format(part).capitalize()).iterator(), " "); return builder.toString(); }
Example #3
Source File: ParquetMetadataCommand.java From parquet-mr with Apache License 2.0 | 5 votes |
private void printRowGroup(Logger console, int index, BlockMetaData rowGroup, MessageType schema) { long start = rowGroup.getStartingPos(); long rowCount = rowGroup.getRowCount(); long compressedSize = rowGroup.getCompressedSize(); long uncompressedSize = rowGroup.getTotalByteSize(); String filePath = rowGroup.getPath(); console.info(String.format("\nRow group %d: count: %d %s records start: %d total: %s%s\n%s", index, rowCount, humanReadable(((float) compressedSize) / rowCount), start, humanReadable(compressedSize), filePath != null ? " path: " + filePath : "", new TextStringBuilder(80).appendPadding(80, '-'))); int size = maxSize(Iterables.transform(rowGroup.getColumns(), new Function<ColumnChunkMetaData, String>() { @Override public String apply(@Nullable ColumnChunkMetaData input) { return input == null ? "" : input.getPath().toDotString(); } })); console.info(String.format("%-" + size + "s %-9s %-9s %-9s %-10s %-7s %s", "", "type", "encodings", "count", "avg size", "nulls", "min / max")); for (ColumnChunkMetaData column : rowGroup.getColumns()) { printColumnChunk(console, size, column, schema); } }
Example #4
Source File: PersistenceManager.java From cuba with Apache License 2.0 | 5 votes |
@Authenticated @Override public String jpqlLoadList(String queryString) { try { Transaction tx = persistence.createTransaction(); try { EntityManager em = persistence.getEntityManager(); Query query = em.createQuery(queryString); QueryParser parser = QueryTransformerFactory.createParser(queryString); Set<String> paramNames = parser.getParamNames(); for (String paramName : paramNames) { security.setQueryParam(query, paramName); } List resultList = query.getResultList(); tx.commit(); TextStringBuilder sb = new TextStringBuilder(); for (Object element : resultList) { if (element instanceof Object[]) { sb.appendWithSeparators((Object[]) element, " | "); } else { sb.append(element); } sb.append("\n"); } return sb.toString(); } finally { tx.end(); } } catch (Throwable e) { log.error("jpqlLoadList error", e); return ExceptionUtils.getStackTrace(e); } }
Example #5
Source File: Param.java From cuba with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected void setValue(@Nullable Object value, boolean updateEditComponent) { if (!Objects.equals(value, this.value)) { Object prevValue = this.value; this.value = value; if (updateEditComponent && this.editComponent instanceof HasValue) { if (editComponent instanceof TextField) { TextField textField = (TextField) this.editComponent; if (value instanceof Collection) { //if the value type is an array and the editComponent is a textField ('IN' condition for String attribute) //then we should set the string value (not the array) to the text field String caption = new TextStringBuilder().appendWithSeparators((Collection) value, ",").toString(); textField.setValue(caption); } else { textField.setValue(value); } } else { ((HasValue) editComponent).setValue(value); } } getEventHub().publish(ParamValueChangedEvent.class, new ParamValueChangedEvent(this, prevValue, value)); } }
Example #6
Source File: ConfigStorageCommon.java From cuba with Apache License 2.0 | 5 votes |
public String printAppProperties(String prefix) { List<String> list = new ArrayList<>(); for (String name : AppContext.getPropertyNames()) { if (prefix == null || name.startsWith(prefix)) { list.add(name + "=" + AppContext.getProperty(name)); } } Collections.sort(list); return new TextStringBuilder().appendWithSeparators(list, "\n").toString(); }
Example #7
Source File: AbstractMessages.java From cuba with Apache License 2.0 | 5 votes |
@Nullable protected String searchMessage(String packs, String key, Locale locale, Locale truncatedLocale, Set<String> passedPacks) { StringTokenizer tokenizer = new StringTokenizer(packs); //noinspection unchecked List<String> list = tokenizer.getTokenList(); Collections.reverse(list); for (String pack : list) { if (!enterPack(pack, locale, truncatedLocale, passedPacks)) continue; String msg = searchOnePack(pack, key, locale, truncatedLocale, passedPacks); if (msg != null) return msg; Locale tmpLocale = truncatedLocale; while (tmpLocale != null) { tmpLocale = truncateLocale(tmpLocale); msg = searchOnePack(pack, key, locale, tmpLocale, passedPacks); if (msg != null) return msg; } } if (log.isTraceEnabled()) { String packName = new TextStringBuilder().appendWithSeparators(list, ",").toString(); log.trace("Resource '{}' not found", makeCacheKey(packName, key, locale, locale)); } return null; }
Example #8
Source File: RequestHandler.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private Map<String, String> getRequestHeaders(HttpExchange exchange) { Map<String, String> headers = new HashMap<>(); for (Map.Entry<String, List<String>> e : exchange.getResponseHeaders().entrySet()) { List<String> value = e.getValue(); headers.put(e.getKey(), new TextStringBuilder().appendWithSeparators(value, ";").build()); } return headers; }
Example #9
Source File: ResourceSvc.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void addStylesToResource(String pluginName, String fileName, Position position, String... cssSrcs) { checkParams(pluginName, fileName, position, cssSrcs); String snippet = new TextStringBuilder("<link href=\"") .appendWithSeparators(cssSrcs, "\" rel=\"stylesheet\"></link><link href=\"") .append("\" rel=\"stylesheet\">").build(); snippets.add(new Snippet(pluginName, fileName, position, snippet)); if (!"Plan".equals(pluginName)) { logger.info(locale.getString(PluginLang.API_ADD_RESOURCE_CSS, pluginName, fileName, position.cleanName())); } }
Example #10
Source File: ResourceSvc.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void addScriptsToResource(String pluginName, String fileName, Position position, String... jsSrcs) { checkParams(pluginName, fileName, position, jsSrcs); String snippet = new TextStringBuilder("<script src=\"") .appendWithSeparators(jsSrcs, "\"></script><script src=\"") .append("\"></script>").build(); snippets.add(new Snippet(pluginName, fileName, position, snippet)); if (!"Plan".equals(pluginName)) { logger.info(locale.getString(PluginLang.API_ADD_RESOURCE_JS, pluginName, fileName, position.cleanName())); } }
Example #11
Source File: CasquatchGenerator.java From casquatch with Apache License 2.0 | 5 votes |
/** * Syntax helper * @return string containing help message */ public static String help() { TextStringBuilder output = new TextStringBuilder(); output.appendln("Casquatch Code Generated"); output.appendln(""); output.appendln("Properties can be provided via the command line via -D parameters"); output.appendln("Properties:"); output.appendln("casquatch.generator.username=<string> -- Authentication Username"); output.appendln("casquatch.generator.password=<string> -- Authentication Password"); output.appendln("casquatch.generator.keyspace=<string> -- Keyspace to parse"); output.appendln("casquatch.generator.datacenter=<string> -- LocalDC for connection"); output.appendln("casquatch.generator.contactPoints.0=<ip0:port>...casquatch.generator.contactPoints.n=<ipn:port> -- List of contact points"); output.appendln("casquatch.generator.tables.0=<table0>...casquatch.generator.tables.n=<tablen> -- Provide a list of tables. All tables are processed if not supplied"); output.appendln("casquatch.generator.console=<boolean> -- Indicate if generated code should be printed to console"); output.appendln("casquatch.generator.file=<boolean> -- Indicate if generated code should be printed to a file"); output.appendln("casquatch.generator.outputFolder=<path> -- Required if file=true. Defines location to write generated files"); output.appendln("casquatch.generator.overwrite=<boolean> -- Toggle overwriting of files in output folder"); output.appendln("casquatch.generator.createPackage=<boolean> -- If createPackage=true then pom.xml and src folder structure will be added |"); output.appendln("casquatch.generator.packageName=<string> -- Package name for source files"); output.appendln("config.file=<path> -- Specify a path to a config file to place parameters"); output.appendln(""); output.appendln("Examples: "); output.appendln(""); output.appendln("Generate using properties file"); output.appendln("java -Dconfig.file=/path/to/config.properties -jar CassandraGenerator.jar"); output.appendln(""); output.appendln("Generate all tables in a keyspace providing minimum information"); output.appendln("java -Dcasquatch.generator.outputFolder=tmp -Dcasquatch.generator.keyspace=myKeyspace -Dcasquatch.generator.datacenter=datacenter1 -jar CassandraGenerator.jar"); output.appendln(""); output.appendln("Generate a package for all tables in a keyspace providing additional information"); output.appendln("java -Dcasquatch.generator.outputFolder=tmp -Dcasquatch.generator.keyspace=myKeyspace -Dcasquatch.generator.datacenter=datacenter1 -Dcasquatch.generator.username=cassandra -Dcasquatch.generator.password=cassandra -Dcasquatch.generator.createPackage=true -Dcasquatch.generator.packageName=com.demo.mykeyspace -jar CassandraGenerator.jar"); return output.toString(); }
Example #12
Source File: TortureTable.java From casquatch with Apache License 2.0 | 5 votes |
/** * Generated: Returns DDL * @return DDL for table */ public static String getDDL() { TextStringBuilder ddl = new TextStringBuilder(); ddl.appendln(Udt.getDDL()); ddl.appendln("CREATE TABLE \"torture_table\" ( \"id\" uuid, \"col_ascii\" ascii, \"col_bigint\" bigint, \"col_blob\" blob, \"col_boolean\" boolean, \"col_date\" date, \"col_decimal\" decimal, \"col_double\" double, \"col_float\" float, \"col_inet\" inet, \"col_int\" int, \"col_list\" list<text>, \"col_map\" map<text, text>, \"col_set\" set<text>, \"col_smallint\" smallint, \"col_text\" text, \"col_time\" time, \"col_timestamp\" timestamp, \"col_timeuuid\" timeuuid, \"col_tinyint\" tinyint, \"col_udt\" frozen<\"junittest\".\"udt\">, \"col_uuid\" uuid, \"col_varchar\" text, \"col_varint\" varint, PRIMARY KEY (\"id\") ) WITH bloom_filter_fp_chance = 0.01 AND caching = {'keys':'ALL','rows_per_partition':'NONE'} AND comment = '' AND compaction = {'class':'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy','max_threshold':'32','min_threshold':'4'} AND compression = {'chunk_length_in_kb':'64','class':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1.0 AND dclocal_read_repair_chance = 0.1 AND default_time_to_live = 0 AND extensions = {} AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 AND read_repair_chance = 0.0 AND speculative_retry = '99PERCENTILE';"); return ddl.toString(); }
Example #13
Source File: TableName.java From casquatch with Apache License 2.0 | 4 votes |
/** * Generated: Returns DDL * @return DDL for table */ public static String getDDL() { TextStringBuilder ddl = new TextStringBuilder(); ddl.appendln("CREATE TABLE \"table_name\" ( \"key_one\" int, \"key_two\" int, \"col_one\" text, \"col_two\" text, PRIMARY KEY (\"key_one\", \"key_two\") ) WITH bloom_filter_fp_chance = 0.01 AND caching = {'keys':'ALL','rows_per_partition':'NONE'} AND comment = '' AND compaction = {'class':'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy','max_threshold':'32','min_threshold':'4'} AND compression = {'chunk_length_in_kb':'64','class':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1.0 AND dclocal_read_repair_chance = 0.1 AND default_time_to_live = 0 AND extensions = {} AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 AND read_repair_chance = 0.0 AND speculative_retry = '99PERCENTILE';"); return ddl.toString(); }
Example #14
Source File: StoreConfigTransaction.java From Plan with GNU Lesser General Public License v3.0 | 4 votes |
private String extractConfigSettingLines(Config config) { TextStringBuilder configTextBuilder = new TextStringBuilder(); List<String> lines = new ConfigWriter().createLines(config); configTextBuilder.appendWithSeparators(lines, "\n"); return configTextBuilder.toString(); }
Example #15
Source File: MetaPropertyPath.java From cuba with Apache License 2.0 | 4 votes |
protected static String getPathString(String[] path) { return new TextStringBuilder() .appendWithSeparators(path, ".") .toString(); }
Example #16
Source File: NodeMetaData.java From casquatch with Apache License 2.0 | 4 votes |
/** * Generated: Returns DDL * @return DDL for table */ public static String getDDL() { TextStringBuilder ddl = new TextStringBuilder(); ddl.appendln("CREATE TABLE \"local\" ( \"key\" text, \"bootstrapped\" text, \"broadcast_address\" inet, \"cluster_name\" text, \"cql_version\" text, \"data_center\" text, \"dse_version\" text, \"gossip_generation\" int, \"graph\" boolean, \"host_id\" uuid, \"listen_address\" inet, \"native_protocol_version\" text, \"partitioner\" text, \"rack\" text, \"release_version\" text, \"rpc_address\" inet, \"schema_version\" uuid, \"server_id\" text, \"thrift_version\" text, \"tokens\" set<text>, \"truncated_at\" map<uuid, blob>, \"workload\" text, \"workloads\" frozen<set<text>>, PRIMARY KEY (\"key\") ) WITH bloom_filter_fp_chance = 0.01 AND caching = {'keys':'ALL','rows_per_partition':'NONE'} AND comment = 'information about the local node' AND compaction = {'class':'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy','max_threshold':'32','min_threshold':'4'} AND compression = {'chunk_length_in_kb':'64','class':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1.0 AND dclocal_read_repair_chance = 0.0 AND default_time_to_live = 0 AND extensions = {} AND gc_grace_seconds = 0 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 3600000 AND min_index_interval = 128 AND read_repair_chance = 0.0 AND speculative_retry = '99PERCENTILE';"); return ddl.toString(); }
Example #17
Source File: ConstraintEditor.java From cuba with Apache License 2.0 | 4 votes |
public void openWizard() { String entityNameValue = entityName.getValue(); if (StringUtils.isBlank(entityNameValue)) { showNotification(getMessage("notification.entityIsEmpty"), NotificationType.HUMANIZED); entityName.focus(); return; } FakeFilterSupport fakeFilterSupport = new FakeFilterSupport(this, metadata.getSession().getClass(entityNameValue)); WindowInfo windowInfo = windowConfig.getWindowInfo("filterEditor"); Map<String, Object> params = new HashMap<>(); Constraint constraint = getItem(); final Filter fakeFilter = fakeFilterSupport.createFakeFilter(); final FilterEntity filterEntity = fakeFilterSupport.createFakeFilterEntity(constraint.getFilterXml()); final ConditionsTree conditionsTree = fakeFilterSupport.createFakeConditionsTree(fakeFilter, filterEntity); params.put("filter", fakeFilter); params.put("filterEntity", filterEntity); params.put("conditionsTree", conditionsTree); params.put("useShortConditionForm", true); params.put("hideDynamicAttributes", constraint.getCheckType() != ConstraintCheckType.DATABASE); params.put("hideCustomConditions", constraint.getCheckType() != ConstraintCheckType.DATABASE); FilterEditor filterEditor = (FilterEditor) getWindowManager().openWindow(windowInfo, OpenType.DIALOG, params); filterEditor.addCloseListener(actionId -> { if (!COMMIT_ACTION_ID.equals(actionId)) return; FilterParser filterParser1 = AppBeans.get(FilterParser.class); //todo eude rename com.haulmont.cuba.gui.components.filter.FilterParser filterEntity.setXml(filterParser1.getXml(filterEditor.getConditions(), Param.ValueProperty.DEFAULT_VALUE)); if (filterEntity.getXml() != null) { Element element = dom4JTools.readDocument(filterEntity.getXml()).getRootElement(); com.haulmont.cuba.core.global.filter.FilterParser filterParser = new com.haulmont.cuba.core.global.filter.FilterParser(element); Constraint item = getItem(); if (item.getCheckType().database()) { String jpql = new SecurityJpqlGenerator().generateJpql(filterParser.getRoot()); constraint.setWhereClause(jpql); Set<String> joins = filterParser.getRoot().getJoins(); if (!joins.isEmpty()) { String joinsStr = new TextStringBuilder().appendWithSeparators(joins, " ").toString(); constraint.setJoinClause(joinsStr); } } if (item.getCheckType().memory()) { String groovy = new GroovyGenerator().generateGroovy(filterParser.getRoot()); constraint.setGroovyScript(groovy); } constraint.setFilterXml(filterEntity.getXml()); } }); }
Example #18
Source File: SimpleTable.java From casquatch with Apache License 2.0 | 4 votes |
/** * Generated: Returns DDL * @return DDL for table */ public static String getDDL() { TextStringBuilder ddl = new TextStringBuilder(); ddl.appendln("CREATE TABLE \"simple_table\" ( \"key_one\" int, \"key_two\" int, \"col_one\" text, \"col_two\" text, \"solr_query\" text, PRIMARY KEY (\"key_one\", \"key_two\") ) WITH bloom_filter_fp_chance = 0.01 AND caching = {'keys':'ALL','rows_per_partition':'NONE'} AND comment = '' AND compaction = {'class':'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy','max_threshold':'32','min_threshold':'4'} AND compression = {'chunk_length_in_kb':'64','class':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1.0 AND dclocal_read_repair_chance = 0.1 AND default_time_to_live = 0 AND extensions = {} AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 AND read_repair_chance = 0.0 AND speculative_retry = '99PERCENTILE';"); return ddl.toString(); }
Example #19
Source File: Configuration.java From casquatch with Apache License 2.0 | 4 votes |
/** * Generated: Returns DDL * @return DDL for table */ public static String getDDL() { TextStringBuilder ddl = new TextStringBuilder(); ddl.appendln("CREATE TABLE \"configuration\" ( \"application\" text, \"profile\" text, \"label\" text, \"key\" text, \"value\" text, PRIMARY KEY ((\"application\", \"profile\"), \"label\", \"key\") ) WITH bloom_filter_fp_chance = 0.01 AND caching = {'keys':'ALL','rows_per_partition':'NONE'} AND comment = '' AND compaction = {'class':'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy','max_threshold':'32','min_threshold':'4'} AND compression = {'chunk_length_in_kb':'64','class':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1.0 AND dclocal_read_repair_chance = 0.1 AND default_time_to_live = 0 AND extensions = {} AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 AND read_repair_chance = 0.0 AND speculative_retry = '99PERCENTILE';"); return ddl.toString(); }