Java Code Examples for com.google.common.base.CharMatcher#is()

The following examples show how to use com.google.common.base.CharMatcher#is() . 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: EvaluationPhaseFilterFunctions.java    From datawave with Apache License 2.0 5 votes vote down vote up
private static int[] indicesOf(String input, char c) {
    CharMatcher matcher = CharMatcher.is(c);
    int count = matcher.countIn(input);
    int[] indices = new int[count];
    int lastIndex = 0;
    for (int i = 0; i < count; i++) {
        indices[i] = input.indexOf(c, lastIndex + 1);
        lastIndex = indices[i];
    }
    return indices;
}
 
Example 2
Source File: ConfigPropertyMeta.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
protected Object convertValue(String... values) {
	final Object result = Array.newInstance(field.getType().getComponentType(), values.length);
	final CharMatcher matcher = CharMatcher.is('"');
	for (int i = 0; i < values.length; i++) {
		final String value = matcher.trimFrom(StringUtils.strip(values[i]));
		final Object converted = converter.readFromString(value);
		Array.set(result, i, converted);
	}
	return result;
}
 
Example 3
Source File: BaseEncoding.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
CharMatcher padding() {
  return (paddingChar == null)
    ? CharMatcher.none()
    : CharMatcher.is(paddingChar.charValue());
}
 
Example 4
Source File: BaseEncoding.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
CharMatcher padding() {
  return (paddingChar == null)
    ? CharMatcher.none()
    : CharMatcher.is(paddingChar.charValue());
}
 
Example 5
Source File: BaseEncoding.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
CharMatcher padding() {
  return (paddingChar == null)
    ? CharMatcher.none()
    : CharMatcher.is(paddingChar.charValue());
}
 
Example 6
Source File: BaseEncoding.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
CharMatcher padding() {
  return (paddingChar == null)
    ? CharMatcher.none()
    : CharMatcher.is(paddingChar.charValue());
}
 
Example 7
Source File: BaseEncoding.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
CharMatcher padding() {
  return (paddingChar == null) ? CharMatcher.none() : CharMatcher.is(paddingChar.charValue());
}
 
Example 8
Source File: XtendBatchCompiler.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
private boolean configureWorkspace(ResourceSet resourceSet) {
	List<File> sourceFileList = getSourcePathFileList();
	File outputFile = getOutputPathFile();
	if (sourceFileList == null || outputFile == null) {
		return false;
	}

	File commonRoot = determineCommonRoot(outputFile, sourceFileList);

	// We don't want to use root ("/") as a workspace folder, didn't we?
	if (commonRoot == null || commonRoot.getParent() == null || commonRoot.getParentFile().getParent() == null) {
		log.error("All source folders and the output folder should have "
				+ "a common parent non-top level folder (like project folder)");
		for (File sourceFile : sourceFileList) {
			log.error("(Source folder: '" + sourceFile + "')");
		}
		log.error("(Output folder: '" + outputFile + "')");
		return false;
	}
	projectConfig = new FileProjectConfig(commonRoot, commonRoot.getName());

	java.net.URI commonURI = commonRoot.toURI();
	java.net.URI relativizedTarget = commonURI.relativize(outputFile.toURI());
	if (relativizedTarget.isAbsolute()) {
		log.error("Target folder '" + outputFile + "' must be a child of the project folder '" + commonRoot + "'");
		return false;
	}
	CharMatcher slash = CharMatcher.is('/');
	String relativeTargetFolder = slash.trimTrailingFrom(relativizedTarget.getPath());
	outputConfiguration = Iterables.getOnlyElement(outputConfigurationProvider.getOutputConfigurations());
	outputConfiguration.setOutputDirectory(relativeTargetFolder);
	for (File source : sourceFileList) {
		java.net.URI relativizedSrc = commonURI.relativize(source.toURI());
		if (relativizedSrc.isAbsolute()) {
			log.error("Source folder '" + source + "' must be a child of the project folder '" + commonRoot + "'");
			return false;
		}
		projectConfig.addSourceFolder(slash.trimTrailingFrom(relativizedSrc.getPath()));
	}
	Map<String, Set<OutputConfiguration>> outputConfigurations = newHashMap();
	outputConfigurations.put(languageName, newHashSet(outputConfiguration));
	ProjectConfigAdapter.install(resourceSet, projectConfig);
	resourceSet.eAdapters().add(new OutputConfigurationAdapter(outputConfigurations));
	return true;
}