List of usage examples for com.google.common.base CharMatcher negate
public CharMatcher negate()
From source file:org.nuxeo.ecm.core.filter.CharacterFilteringServiceImpl.java
@Override public void registerContribution(Object contrib, String point, ComponentInstance contributor) { if (FILTERING_XP.equals(point)) { desc = (CharacterFilteringServiceDescriptor) contrib; CharMatcher charsToPreserve = CharMatcher.anyOf("\r\n\t"); CharMatcher allButPreserved = charsToPreserve.negate(); charsToRemove = CharMatcher.JAVA_ISO_CONTROL.and(allButPreserved); charsToRemove = charsToRemove.or(CharMatcher.INVISIBLE.and(CharMatcher.WHITESPACE.negate())); List<String> additionalChars = desc.getDisallowedChars(); String otherCharsToRemove = ""; if (additionalChars != null && !additionalChars.isEmpty()) { for (String c : additionalChars) { otherCharsToRemove += StringEscapeUtils.unescapeJava(c); }//from w w w .ja va 2 s. co m charsToRemove = charsToRemove.or(CharMatcher.anyOf(otherCharsToRemove)); } } else { throw new RuntimeException("Unknown extension point: " + point); } }
From source file:com.android.build.gradle.internal.TaskManager.java
public void createMockableJarTask() { createMockableJar = project.getTasks().create("mockableAndroidJar", MockableAndroidJarTask.class); createMockableJar.setGroup(BUILD_GROUP); createMockableJar.setDescription("Creates a version of android.jar that's suitable for unit tests."); createMockableJar.setReturnDefaultValues(extension.getTestOptions().getUnitTests().isReturnDefaultValues()); ConventionMappingHelper.map(createMockableJar, "androidJar", new Callable<File>() { @Override//from w w w. j a v a 2s. c om public File call() throws Exception { checkNotNull(androidBuilder.getTarget(), "ensureTargetSetup not called"); return new File(androidBuilder.getTarget().getPath(IAndroidTarget.ANDROID_JAR)); } }); ConventionMappingHelper.map(createMockableJar, "outputFile", new Callable<File>() { @Override public File call() throws Exception { // Since the file ends up in $rootProject.buildDir, it will survive clean // operations - projects generated by AS don't have a top-level clean task that // would delete the top-level build directory. This means that the name has to // encode all the necessary information, otherwise the task will be UP-TO-DATE // even if the file should be regenerated. That's why we put the SDK version and // "default-values" in there, so if one project uses the returnDefaultValues flag, // it will just generate a new file and not change the semantics for other // sub-projects. There's an implicit "v1" there as well, if we ever change the // generator logic, the names will have to be changed. String fileExt; if (createMockableJar.getReturnDefaultValues()) { fileExt = ".default-values.jar"; } else { fileExt = ".jar"; } File outDir = new File(project.getRootProject().getBuildDir(), AndroidProject.FD_GENERATED); CharMatcher safeCharacters = CharMatcher.JAVA_LETTER_OR_DIGIT.or(CharMatcher.anyOf("-.")); String sdkName = safeCharacters.negate().replaceFrom(extension.getCompileSdkVersion(), '-'); return new File(outDir, "mockable-" + sdkName + fileExt); } }); }