1 7 8 9 package org.enhydra.oyster.util; 10 11 import org.enhydra.oyster.exception.SMIMEException; 12 13 14 18 public class ByteArrayComparator { 19 20 24 private int positionFirst = -1; 25 26 34 public ByteArrayComparator (byte[] toFind0, byte[] lookUpArray0) throws SMIMEException 35 { 36 if (toFind0.length >= lookUpArray0.length) 37 throw new SMIMEException(this, 1033); 38 positionFirst = find(toFind0, lookUpArray0); 39 } 40 41 47 private int find (byte[] toFind0, byte[] lookUpArray0) { 48 int k; 49 int positionFirst = -1; 50 byte[] prStr; 51 for (k = 0; k != lookUpArray0.length; k++) { 52 for (int z = 0; z != toFind0.length; z++) { 53 positionFirst = k; 54 if (toFind0[z] != lookUpArray0[k + z]) { 55 positionFirst = -1; 56 break; 57 } 58 } 59 if (positionFirst == k) 60 break; 61 } 62 return positionFirst; } 64 65 69 public int getMatchingIndex () { 70 return positionFirst; 71 } 72 } 73 74 75 76 | Popular Tags |