当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.join方法代码示例

本文整理汇总了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, ',') + "]");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:WordListAnonymizerUtility.java

示例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));
		}
	};
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:27,代码来源:Filters.java

示例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);
    }
}
 
开发者ID:wenweihu86,项目名称:distmq,代码行数:28,代码来源:MetadataManager.java

示例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);
    }
}
 
开发者ID:zhangyingwei,项目名称:cockroach,代码行数:10,代码来源:Task.java

示例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");
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:9,代码来源:TileEntityCommand.java

示例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);
    }
}
 
开发者ID:cmb9400,项目名称:skip-assistant,代码行数:36,代码来源:SpotifyPollingService.java

示例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, " ");
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:8,代码来源:ColladaSerializer.java

示例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);
}
 
开发者ID:personium,项目名称:personium-core,代码行数:15,代码来源:UrlUtils.java

示例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);
       }
}
 }
 
开发者ID:BriData,项目名称:DBus,代码行数:14,代码来源:MysqlDefaultProcessor.java

示例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, " ");
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:8,代码来源:ColladaSerializer.java

示例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)
    }, ',');
}
 
开发者ID:Lolmewn,项目名称:Stats4,代码行数:7,代码来源:PlaytimeStat.java

示例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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:65,代码来源:AbstractCSQueue.java

示例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, ","));
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:58,代码来源:ManifestHelper.java

示例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);
		}
	}
}
 
开发者ID:dev-share,项目名称:database-transform-tool,代码行数:81,代码来源:ManageTable.java

示例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;
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:49,代码来源:KalturaAPIServiceStub.java


注:本文中的org.apache.commons.lang.StringUtils.join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。