Java Code Examples for org.apache.commons.lang3.StringUtils.join()

The following are Jave code examples for showing how to use join() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: springboot-spwa-gae-demo   File: BaseGaeSearchService.java   View Source Code Vote up 6 votes
protected String convertQueryComponentToQueryFragment(QueryComponent queryComponent) {
    if (!queryComponent.isFieldedQuery()) {
        return queryComponent.getQuery();
    }

    String field = this.getEncodedFieldName(queryComponent.getField());
    if (field == null) {
        throw new SearchException("Unable to build query string - there is no field named '%s' on %s", queryComponent.getField(), type.getSimpleName());
    }
    String operation = IsSymbols.get(queryComponent.getIs());
    if (queryComponent.isCollectionQuery()) {
        List<String> values = convertValuesToString(field, queryComponent.getCollectionValue());
        String stringValue = StringUtils.join(values, " OR ");
        return String.format("%s:(%s)", field, stringValue);
    } else {
        String value = convertValueToString(field, queryComponent.getValue());
        return String.format("%s%s%s", field, operation, value);
    }
}
 
Example 2
Project: bluegreen-manager   File: ArgumentParser.java   View Source Code Vote up 6 votes
/**
 * Parses the given command-line arguments and locally saves the job name and parameters.
 * <p/>
 * Throws if any basic syntax errors.
 */
public void parseArgs(String[] args)
{
  jobName = null;
  parameters = null;
  commandLine = null;
  if (args != null && args.length > 0)
  {
    commandLine = StringUtils.join(args, " ");
    jobName = parseJobName(args[0]);
    parameters = parseParameters(args);
  }
  else
  {
    throw new CmdlineException("Syntax Error: Please specify some arguments");
  }
}
 
Example 3
Project: JAVA-   File: InstanceUtil.java   View Source Code Vote up 6 votes
/**
 * 执行某对象方法
 * 
 * @param owner
 *            对象
 * @param methodName
 *            方法名
 * @param args
 *            参数
 * @return 方法返回值
 */
public static final Object invokeMethod(Object owner, String methodName, Object... args) {
    Class<?> ownerClass = owner.getClass();
    String key = null;
    if (args != null) {
        Class<?>[] argsClass = new Class[args.length];
        for (int i = 0, j = args.length; i < j; i++) {
            if (args[i] != null) {
                argsClass[i] = args[i].getClass();
            }
        }
        key = ownerClass + "_" + methodName + "_" + StringUtils.join(argsClass, ","); // 用于区分重载的方法
    } else {
        key = ownerClass + "_" + methodName; // 用于区分重载的方法
    }
    MethodAccess methodAccess = methodMap.get(key);
    if (methodAccess == null) {
        methodAccess = MethodAccess.get(ownerClass);
        methodMap.put(key, methodAccess); // 缓存Method对象
    }
    return methodAccess.invoke(owner, methodName, args);
}
 
Example 4
Project: xm-commons   File: LogObjectPrinter.java   View Source Code Vote up 6 votes
private static String renderParams(JoinPoint joinPoint, String[] params, String[] includeParamNames,
                                   String[] excludeParamNames, boolean inputCollectionAware) {

    Set<String> includeSet = prepareNameSet(includeParamNames);
    Set<String> excludeSet = prepareNameSet(excludeParamNames);
    List<String> requestList = new ArrayList<>();

    Map<String, Object> paramMap = joinPointToParamMap(joinPoint, params);

    if (!includeSet.isEmpty()) {
        includeSet
            .stream().filter(paramMap::containsKey)
            .forEach(key -> requestList.add(buildParam(key, paramMap.get(key), inputCollectionAware)));
    } else if (!excludeSet.isEmpty()) {
        paramMap.forEach((key, value) -> {
            if (!excludeSet.contains(key)) {
                requestList.add(buildParam(key, value, inputCollectionAware));
            }
        });
    } else {
        paramMap.forEach((key, value) -> requestList.add(buildParam(key, value, inputCollectionAware)));
    }

    return StringUtils.join(requestList, ',');
}
 
Example 5
Project: springboot-spwa-gae-demo   File: BaseGaeSearchService.java   View Source Code Vote up 5 votes
protected String buildQueryString(List<QueryComponent> queryComponents) {
    List<String> stringQueryComponents = new ArrayList<>();
    for (QueryComponent queryComponent : queryComponents) {
        String fragmentString = convertQueryComponentToQueryFragment(queryComponent);
        stringQueryComponents.add(fragmentString);
    }
    return StringUtils.join(stringQueryComponents, " ");
}
 
Example 6
Project: OpenDA   File: D3dWindFile.java   View Source Code Vote up 5 votes
public void initialize(File workingDirectory, String[] arguments) {

		if (arguments.length != 2) {
			// Change to String.join upon migrating to Java 1.8.
			throw new RuntimeException("Please specify a mdf-filename and a wind field type as arguments. Supported types are: " + StringUtils.join(supportedFieldTypes, ", "));
		}

		String mdfFileName = arguments[0];

		fieldType = arguments[1];
		if (!(supportedFieldTypes.contains(fieldType))) {
			// Change to String.join upon migrating to Java 1.8.
			throw new RuntimeException("Unrecognised wind field type specified as argument, choose from: " + StringUtils.join(supportedFieldTypes, ", "));
		}

		modelDefinitionFile = ModelDefinitionFile.getModelDefinitionFile(workingDirectory, mdfFileName);

		File windFile = modelDefinitionFile.getFieldFile(fieldType, true);

		try {
			FileReader fileReader = new FileReader(windFile);
			BufferedReader inputFileBufferedReader = new BufferedReader(fileReader);

			if (fieldType.equals(ModelDefinitionFile.WINDGU)) {
				windExchangeItem = readExchangeItem2D(inputFileBufferedReader, "windgu");
			} else if (fieldType.equals(ModelDefinitionFile.WINDGV)) {
				windExchangeItem = readExchangeItem2D(inputFileBufferedReader, "windgv");
			}else if (fieldType.equals(ModelDefinitionFile.WINDWU)) {
				windExchangeItem = readExchangeItem2D(inputFileBufferedReader, "windu");
			}else if (fieldType.equals(ModelDefinitionFile.WINDWV)) {
				windExchangeItem = readExchangeItem2D(inputFileBufferedReader, "windv");
			}
			inputFileBufferedReader.close();
			fileReader.close();

		} catch (IOException e) {
			throw new RuntimeException("Could not read from " + windFile.getAbsolutePath() + "\n" + e.getMessage());
		}
	}
 
Example 7
Project: circe-be   File: CohortExpressionQueryBuilder.java   View Source Code Vote up 5 votes
private String getCensoringEventsQuery(Criteria[] censoringCriteria)
{
  ArrayList<String> criteriaQueries = new ArrayList<>();
  for (Criteria c : censoringCriteria)    
  {
    String criteriaQuery = c.accept(this);
    criteriaQueries.add(StringUtils.replace(CENSORING_QUERY_TEMPLATE, "@criteriaQuery", criteriaQuery));
  }
  
  return StringUtils.join(criteriaQueries,"\nUNION ALL\n");
}
 
Example 8
Project: Phoenicia   File: LocaleParser.java   View Source Code Vote up 4 votes
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    this.nodeStack.push(localName);
    String nodePath = StringUtils.join(this.nodeStack, '/');
    //Debug.d("Parser start: "+nodePath);

    if (nodePath.equals("/locale")) {
        this.parseLocale(attributes);
    } else if (nodePath.equals("/locale/map")) {
        this.parseMap(attributes);
    } else if (nodePath.equals("/locale/shell")) {
        this.parseShell(attributes);
    } else if (nodePath.equals("/locale/music")) {
        this.parseMusic(attributes);
    } else if (nodePath.equals("/locale/inventory")) {
        this.parseInventory(attributes);
    } else if (nodePath.equals("/locale/market")) {
        this.parseMarket(attributes);
    } else if (nodePath.equals("/locale/workshop")) {
        this.parseWorkshop(attributes);
    } else if (nodePath.equals("/locale/people/person")) {
        this.parsePerson(attributes);
    } else if (nodePath.equals("/locale/games/game")) {
        this.parseGame(attributes);
    } else if (nodePath.equals("/locale/decorations/decoration")) {
        this.parseDecoration(attributes);
    } else if (nodePath.equals("/locale/tour")) {
        this.parseTourGuide(attributes);
    } else if (nodePath.equals("/locale/tour/stop")) {
        this.parseTourStop(attributes);
    } else if (nodePath.equals("/locale/tour/stop/message")) {
        this.parseTourStopMessage(attributes);
    } else if (nodePath.equals("/locale/numbers/number")) {
        this.parseNumberDefinition(attributes);
    } else if (nodePath.equals("/locale/letters/letter")) {
        this.parseLetterDefinition(attributes);
    } else if (nodePath.equals("/locale/words/word")) {
        this.parseWordDefinition(attributes);
    } else if (nodePath.equals("/locale/levels/level")) {
        this.parseLevel(attributes);
    } else if (nodePath.equals("/locale/levels/level/intro/page")) {
        this.parseLevelIntroPage(attributes);
    } else if (nodePath.equals("/locale/levels/level/req/gather_letter")) {
        this.currentReqLetter = new CollectLetterReq();
        this.parseLevelReqLetter(attributes);
    } else if (nodePath.equals("/locale/levels/level/req/gather_word")) {
        this.currentReqWord = new CollectWordReq();
        this.parseLevelReqWord(attributes);
    }
}
 
Example 9
Project: azure-libraries-for-java   File: ResourceId.java   View Source Code Vote up 4 votes
private ResourceId(final String id) {
    if (id == null) {
        // Protect against NPEs from null IDs, preserving legacy behavior for null IDs
        return;
    } else {
        // Skip the first '/' if any, and then split using '/'
        String[] splits = (id.startsWith("/")) ? id.substring(1).split("/") : id.split("/");
        if (splits.length % 2 == 1) {
            throw new InvalidParameterException(badIdErrorText(id));
        }

        // Save the ID itself
        this.id = id;

        // Format of id:
        // /subscriptions/<subscriptionId>/resourceGroups/<resourceGroupName>/providers/<providerNamespace>(/<parentResourceType>/<parentName>)*/<resourceType>/<name>
        //  0             1                2              3                   4         5                                                        N-2            N-1

        // Extract resource type and name
        if (splits.length < 2) {
            throw new InvalidParameterException(badIdErrorText(id));
        } else {
            this.name = splits[splits.length - 1];
            this.resourceType = splits[splits.length - 2];
        }

        // Extract parent ID
        if (splits.length < 10) {
            this.parentId = null;
        } else {
            String[] parentSplits = new String[splits.length - 2];
            System.arraycopy(splits, 0, parentSplits, 0, splits.length - 2);
            this.parentId = "/" + StringUtils.join(parentSplits, "/");
        }

        for (int i = 0; i < splits.length && i < 6; i++) {
            switch (i) {
            case 0:
                // Ensure "subscriptions"
                if (!splits[i].equalsIgnoreCase("subscriptions")) {
                    throw new InvalidParameterException(badIdErrorText(id));
                }
                break;
            case 1:
                // Extract subscription ID
                this.subscriptionId = splits[i];
                break;
            case 2:
                // Ensure "resourceGroups"
                if (!splits[i].equalsIgnoreCase("resourceGroups")) {
                    throw new InvalidParameterException(badIdErrorText(id));
                }
                break;
            case 3:
                // Extract resource group name
                this.resourceGroupName = splits[i];
                break;
            case 4:
                // Ensure "providers"
                if (!splits[i].equalsIgnoreCase("providers")) {
                    throw new InvalidParameterException(badIdErrorText(id));
                }
                break;
            case 5:
                // Extract provider namespace
                this.providerNamespace = splits[i];
                break;
            default:
                break;
            }
        }
    }
}
 
Example 10
Project: Backmemed   File: JsonException.java   View Source Code Vote up 4 votes
public String getJsonKeys()
{
    return StringUtils.join((Iterable)this.jsonKeys, "->");
}
 
Example 11
Project: sierra   File: TabularSequenceSummary.java   View Source Code Vote up 4 votes
/**
 *
 */
public TabularSequenceSummary (List<AlignedSequence> overallResults) {

	for (AlignedSequence alignedSeq : overallResults) {
		List<String> sequenceRecord = new ArrayList<>();

		List<Gene> geneList = alignedSeq.getAvailableGenes();
		MutationSet seqMutations = alignedSeq.getMutations();
		String seqName = alignedSeq.getInputSequence().getHeader();

		tabularResults.put(seqName, new HashMap<String, String>());
		String genes = StringUtils.join(geneList, ",");

		// sequenceName
		sequenceRecord.add(seqName);

		// Genes
		sequenceRecord.add(genes);

		// PRStart, PREnd, RTStart, RTEnd, INStart, INEnd
		sequenceRecord.addAll(determineGeneBoundaries(alignedSeq));

		// Subtype(%)
		sequenceRecord.add(determineSubtype(alignedSeq));

		// PcntMix
		sequenceRecord.add(
			NumberFormats.prettyDecimalAsString(alignedSeq.getMixturePcnt()));

		// PRMajor, PRAccessory, PROther,
		// NRTI, NNRTI, RTOther,
		// INMajor, INAccessory, INOther
		sequenceRecord.addAll(determineMutLists(alignedSeq));

	  	// PRSDRMs, RTSDRMs
		sequenceRecord.addAll(determineSdrms(alignedSeq));

	  	// PI-TSMs, NRTI-TSMs, NNRTI-TSMs, INSTI-TSMs
		sequenceRecord.addAll(determineNonDrmTsms(alignedSeq));

	  	// NumFS, FrameShifts
		sequenceRecord.addAll(determineFrameShiftText(alignedSeq));
		// NumIns, Insertions
		sequenceRecord.addAll(determineSeqInsertions(seqMutations));
		// NumDel, Deletions
		sequenceRecord.addAll(determineSeqDeletions(seqMutations));
		// NumStops, StopCodons
		sequenceRecord.addAll(determineSeqStopCodons(seqMutations));
		// NumBDHVN, BDHVN
		sequenceRecord.addAll(determineSeqBDHVN(seqMutations));
		// NumApobec, ApobecMuts
		sequenceRecord.addAll(determineApobecFields(seqMutations));
		// NumUnusual, UnusualMuts
		sequenceRecord.addAll(determineSeqUnusualMuts(seqMutations));
		sequenceRows.add(sequenceRecord);

		for (int i=0; i<headerFields.length; i++) {
			String field = headerFields[i];
			String dataItem = sequenceRecord.get(i);
			tabularResults.get(seqName).put(field, dataItem);
		}
	}
}
 
Example 12
Project: SDI   File: Stepper.java   View Source Code Vote up 4 votes
public String toString() {
    return StringUtils.join(steps, ' ');
}
 
Example 13
Project: Yidu   File: CleanDeleteDataServiceImpl.java   View Source Code Vote up 4 votes
@Override
public void cleanDeleteData() {
    int keepdays = YiDuConstants.yiduConf.getInt(YiDuConfig.KEEP_DELETE_DATA_DAYS, 5);

    // 清理txt文件和img文件
    // 按小说删除txt文件和封面文件
    String getDeleteArtcleSql = "select articleno from t_article where deleteflag and modifytime < (now() -  INTERVAL ''{0} days'')";
    List<Integer> articlenoList = yiduJdbcTemplate.queryForList(
            MessageFormat.format(getDeleteArtcleSql, new Object[] { keepdays }), Integer.class);
    for (Integer articleno : articlenoList) {
        Utils.deleteDirectory(Utils.getTextDirectoryPathByArticleno(articleno));
        Utils.deleteDirectory(Utils.getArticlePicPath(articleno));
    }

    // 按章节删除txt文件
    String getDeleteChapterSql = "select * from t_chapter where deleteflag and modifytime < (now() -  INTERVAL ''{0} days'') ";
    if (Utils.isDefined(articlenoList)) {
        getDeleteChapterSql = getDeleteChapterSql + " and articlno not in (" + StringUtils.join(articlenoList, ",")
                + ")";
    }

    List<TChapter> chapterList = yiduJdbcTemplate.query(
            MessageFormat.format(getDeleteChapterSql, new Object[] { keepdays }),
            new BeanPropertyRowMapper<TChapter>(TChapter.class));
    for (TChapter chapter : chapterList) {
        Utils.deleteFile(Utils.getTextFilePathByChapterno(chapter.getArticleno(), chapter.getChapterno()));
    }
    // 清理数据库数据
    Set<String> tableSet = new HashSet<String>();
    tableSet.add("t_user");
    tableSet.add("t_review");
    tableSet.add("t_chapter");
    tableSet.add("t_system_block");
    tableSet.add("t_bookcase");
    tableSet.add("t_article");
    tableSet.add("t_message");
    tableSet.add("t_credit_history");
    String deleteSql = "delete from {0} where deleteflag and modifytime < (now() -  INTERVAL ''{1} days'')";
    for (String table : tableSet) {
        yiduJdbcTemplate.execute(MessageFormat.format(deleteSql, new Object[] { table, keepdays }));
    }
}
 
Example 14
Project: googlecloud-techtalk   File: SearchImpl.java   View Source Code Vote up 4 votes
@Override
public String toString() {
    return (queryComponents.isEmpty() ? "*" : StringUtils.join(queryComponents, " ")) + (sortOrder.isEmpty() ? "" : " " + sortOrder);
}
 
Example 15
Project: metadata-qa-marc   File: MarcFieldExtractor.java   View Source Code Vote up 4 votes
private void processNumberOfPart() {
	numberOfPart = StringUtils.join(resultMap.get("245$n"), "; ");
}
 
Example 16
Project: spydra   File: OnPremiseExecutorTest.java   View Source Code Vote up 4 votes
@Test
public void testGetCommand() {
  String jarPath = "jarPath";
  List<String> args = new ArrayList<>();
  args.add("arg1");
  String mainClass = "mainClass";
  String[] properties = new String[]{
      "propertyName0=propertyValue0",
      "propertyName1=propertyValue1"};

  SpydraArgument arguments = new SpydraArgument();
  arguments.getSubmit().getOptions().put(OPTION_JAR, jarPath);
  arguments.getSubmit().getOptions().put(OPTION_CLASS, mainClass);
  arguments.getSubmit().getOptions().put(SpydraArgument.OPTION_PROPERTIES,
      StringUtils.join(properties, ","));
  arguments.getSubmit().setJobArgs(args);

  OnPremiseExecutor executor = new OnPremiseExecutor();
  List<String> command = executor.getCommand(arguments);

  String[] baseCommand = StringUtils.split(OnPremiseExecutor.BASE_COMMAND);
  for (int i = 0; i < baseCommand.length; i++) {
    assertEquals(baseCommand[i], command.get(i));
  }

  assertEquals(command.get(baseCommand.length), jarPath);
  assertEquals(command.get(baseCommand.length + 1), mainClass);

  int count = 0;
  for (int i = 0; i < command.size() - 1; i++) {
    if (command.get(i).equals(OnPremiseExecutor.PROPERTY)) {
      assertTrue(command.contains(properties[0])
          || command.contains(properties[1]));
      count++;
    }
  }
  assertEquals(properties.length, count);

  // Check order of arguments (HADOOP-1056)
  String expectedCommand = "hadoop jar jarPath mainClass arg1 "
      + "-D propertyName0=propertyValue0 "
      + "-D propertyName1=propertyValue1";
  String actualCommand = StringUtils.join(command, StringUtils.SPACE);
  assertEquals(expectedCommand, actualCommand);
}
 
Example 17
Project: uob-timetable-android   File: MyApplication.java   View Source Code Vote up 4 votes
public void onCreate(){

        super.onCreate();

        SettingsManager settings = SettingsManager.getInstance(this);
        hadPrefDataOnLaunch = settings.isEmpty() == false;
        settings.clearOldData();

        String loggerKey = "Application";

        // Init logger
        Logger.getInstance()
            .addLogger("android", new AndroidLogger())
            .addLogger("memory", new MemoryLogger());

        // Init bugsnag
        String bugsnagKey = BuildConfig.BUGSNAG_KEY;
        // Key is always inserted in to BuildConfig as a string
        if (bugsnagKey.equals("null")){
            Logger.getInstance().error(loggerKey, "Can't init Bugsnag - No key");
        } else {
            String[] bugsnagVersionParts = {
                    BuildConfig.VERSION_NAME,
                    Integer.valueOf(BuildConfig.VERSION_CODE).toString(),
                    BuildConfig.GIT_COMMIT_HASH
            };
            String bugsnagVersion = StringUtils.join(bugsnagVersionParts, ":");

            Configuration config = new Configuration(bugsnagKey);
            config.setAppVersion(bugsnagVersion);
            config.setReleaseStage(getBuildTypeString());

            Logger.getInstance()
                .addLogger("bugsnag", new BugsnagLogger(this, config))
                .info(loggerKey, "Bugsnag initialised");
        }

        SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm dd/MM/yy");

        Logger.getInstance()
            .info(loggerKey, "API level: " + AndroidUtilities.apiLevel())
            .info(loggerKey, "API level name: " + AndroidUtilities.apiLevelName())
            .info(loggerKey, "Target API level: " + AndroidUtilities.targetApiLevel(this))
            .info(loggerKey, "Git commit hash: " + BuildConfig.GIT_COMMIT_HASH)
            .info(loggerKey, "Git branch: " + BuildConfig.GIT_BRANCH)
            .info(loggerKey, "Build type: " + getBuildTypeString())
            .info(loggerKey, "Build keys: " + (AndroidUtilities.isReleaseSigned(this) ? "Release" : "Debug"))
            .info(loggerKey, "Version code: " + AndroidUtilities.buildVersionCode(this))
            .info(loggerKey, "Version name: " + AndroidUtilities.buildVersionName(this))
            .info(loggerKey, "Build date: " + dateFormat.format(AndroidUtilities.buildDate()))
            .info(loggerKey, "Package update date: " + dateFormat.format(AndroidUtilities.packageUpdateDate(this)))
            .info(loggerKey, "Launch count: " +  settings.incrementLaunchCount())
            .info(loggerKey, "Network: " + AndroidUtilities.getNetworkRaw(this))
            .info(loggerKey, "Tablet layout: " + AndroidUtilities.isTabletLayout(this));
    }
 
Example 18
Project: vind   File: SolrUtils.java   View Source Code Vote up 4 votes
public static String buildSolrFacetTags(String ... keys){
    return StringUtils.join("tag='",StringUtils.join(keys,','),"'");
}
 
Example 19
Project: plugin-bt-jira   File: JiraExportPluginResource.java   View Source Code Vote up 4 votes
@Override
public Object getValue(final T context) {
	return StringUtils
			.join(identifierHelper.normalize(identifierHelper.asList((String) super.getValue(context))), ',');
}
 
Example 20
Project: winter   File: MovieXMLReader.java   View Source Code Vote up 3 votes
@Override
public Movie createInstanceForFusion(RecordGroup<Movie, Attribute> cluster) {

	List<String> ids = new LinkedList<>();

	for (Movie m : cluster.getRecords()) {
		ids.add(m.getIdentifier());
	}

	Collections.sort(ids);

	String mergedId = StringUtils.join(ids, '+');

	return new Movie(mergedId, "fused");
}