You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CharOperation.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /********************************************************************
  2. * Copyright (c) 2006 Contributors. All rights reserved.
  3. * This program and the accompanying materials are made available
  4. * under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution and is available at
  6. * http://eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: IBM Corporation - initial API and implementation
  9. * Helen Hawkins - initial version
  10. *******************************************************************/
  11. package org.aspectj.util;
  12. /**
  13. * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
  14. *
  15. */
  16. public class CharOperation {
  17. /**
  18. * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
  19. */
  20. public static final char[] subarray(char[] array, int start, int end) {
  21. if (end == -1)
  22. end = array.length;
  23. if (start > end)
  24. return null;
  25. if (start < 0)
  26. return null;
  27. if (end > array.length)
  28. return null;
  29. char[] result = new char[end - start];
  30. System.arraycopy(array, start, result, 0, end - start);
  31. return result;
  32. }
  33. /**
  34. * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
  35. */
  36. public static final int lastIndexOf(char toBeFound, char[] array) {
  37. for (int i = array.length; --i >= 0;)
  38. if (toBeFound == array[i])
  39. return i;
  40. return -1;
  41. }
  42. }