本文整理匯總了Java中org.apache.commons.lang.StringUtils.join方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.join方法的具體用法?Java StringUtils.join怎麽用?Java StringUtils.join使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.StringUtils
的用法示例。
在下文中一共展示了StringUtils.join方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: extractSuffix
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* Extracts a known suffix from the given data.
*
* @throws RuntimeException if the data doesn't have a suffix.
* Use {@link #hasSuffix(String, String[])} to make sure that the
* given data has a suffix.
*/
public static String[] extractSuffix(String data, String[] suffixes) {
// check if they end in known suffixes
String suffix = "";
for (String ks : suffixes) {
if (data.endsWith(ks)) {
suffix = ks;
// stripe off the suffix which will get appended later
data = data.substring(0, data.length() - suffix.length());
return new String[] {data, suffix};
}
}
// throw exception
throw new RuntimeException("Data [" + data + "] doesn't have a suffix from"
+ " known suffixes [" + StringUtils.join(suffixes, ',') + "]");
}
示例2: and
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/** Produces the conjunction of the given filters.
*
* @param <T> the type of objects that the filters deal with.
* @param f the filters.
* @return the conjunction.
*/
@SafeVarargs
public static<T> Filter<T> and(final Filter<T>... f) {
return new Filter<T>() {
@Override
public boolean apply(final T x) {
for (final Filter<T> filter: f) if (! filter.apply(x)) return false;
return true;
}
@Override
public String toString() {
return "(" + StringUtils.join(f, " and ") + ")";
}
@Override
public Filter<T> copy() {
return Filters.and(Filters.copy(f));
}
};
}
示例3: subscribeBroker
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public void subscribeBroker() {
try {
final String brokerParentPath = zkConf.getZKBasePath() + "/brokers";
List<String> shardings = zkClient.getChildren().forPath(brokerParentPath);
for (String sharding : shardings) {
final int shardingId = Integer.valueOf(sharding);
final String shardingPath = brokerParentPath + "/" + sharding;
List<String> brokerAddressList = zkClient.getChildren().forPath(shardingPath);
if ((isProducer || isConsumer) && CollectionUtils.isNotEmpty(brokerAddressList)) {
BrokerClient brokerClient = new BrokerClient(brokerAddressList, rpcClientOptions);
BrokerClient oldBrokerClient = metadata.getBrokerMap().putIfAbsent(shardingId, brokerClient);
if (oldBrokerClient != null) {
oldBrokerClient.getRpcClient().stop();
String oldIpPorts = StringUtils.join(oldBrokerClient.getAddressList(), ",");
metadata.getBrokerMap().get(shardingId).getRpcClient().addEndPoints(oldIpPorts);
}
}
// 監聽broker分片變化
zkClient.getChildren().usingWatcher(new BrokerShardingWather(shardingId)).forPath(shardingPath);
}
// 監聽/brokers孩子節點變化
zkClient.getChildren().usingWatcher(new BrokersWatcher()).forPath(brokerParentPath);
} catch (Exception ex) {
LOG.warn("subscribeBroker exception:", ex);
}
}
示例4: getUrl
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public String getUrl() {
if (this.getParams().isEmpty()) {
return url;
} else {
List<String> paramsList = this.getParams().entrySet().stream().map(entity -> String.format("%s=%s", entity.getKey(), entity.getValue())).collect(Collectors.toList());
String param = StringUtils.join(paramsList.toArray(), "&");
return String.format("%s?%s", url, param);
}
}
示例5: TileEntityCommand
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public TileEntityCommand()
{
super("cauldron_te");
this.description = "Toggle certain TileEntity options";
this.usageMessage = "/cauldron_te [" + StringUtils.join(COMMANDS, '|') + "] <option> [value]";
this.setPermission("cauldron.command.cauldron_te");
}
示例6: checkSkipped
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* determine if a song was skipped and if so, save it to the repository
* @param prevSong
* @param nextSong
*/
private void checkSkipped(CurrentlyPlayingTrack prevSong, CurrentlyPlayingTrack nextSong)
throws WebApiException, IOException {
// find which songs were skipped and save them to the repository
if (spotifyHelperService.wasSkipped(prevSong, nextSong) &&
spotifyHelperService.isValidPlaylistTrack(prevSong, user)) {
String userId = user.getId();
String songUri = prevSong.getItem().getUri();
String songName = prevSong.getItem().getName();
List<String> artistList = prevSong.getItem().getArtists().stream().map(x -> x.getName()).collect(Collectors.toList());
String songArtistNames = songName + " - " + StringUtils.join(artistList, ", ");
String playlistHref = prevSong.getContext().getHref();
String playlistId = playlistHref.substring(playlistHref.lastIndexOf("/") + 1, playlistHref.length());
String playlistName = api.getPlaylist(userId, playlistId).build().get().getName();
String previewUrl = api.getTrack(songUri.split(":")[2]).build().get().getPreviewUrl();
if (previewUrl.equals("null")) {
previewUrl = null;
}
LOGGER.info("Skipped song detected! \n "
+ userId + " skipped " + songName
+ "\n in playlist " + playlistName);
skippedTrackRepository.insertOrUpdateCount(1, playlistId, songUri, userId, songArtistNames, playlistName, previewUrl);
}
}
示例7: byteBufferToIntPointSpaceDelimitedString
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private String byteBufferToIntPointSpaceDelimitedString(ByteBuffer buffer) {
// Prepare to store integers as a list of strings.
List<String> stringScalars = intBufferToStringList(buffer, intFormat);
// Send back a space-delimited list of the strings: 1 2 0
return StringUtils.join(stringScalars, " ");
}
示例8: box
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* BOXアクセス.
* @param cellName セル名
* @param boxName ボックス名
* @param pathInBox ボックス內パス
* @return 認証エンドポイントURL
*/
public static String box(final String cellName, final String boxName, final String... pathInBox) {
String path = "";
if (pathInBox != null) {
path = StringUtils.join(pathInBox, "/");
}
return String.format("%s/%s/%s/%s", baseUrl, cellName, boxName, path);
}
示例9: dataFilter
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
private void dataFilter(List<MessageEntry> msgEntryLst) {
// 過濾掉沒有在係統中配置的表或者沒有經過拉全量的表的數據
for(Iterator<MessageEntry> it = msgEntryLst.iterator(); it.hasNext(); ){
EntryHeader header = it.next().getEntryHeader();
String schemaName = header.getSchemaName();
String tableName = header.getTableName();
String key = StringUtils.join(new String[]{schemaName,tableName}, ".");
if (ThreadLocalCache.get(Constants.CacheNames.DATA_TABLES, key) == null) {
it.remove();
logger.info("The message of {} was filtered, the data table is not configured", tableName);
}
}
}
示例10: doubleBufferToFloatingPointSpaceDelimitedString
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private String doubleBufferToFloatingPointSpaceDelimitedString(DoubleBuffer buffer) {
// For each scalar in the buffer, turn it into a string, adding it to the overall list.
List<String> stringScalars = doubleBufferToStringList(buffer, decimalFormat);
// Send back a space-delimited list of the strings: 1 2.45 0
return StringUtils.join(stringScalars, " ");
}
示例11: generateLocationString
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public String generateLocationString() {
return StringUtils.join(new String[]{
this.locWorld, Integer.toString(this.locX), Integer.toString(this.locY), Integer.toString(this.locZ),
Float.toString(this.locYaw), Float.toString(this.locPitch)
}, ',');
}
示例12: setupQueueConfigs
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
synchronized void setupQueueConfigs(Resource clusterResource)
throws IOException {
// get labels
this.accessibleLabels =
csContext.getConfiguration().getAccessibleNodeLabels(getQueuePath());
this.defaultLabelExpression = csContext.getConfiguration()
.getDefaultNodeLabelExpression(getQueuePath());
// inherit from parent if labels not set
if (this.accessibleLabels == null && parent != null) {
this.accessibleLabels = parent.getAccessibleNodeLabels();
}
// inherit from parent if labels not set
if (this.defaultLabelExpression == null && parent != null
&& this.accessibleLabels.containsAll(parent.getAccessibleNodeLabels())) {
this.defaultLabelExpression = parent.getDefaultNodeLabelExpression();
}
// After we setup labels, we can setup capacities
setupConfigurableCapacities();
this.maximumAllocation =
csContext.getConfiguration().getMaximumAllocationPerQueue(
getQueuePath());
authorizer = YarnAuthorizationProvider.getInstance(csContext.getConf());
this.state = csContext.getConfiguration().getState(getQueuePath());
this.acls = csContext.getConfiguration().getAcls(getQueuePath());
// Update metrics
CSQueueUtils.updateQueueStatistics(
resourceCalculator, this, parent,
labelManager.getResourceByLabel(RMNodeLabelsManager.NO_LABEL, clusterResource), minimumAllocation);
// Check if labels of this queue is a subset of parent queue, only do this
// when we not root
if (parent != null && parent.getParent() != null) {
if (parent.getAccessibleNodeLabels() != null
&& !parent.getAccessibleNodeLabels().contains(RMNodeLabelsManager.ANY)) {
// if parent isn't "*", child shouldn't be "*" too
if (this.getAccessibleNodeLabels().contains(RMNodeLabelsManager.ANY)) {
throw new IOException("Parent's accessible queue is not ANY(*), "
+ "but child's accessible queue is *");
} else {
Set<String> diff =
Sets.difference(this.getAccessibleNodeLabels(),
parent.getAccessibleNodeLabels());
if (!diff.isEmpty()) {
throw new IOException("Some labels of child queue is not a subset "
+ "of parent queue, these labels=["
+ StringUtils.join(diff, ",") + "]");
}
}
}
}
this.reservationsContinueLooking = csContext.getConfiguration()
.getReservationContinueLook();
this.preemptionDisabled = isQueueHierarchyPreemptionDisabled(this);
this.cr = clusterResource;
}
示例13: checkManifest
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public static boolean checkManifest(AppVariantContext appVariantContext, File fullManifest,
AtlasDependencyTree dependencyTree,
AtlasExtension atlasExtension) throws DocumentException {
Set<String> notMergedArtifacts = getNotMergedBundles(atlasExtension);
BundleInfo mainBundleInfo = new BundleInfo();
collectBundleInfo(appVariantContext, mainBundleInfo, fullManifest, null);
List<String> errors = new ArrayList<>();
for (AwbBundle awbBundle : dependencyTree.getAwbBundles()) {
String cord = String.format("%s:%s",
awbBundle.getResolvedCoordinates().getGroupId(),
awbBundle.getResolvedCoordinates().getArtifactId());
if (null != notMergedArtifacts && notMergedArtifacts.contains(cord)) {
continue;
}
for (String activity : awbBundle.bundleInfo.getActivities()) {
if (StringUtils.isNotEmpty(activity) && !mainBundleInfo.getActivities().contains(activity)) {
errors.add("miss activity:" + activity);
}
}
for (String service : awbBundle.bundleInfo.getServices()) {
if (StringUtils.isNotEmpty(service) && !mainBundleInfo.getServices().contains(service)) {
errors.add("miss service:" + service);
}
}
if (!atlasExtension.getManifestOptions().isRemoveProvider()) {
for (String provider : awbBundle.bundleInfo.getContentProviders()) {
if (StringUtils.isNotEmpty(provider) && !mainBundleInfo.getContentProviders().contains(provider)) {
errors.add("miss provider:" + provider);
}
}
}
for (String receiver : awbBundle.bundleInfo.getReceivers()) {
if (StringUtils.isNotEmpty(receiver) && !mainBundleInfo.getReceivers().contains(receiver)) {
errors.add("miss receiver:" + receiver);
}
}
}
if (errors.isEmpty()) {
return true;
}
for (String err : errors) {
sLogger.error(err);
}
throw new GradleException("manifest merge error :" + StringUtils.join(errors, ","));
}
示例14: mongodb2greenplum
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* @decription 數據同步(MongoDB-->Greenplum)
* @author yi.zhang
* @time 2017年8月4日 下午5:26:59
* @param source 數據源
* @param target 目標庫
* @param mapper 表映射
* @param filter_columns 字段過濾
*/
protected void mongodb2greenplum(Config source,Config target,Map<String,String> mapper,List<String> filter_columns){
if(source==null||target==null){
return;
}
MongoDBFactory factory = new MongoDBFactory();
factory.init(source.getServers(), source.getDatabase(), source.getSchema(), source.getUsername(), source.getPassword());
Map<String,String> mapping = new HashMap<String,String>();
if(mapper==null||mapper.size()==0){
List<String> tables = factory.queryTables();
for (String table : tables) {
mapping.put(table, table);
}
}else{
mapping = mapper;
}
GreenplumFactory tfactory = new GreenplumFactory();
tfactory.init(target.getServers(), target.getDatabase(), target.getSchema(), target.getUsername(), target.getPassword(), true, 100, 10);
List<String> stables = factory.queryTables();
List<String> ttables = tfactory.queryTables();
for(String stable : mapping.keySet()){
String ttable = mapping.get(stable);
if(!(stables.contains(stable)&&ttables.contains(ttable))){
System.out.println("--數據表["+stable+"]或目標表["+ttable+"]不存在--");
continue;
}
Map<String,String> reflect = new LinkedHashMap<String,String>();
Map<String, String> scolumns = factory.queryColumns(stable);
Map<String, String> tcolumns = tfactory.queryColumns(ttable);
if(scolumns==null||scolumns.isEmpty()||tcolumns==null||tcolumns.isEmpty()){
System.out.println("--數據表["+stable+"]或目標表["+ttable+"]無合適字段--");
continue;
}
for(String scolumn:scolumns.keySet()){
String s_column = scolumn.trim().toLowerCase().replaceAll("(_+?|-+?)", "");
if(filter_columns!=null&&(filter_columns.contains(scolumn)||filter_columns.contains(s_column))){
continue;
}
for(String tcolumn:tcolumns.keySet()){
String t_column = tcolumn.trim().toLowerCase().replaceAll("(_+?|-+?)", "");
if(filter_columns!=null&&(filter_columns.contains(tcolumn)||filter_columns.contains(t_column))){
continue;
}
if(scolumn.equalsIgnoreCase(tcolumn)||scolumn.equalsIgnoreCase(t_column)||s_column.equalsIgnoreCase(tcolumn)||s_column.equalsIgnoreCase(t_column)){
reflect.put(scolumn, tcolumn);
}
}
}
if(reflect.isEmpty()){
System.out.println("--數據表["+stable+"]或目標表["+ttable+"]無對應字段--");
continue;
}
List<?> datas = factory.executeQuery(stable, null, null);
System.out.println("--數據表["+stable+"]數據量:"+datas.size());
for (Object data : datas) {
Map<String,Object> tdata = new LinkedHashMap<String,Object>();
JSONObject json = (JSONObject)data;
for(String key:json.keySet()){
Object value = json.get(key);
if(value instanceof Date){
value = DateUtil.formatDateTimeStr((Date)value);
}
if(value instanceof String){
value = "\""+json.getString(key)+"\"";
}
tdata.replace(reflect.get(key), value);
}
String sql = "insert into "+ttable+"("+StringUtils.join(tdata.keySet(), ",")+")values("+StringUtils.join(tdata.values(), ",")+")";
tfactory.executeUpdate(sql);
}
}
}
示例15: removeItemFromKalturaPlaylist
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
@Override
protected boolean removeItemFromKalturaPlaylist(KalturaPlaylist playlist, String kalturaId) {
if (playlist == null) {
throw new IllegalArgumentException("playlist is not set");
}
if (StringUtils.isEmpty(kalturaId)) {
throw new IllegalArgumentException("kaltura entry id is not set");
}
boolean removed = false;
if (playlist.playlistContent != null) {
// must create a mutable ArrayList in order to remove item here
List<String> entries = new ArrayList<String>(Arrays.asList(StringUtils.splitByWholeSeparator(playlist.playlistContent, ",")));
boolean changed = entries.remove(kalturaId);
if (changed) {
MediaCollection mc = null;
if (entries.isEmpty()) {
entries.add(KalturaAPIService.DEFAULT_PLAYLIST_EMPTY);
} else {
KalturaPlaylist newPlaylist = new KalturaPlaylist();
newPlaylist.playlistContent = StringUtils.join(entries, ",");
// get the collection
for (Iterator<MediaCollection> mci = mockCollections.iterator();mci.hasNext();) {
MediaCollection mediaCollection = mci.next();
if (StringUtils.equals(mediaCollection.getIdStr(), playlist.id)) {
mc = mediaCollection;
break;
}
}
}
// add the items to the collection
if (mc != null) {
// create list of media items to add to collection
List<MediaItem> mediaItems = new ArrayList<MediaItem>();
for (String entry : entries) {
for (MediaItem mi : mockItems) {
if (StringUtils.equals(mi.getIdStr(), entry)) {
mediaItems.add(mi);
break;
}
}
}
mc.setItems(mediaItems);
}
removed = true;
}
}
return removed;
}