@SuppressWarnings("unchecked") public void registerAddonConverter(TypeConverter<File> fileTypeConverter) { if (addonFileConverters == null) { addonFileConverters = new TypeConverter[0]; } addonFileConverters = ArraysUtil.append(addonFileConverters, fileTypeConverter); }
/** * Adds loader-only rules for classes which must be loaded using this * loader. */ public void addLoaderOnlyRules(String... packages) { loaderOnlyRules = ArraysUtil.join(loaderOnlyRules, packages); }
/** * Appends an element to array. */ public static <T> T[] append(T[] buffer, T newElement) { T[] t = resize(buffer, buffer.length + 1); t[buffer.length] = newElement; return t; }
@Override public void visitEnd() { if (methodParameters.length > currentParam) { methodParameters = ArraysUtil.subarray(methodParameters, 0, currentParam); } }
/** * Finds the first occurrence in an array. */ public static int indexOf(byte[] array, byte[] sub) { return indexOf(array, sub, 0, array.length); } public static boolean contains(byte[] array, byte[] sub) {
/** * Inserts one element into an array. */ public static <T> T[] insert(T[] dest, T src, int offset) { Class<T> componentType = (Class<T>) dest.getClass().getComponentType(); return insert(dest, src, offset, componentType); }
private String extractContentTypeValue(final String type, int startIndex) { // skip spaces while (startIndex < type.length() && type.charAt(startIndex) == ' ') { startIndex++; } if (startIndex >= type.length()) { return null; } int endIndex = startIndex; if (type.charAt(startIndex) == '"') { startIndex++; endIndex = type.indexOf('"', startIndex); if (endIndex == -1) { endIndex = type.length(); } } else { while (endIndex < type.length() && (!ArraysUtil.contains(TSPECIALS, type.charAt(endIndex)))) { endIndex++; } } return type.substring(startIndex, endIndex); }
/** * Adds action configuration. Returns <code>true</code> if * new configuration replaces existing one. */ public boolean add(ActionConfig cfg) { if (cfg.actionPath.equals(this.actionPath) == false) { throw new MadvocException("Invalid configuration."); } cfg.actionConfigSet = this; int ndx = lookupIndex(cfg.actionMethod); if (ndx == -1) { if (cfg.actionMethod == null) { configs = ArraysUtil.append(configs, cfg); } else { configs = ArraysUtil.insert(configs, cfg, 0); } return false; } else { configs[ndx] = cfg; return true; } }
return ArraysUtil.toString((int[]) value); return ArraysUtil.toString((long[]) value); return ArraysUtil.toString((byte[]) value); return ArraysUtil.toString((float[]) value); return ArraysUtil.toString((double[]) value); return ArraysUtil.toString((short[]) value); return ArraysUtil.toString((boolean[]) value); return ArraysUtil.toString((Object[])value);
assertTrue(ArraysUtil.contains(interfaces, Map.class)); assertTrue(ArraysUtil.contains(interfaces, Serializable.class)); assertTrue(ArraysUtil.contains(interfaces, Cloneable.class)); assertTrue(ArraysUtil.contains(interfaces, SomeGuy.class)); assertTrue(ArraysUtil.contains(interfaces, Cool.class)); assertTrue(ArraysUtil.contains(interfaces, Flying.class)); assertTrue(ArraysUtil.contains(interfaces, Vigilante.class)); assertTrue(ArraysUtil.indexOf(interfaces, Flying.class) < ArraysUtil.indexOf(interfaces, SomeGuy.class)); assertTrue(ArraysUtil.contains(interfaces, SomeGuy.class)); assertTrue(ArraysUtil.contains(interfaces, Cool.class)); assertTrue(ArraysUtil.contains(interfaces, SomeGuy.class));
@Test void testSub() { assertArrayEquals(new int[] { 2, 3, 4 }, ArraysUtil.subarray(x, 1, 3)); assertArrayEquals(new long[] { 2, 3, 4 }, ArraysUtil.values(ArraysUtil.subarray(xx, 1, 3))); assertArrayEquals(new String[] { "f", "o", "o" }, ArraysUtil.subarray(new String[] { "f", "o", "o", "b", "a", "r" }, 0, 3)); assertArrayEquals(new byte[] { 2, 3 }, ArraysUtil.subarray(new byte[] { 1, 2, 3 }, 1, 2)); assertArrayEquals(new char[] { 'f', 'o', 'o' }, ArraysUtil.subarray(new char[] { 'f', 'o', 'o', 'b', 'a', 'r' }, 0, 3)); assertArrayEquals(new short[] { 2, 3 }, ArraysUtil.subarray(new short[] { 1, 2, 3 }, 1, 2)); assertArrayEquals(new long[] { 2l, 3l }, ArraysUtil.subarray(new long[] { 1l, 2l, 3l }, 1, 2)); assertArrayEquals(new float[] { 2.0f, 3.0f }, ArraysUtil.subarray(new float[] { 1.0f, 2.0f, 3.0f }, 1, 2), 0.1f); assertArrayEquals(new double[] { 2.0, 3.0 }, ArraysUtil.subarray(new double[] { 1.0, 2.0, 3.0 }, 1, 2), 0.1); assertBooleanArrayEquals(new boolean[] { true, false }, ArraysUtil.subarray(new boolean[] { true, true, false, false }, 1, 2)); }
/** * Inserts one array into another at given offset. */ public static <T> T[] insertAt(T[] dest, T[] src, int offset) { Class<T> componentType = (Class<T>) dest.getClass().getComponentType(); return insertAt(dest, src, offset, componentType); }
/** * Returns subarray. */ public static <T> T[] subarray(T[] buffer, int offset, int length) { Class<T> componentType = (Class<T>) buffer.getClass().getComponentType(); return subarray(buffer, offset, length, componentType); }
/** * Finds the first occurrence in an array from specified given position. */ public static int indexOf(byte[] array, byte[] sub, int startIndex) { return indexOf(array, sub, startIndex, array.length); }
/** * Inserts one array into another array. */ public static <T> T[] insert(T[] dest, T[] src, int offset) { Class<T> componentType = (Class<T>) dest.getClass().getComponentType(); return insert(dest, src, offset, componentType); } /**
/** * Removes elements from the set of matched elements. */ public Jerry not(final String cssSelector) { Node[] notNodes = root().find(cssSelector).nodes; List<Node> result = new NodeList(nodes.length); if (nodes.length > 0) { for (Node node : nodes) { if (!ArraysUtil.contains(notNodes, node)) { result.add(node); } } } return new Jerry(this, result); }
return ArraysUtil.toString((int[]) value); return ArraysUtil.toString((long[]) value); return ArraysUtil.toString((byte[]) value); return ArraysUtil.toString((float[]) value); return ArraysUtil.toString((double[]) value); return ArraysUtil.toString((short[]) value); return ArraysUtil.toString((boolean[]) value); return ArraysUtil.toString((Object[])value);
/** * Inserts one array into another at given offset. */ public static <T> T[] insertAt(T[] dest, T[] src, int offset) { Class<T> componentType = (Class<T>) dest.getClass().getComponentType(); return insertAt(dest, src, offset, componentType); }
/** * Adds property injection point. */ protected void addPropertyInjectionPoint(final PropertyInjectionPoint pip) { if (properties == null) { properties = new PropertyInjectionPoint[1]; properties[0] = pip; } else { properties = ArraysUtil.append(properties, pip); } }
/** * Adds parent only rules for classes which must be loaded on the * parent loader. */ public void addParentOnlyRules(String... packages) { parentOnlyRules = ArraysUtil.join(parentOnlyRules, packages); }