Codota Logo
CollectionUtil.subArray
Code IndexAdd Codota to your IDE (free)

How to use
subArray
method
in
com.twelvemonkeys.util.CollectionUtil

Best Java code snippets using com.twelvemonkeys.util.CollectionUtil.subArray (Showing top 19 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: haraldk/TwelveMonkeys

/**
 * Creates an array containing a subset of the original array.
 * If the sub array is same length as the original
 * ({@code pStart == 0}), the original array will be returned.
 *
 * @param pArray the original array
 * @param pStart the start index of the original array
 * @return a subset of the original array, or the original array itself,
 *         if {@code pStart} is 0.
 *
 * @throws IllegalArgumentException if {@code pArray} is {@code null}
 * @throws ArrayIndexOutOfBoundsException if {@code pStart} < 0
 */
public static <T> T[] subArray(T[] pArray, int pStart) {
  return subArray(pArray, pStart, -1);
}
origin: haraldk/TwelveMonkeys

/**
 * Creates an array containing a subset of the original array.
 * If the sub array is same length as the original
 * ({@code pStart == 0}), the original array will be returned.
 *
 * @param pArray the original array
 * @param pStart the start index of the original array
 * @return a subset of the original array, or the original array itself,
 *         if {@code pStart} is 0.
 *
 * @throws IllegalArgumentException if {@code pArray} is {@code null} or
 *         if {@code pArray} is not an array.
 * @throws ArrayIndexOutOfBoundsException if {@code pStart} < 0
 */
public static Object subArray(Object pArray, int pStart) {
  return subArray(pArray, pStart, -1);
}
origin: haraldk/TwelveMonkeys

/**
 * Creates an array containing a subset of the original array.
 * If the {@code pLength} parameter is negative, it will be ignored.
 * If there are not {@code pLength} elements in the original array
 * after {@code pStart}, the {@code pLength} parameter will be
 * ignored.
 * If the sub array is same length as the original, the original array will
 * be returned.
 *
 * @param pArray  the original array
 * @param pStart  the start index of the original array
 * @param pLength the length of the new array
 * @return a subset of the original array, or the original array itself,
 *         if {@code pStart} is 0 and {@code pLength} is either
 *         negative, or greater or equal to {@code pArray.length}.
 *
 * @throws IllegalArgumentException if {@code pArray} is {@code null}
 * @throws ArrayIndexOutOfBoundsException if {@code pStart} < 0
 */
@SuppressWarnings("unchecked")
public static <T> T[] subArray(T[] pArray, int pStart, int pLength) {
  return (T[]) subArray((Object) pArray, pStart, pLength);
}
origin: haraldk/TwelveMonkeys

public String getValueAsString() {
  if (valueCount() > 1) {
    if (valueCount() < 16) {
      return arrayToString(value);
    }
    else {
      String first = arrayToString(CollectionUtil.subArray(value, 0, 4));
      String last = arrayToString(CollectionUtil.subArray(value, valueCount() - 4, 4));
      return String.format("%s ... %s (%d)", first.substring(0, first.length() - 1), last.substring(1), valueCount());
    }
  }
  if (value != null && value.getClass().isArray() && Array.getLength(value) == 1) {
    return String.valueOf(Array.get(value, 0));
  }
  return String.valueOf(value);
}
origin: haraldk/TwelveMonkeys

@Test
public void testSubArrayObject() {
  String[] strings = CollectionUtil.subArray(new String[] {"foo", "bar", "baz", "xyzzy"}, 1, 2);
  assertArrayEquals(new String[] {"bar", "baz"}, strings);
}
origin: haraldk/TwelveMonkeys

@Test
public void testSubArrayNative() {
  int[] numbers = (int[]) CollectionUtil.subArray(new int[] {1, 2, 3, 4, 5}, 1, 3);
  assertArrayEquals(new int[] {2, 3, 4}, numbers);
}
origin: com.twelvemonkeys/twelvemonkeys-core

/**
 * Creates an array containing a subset of the original array.
 * If the sub array is same length as the original
 * ({@code pStart == 0}), the original array will be returned.
 *
 * @param pArray the origianl array
 * @param pStart the start index of the original array
 * @return a subset of the original array, or the original array itself,
 *         if {@code pStart} is 0.
 *
 * @throws IllegalArgumentException if {@code pArray} is {@code null} or
 *         if {@code pArray} is not an array.
 * @throws ArrayIndexOutOfBoundsException if {@code pStart} < 0
 */
public static Object subArray(Object pArray, int pStart) {
  return subArray(pArray, pStart, -1);
}
origin: com.twelvemonkeys.common/common-lang

/**
 * Creates an array containing a subset of the original array.
 * If the sub array is same length as the original
 * ({@code pStart == 0}), the original array will be returned.
 *
 * @param pArray the original array
 * @param pStart the start index of the original array
 * @return a subset of the original array, or the original array itself,
 *         if {@code pStart} is 0.
 *
 * @throws IllegalArgumentException if {@code pArray} is {@code null}
 * @throws ArrayIndexOutOfBoundsException if {@code pStart} < 0
 */
public static <T> T[] subArray(T[] pArray, int pStart) {
  return subArray(pArray, pStart, -1);
}
origin: com.github.lafa.twelvemonkeyspurejava.common/common-lang

/**
 * Creates an array containing a subset of the original array.
 * If the sub array is same length as the original
 * ({@code pStart == 0}), the original array will be returned.
 *
 * @param pArray the original array
 * @param pStart the start index of the original array
 * @return a subset of the original array, or the original array itself,
 *         if {@code pStart} is 0.
 *
 * @throws IllegalArgumentException if {@code pArray} is {@code null}
 * @throws ArrayIndexOutOfBoundsException if {@code pStart} < 0
 */
public static <T> T[] subArray(T[] pArray, int pStart) {
  return subArray(pArray, pStart, -1);
}
origin: com.twelvemonkeys.common/common-lang

/**
 * Creates an array containing a subset of the original array.
 * If the sub array is same length as the original
 * ({@code pStart == 0}), the original array will be returned.
 *
 * @param pArray the original array
 * @param pStart the start index of the original array
 * @return a subset of the original array, or the original array itself,
 *         if {@code pStart} is 0.
 *
 * @throws IllegalArgumentException if {@code pArray} is {@code null} or
 *         if {@code pArray} is not an array.
 * @throws ArrayIndexOutOfBoundsException if {@code pStart} < 0
 */
public static Object subArray(Object pArray, int pStart) {
  return subArray(pArray, pStart, -1);
}
origin: com.github.lafa.twelvemonkeyspurejava.common/common-lang

/**
 * Creates an array containing a subset of the original array.
 * If the sub array is same length as the original
 * ({@code pStart == 0}), the original array will be returned.
 *
 * @param pArray the original array
 * @param pStart the start index of the original array
 * @return a subset of the original array, or the original array itself,
 *         if {@code pStart} is 0.
 *
 * @throws IllegalArgumentException if {@code pArray} is {@code null} or
 *         if {@code pArray} is not an array.
 * @throws ArrayIndexOutOfBoundsException if {@code pStart} < 0
 */
public static Object subArray(Object pArray, int pStart) {
  return subArray(pArray, pStart, -1);
}
origin: com.twelvemonkeys.common/common-lang

/**
 * Creates an array containing a subset of the original array.
 * If the {@code pLength} parameter is negative, it will be ignored.
 * If there are not {@code pLength} elements in the original array
 * after {@code pStart}, the {@code pLength} parameter will be
 * ignored.
 * If the sub array is same length as the original, the original array will
 * be returned.
 *
 * @param pArray  the original array
 * @param pStart  the start index of the original array
 * @param pLength the length of the new array
 * @return a subset of the original array, or the original array itself,
 *         if {@code pStart} is 0 and {@code pLength} is either
 *         negative, or greater or equal to {@code pArray.length}.
 *
 * @throws IllegalArgumentException if {@code pArray} is {@code null}
 * @throws ArrayIndexOutOfBoundsException if {@code pStart} < 0
 */
@SuppressWarnings("unchecked")
public static <T> T[] subArray(T[] pArray, int pStart, int pLength) {
  return (T[]) subArray((Object) pArray, pStart, pLength);
}
origin: com.github.lafa.twelvemonkeyspurejava.common/common-lang

/**
 * Creates an array containing a subset of the original array.
 * If the {@code pLength} parameter is negative, it will be ignored.
 * If there are not {@code pLength} elements in the original array
 * after {@code pStart}, the {@code pLength} parameter will be
 * ignored.
 * If the sub array is same length as the original, the original array will
 * be returned.
 *
 * @param pArray  the original array
 * @param pStart  the start index of the original array
 * @param pLength the length of the new array
 * @return a subset of the original array, or the original array itself,
 *         if {@code pStart} is 0 and {@code pLength} is either
 *         negative, or greater or equal to {@code pArray.length}.
 *
 * @throws IllegalArgumentException if {@code pArray} is {@code null}
 * @throws ArrayIndexOutOfBoundsException if {@code pStart} < 0
 */
@SuppressWarnings("unchecked")
public static <T> T[] subArray(T[] pArray, int pStart, int pLength) {
  return (T[]) subArray((Object) pArray, pStart, pLength);
}
origin: com.github.lafa.twelvemonkeyspurejava.imageio/imageio-metadata

public String getValueAsString() {
  if (valueCount() > 1) {
    if (valueCount() < 16) {
      return arrayToString(value);
    }
    else {
      String first = arrayToString(CollectionUtil.subArray(value, 0, 4));
      String last = arrayToString(CollectionUtil.subArray(value, valueCount() - 4, 4));
      return String.format("%s ... %s (%d)", first.substring(0, first.length() - 1), last.substring(1), valueCount());
    }
  }
  if (value != null && value.getClass().isArray() && Array.getLength(value) == 1) {
    return String.valueOf(Array.get(value, 0));
  }
  return String.valueOf(value);
}
origin: com.twelvemonkeys.imageio/imageio-metadata

public String getValueAsString() {
  if (valueCount() > 1) {
    if (valueCount() < 16) {
      return arrayToString(value);
    }
    else {
      String first = arrayToString(CollectionUtil.subArray(value, 0, 4));
      String last = arrayToString(CollectionUtil.subArray(value, valueCount() - 4, 4));
      return String.format("%s ... %s (%d)", first.substring(0, first.length() - 1), last.substring(1), valueCount());
    }
  }
  if (value != null && value.getClass().isArray() && Array.getLength(value) == 1) {
    return String.valueOf(Array.get(value, 0));
  }
  return String.valueOf(value);
}
origin: com.github.lafa.twelvemonkeyspurejava.common/common-lang

@Test
public void testSubArrayNative() {
  int[] numbers = (int[]) CollectionUtil.subArray(new int[] {1, 2, 3, 4, 5}, 1, 3);
  assertArrayEquals(new int[] {2, 3, 4}, numbers);
}
origin: com.github.lafa.twelvemonkeyspurejava.common/common-lang

@Test
public void testSubArrayObject() {
  String[] strings = CollectionUtil.subArray(new String[] {"foo", "bar", "baz", "xyzzy"}, 1, 2);
  assertArrayEquals(new String[] {"bar", "baz"}, strings);
}
origin: com.twelvemonkeys.common/common-lang

@Test
public void testSubArrayObject() {
  String[] strings = CollectionUtil.subArray(new String[] {"foo", "bar", "baz", "xyzzy"}, 1, 2);
  assertArrayEquals(new String[] {"bar", "baz"}, strings);
}
origin: com.twelvemonkeys.common/common-lang

@Test
public void testSubArrayNative() {
  int[] numbers = (int[]) CollectionUtil.subArray(new int[] {1, 2, 3, 4, 5}, 1, 3);
  assertArrayEquals(new int[] {2, 3, 4}, numbers);
}
com.twelvemonkeys.utilCollectionUtilsubArray

Javadoc

Creates an array containing a subset of the original array. If the sub array is same length as the original ( pStart == 0), the original array will be returned.

Popular methods of CollectionUtil

  • iterator
    Creates a thin Iterator wrapper around an array.
  • mergeArrays
    Merges two arrays into a new array. Elements from array1 and array2 will be copied into a new array,
  • addAll
    Adds all elements of the iterator to the collection.
  • generify
  • generify2
  • invert
    Creates an inverted mapping of the key/value pairs in the given map. Optionally, a duplicate handler
  • reverseOrder
  • test

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • onRequestPermissionsResult (Fragment)
  • onCreateOptionsMenu (Activity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • JButton (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now