001    /*--------------------------------------------------------------------------+
002    $Id: ArrayUtils.java 29779 2010-08-19 07:32:58Z deissenb $
003    |                                                                          |
004    | Copyright 2005-2010 Technische Universitaet Muenchen                     |
005    |                                                                          |
006    | Licensed under the Apache License, Version 2.0 (the "License");          |
007    | you may not use this file except in compliance with the License.         |
008    | You may obtain a copy of the License at                                  |
009    |                                                                          |
010    |    http://www.apache.org/licenses/LICENSE-2.0                            |
011    |                                                                          |
012    | Unless required by applicable law or agreed to in writing, software      |
013    | distributed under the License is distributed on an "AS IS" BASIS,        |
014    | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
015    | See the License for the specific language governing permissions and      |
016    | limitations under the License.                                           |
017    +--------------------------------------------------------------------------*/
018    package edu.tum.cs.commons.collections;
019    
020    
021    /**
022     * Utility methods for arrays.
023     * 
024     * @author hummelb
025     * @author $Author: deissenb $
026     * @version $Rev: 29779 $
027     * @levd.rating GREEN Hash: A1919A9F7B9B0DE52A0860D17B16AB6A
028     */
029    public class ArrayUtils {
030    
031            /** Returns whether one array is a prefix of another one. */
032            public static boolean isPrefix(byte[] prefix, byte[] array) {
033                    if (prefix.length > array.length) {
034                            return false;
035                    }
036                    for (int i = 0; i < prefix.length; ++i) {
037                            if (prefix[i] != array[i]) {
038                                    return false;
039                            }
040                    }
041                    return true;
042            }
043    }