List of usage examples for org.apache.commons.lang3 ArrayUtils removeAll
static Object removeAll(final Object array, final BitSet indices)
From source file:com.newtranx.util.xml.XmlFilterReader.java
@Override public int read(char[] cbuf, int off, int len) throws IOException { int ret = underlying.read(cbuf, off, len); for (int i = off; i < off + ret; i++) { if (!isValid(cbuf[i])) toRemove.add(i);//from w ww . j a v a 2 s . com } if (!toRemove.isEmpty()) { int[] indices = new int[toRemove.size()]; for (int i = 0; i < indices.length; i++) { indices[i] = toRemove.get(i); } toRemove.clear(); ret -= indices.length; char[] newArr = ArrayUtils.removeAll(cbuf, indices); System.arraycopy(newArr, off, cbuf, off, ret); } return ret; }
From source file:org.jsweet.transpiler.candies.CandiesProcessor.java
/** * Create a candies processor./*w w w . j a v a2 s . c o m*/ * * @param workingDir * the directory where the processor will save all cache and * temporary data for processing * @param classPath * the classpath where the processor will seek for JSweet candies * @param extractedCandiesJavascriptDir * see JSweetTranspiler.extractedCandyJavascriptDir */ public CandiesProcessor(File workingDir, String classPath, File extractedCandiesJavascriptDir) { this.workingDir = workingDir; this.classPath = (classPath == null ? System.getProperty("java.class.path") : classPath); String[] cp = this.classPath.split(File.pathSeparator); int[] indices = new int[0]; for (int i = 0; i < cp.length; i++) { if (cp[i].replace('\\', '/').matches(".*org/jsweet/lib/.*-testbundle/.*/.*-testbundle-.*\\.jar")) { logger.warn("candies processor ignores classpath entry: " + cp[i]); indices = ArrayUtils.add(indices, i); } } cp = ArrayUtils.removeAll(cp, indices); this.classPath = StringUtils.join(cp, File.pathSeparator); logger.info("candies processor classpath: " + this.classPath); candiesSourceDir = new File(workingDir, CANDIES_SOURCES_DIR_NAME); candiesStoreFile = new File(workingDir, CANDIES_STORE_FILE_NAME); candiesTsdefsDir = new File(workingDir, CANDIES_TSDEFS_DIR_NAME); setCandiesJavascriptOutDir(extractedCandiesJavascriptDir); }
From source file:org.jsweet.transpiler.candy.CandyProcessor.java
/** * Create a candies processor./*from w w w . j a va 2s. c o m*/ * * @param workingDir * the directory where the processor will save all cache and * temporary data for processing * @param classPath * the classpath where the processor will seek for JSweet candies * @param extractedCandiesJavascriptDir * see JSweetTranspiler.extractedCandyJavascriptDir */ public CandyProcessor(File workingDir, String classPath, File extractedCandiesJavascriptDir) { this.workingDir = workingDir; this.classPath = (classPath == null ? System.getProperty("java.class.path") : classPath); String[] cp = this.classPath.split(File.pathSeparator); int[] indices = new int[0]; for (int i = 0; i < cp.length; i++) { if (cp[i].replace('\\', '/').matches(".*org/jsweet/lib/.*-testbundle/.*/.*-testbundle-.*\\.jar")) { logger.warn("candies processor ignores classpath entry: " + cp[i]); indices = ArrayUtils.add(indices, i); } } cp = ArrayUtils.removeAll(cp, indices); this.classPath = StringUtils.join(cp, File.pathSeparator); logger.info("candies processor classpath: " + this.classPath); candiesSourceDir = new File(workingDir, CANDIES_SOURCES_DIR_NAME); candiesStoreFile = new File(workingDir, CANDIES_STORE_FILE_NAME); candiesTsdefsDir = new File(workingDir, CANDIES_TSDEFS_DIR_NAME); setCandiesJavascriptOutDir(extractedCandiesJavascriptDir); }
From source file:yoyo.framework.standard.shared.commons.lang.ArrayUtilsTest.java
@Test public void test() { assertThat(ArrayUtils.EMPTY_BOOLEAN_ARRAY.length, is(0)); assertThat(ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY, is(new Boolean[] {})); boolean[] testee = ArrayUtils.add(null, true); assertThat(ArrayUtils.clone(testee), is(testee)); assertThat(ArrayUtils.contains(testee, true), is(true)); assertThat(ArrayUtils.contains(testee, false), is(false)); assertThat(ArrayUtils.getLength(testee), is(1)); assertThat(ArrayUtils.hashCode(testee), is(not(nullValue()))); assertThat(ArrayUtils.indexOf(testee, true), is(not(ArrayUtils.INDEX_NOT_FOUND))); assertThat(ArrayUtils.indexOf(testee, false), is(ArrayUtils.INDEX_NOT_FOUND)); assertThat(ArrayUtils.isEmpty(testee), is(false)); assertThat(ArrayUtils.isEmpty(ArrayUtils.EMPTY_BOOLEAN_ARRAY), is(true)); assertThat(ArrayUtils.isEquals(testee, new boolean[] { true }), is(true)); assertThat(ArrayUtils.isNotEmpty(testee), is(true)); assertThat(ArrayUtils.isSameLength(testee, new boolean[] { true }), is(true)); assertThat(ArrayUtils.isSameType(testee, new boolean[] { true }), is(true)); assertThat(ArrayUtils.lastIndexOf(testee, true), is(not(ArrayUtils.INDEX_NOT_FOUND))); assertThat(ArrayUtils.lastIndexOf(testee, false), is(ArrayUtils.INDEX_NOT_FOUND)); boolean[] booleanNull = null; assertThat(ArrayUtils.nullToEmpty(booleanNull), is(ArrayUtils.EMPTY_BOOLEAN_ARRAY)); assertThat(ArrayUtils.remove(testee, 0), is(ArrayUtils.EMPTY_BOOLEAN_ARRAY)); assertThat(ArrayUtils.removeAll(testee, 0), is(ArrayUtils.EMPTY_BOOLEAN_ARRAY)); assertThat(ArrayUtils.removeElement(testee, true), is(ArrayUtils.EMPTY_BOOLEAN_ARRAY)); assertThat(ArrayUtils.removeElement(testee, false), is(testee)); assertThat(ArrayUtils.removeElements(testee, true, false), is(ArrayUtils.EMPTY_BOOLEAN_ARRAY)); }