/** * Creates a new Matcher object. * * @param pat * The pattern * @param str * The string */ public Matcher(final String pat, final String str) { apat = pat.toCharArray(); lpat = apat.length; astr = str.toCharArray(); lstr = astr.length; add(str); matched = match(); }
/** * Creates a new Matcher object. * * @param pat * The pattern * @param str * The string */ public Matcher(final String pat, final String str) { apat = pat.toCharArray(); lpat = apat.length; astr = str.toCharArray(); lstr = astr.length; add(str); matched = match(); }
/** * Creates a new Matcher object. * * @param pat * The pattern * @param str * The string */ public Matcher(final String pat, final String str) { apat = pat.toCharArray(); lpat = apat.length; astr = str.toCharArray(); lstr = astr.length; add(str); matched = match(); }
private final boolean checkEnds(final int sipat, final boolean isSingleStart) { // if the remaining length of the string isn't the same as that found in the pattern // we do not match final int l = lpat - sipat; // calculate length of comparison final int ostr = lstr - l; // calculate offset into string if (ostr >= 0 && strncmp(apat, sipat, astr, ostr, l)) { if (isSingleStart) { // if the ends matches make sure there isn't a PATHSEP in the candidate string // part int i = ostr - istr; while (i > istr) { if (astr[--i] == PATHSEP) { return false; // we cannot match because of a PATHSEP in the matched // part } } } add(new String(astr, istr, ostr - istr)); return true; } // otherwise we do not match return false; } }
private boolean checkEnds(final int sipat, final boolean isSingleStart) { // if the remaining length of the string isn't the same as that found in the pattern // we do not match final int l = lpat - sipat; // calculate length of comparison final int ostr = lstr - l; // calculate offset into string if (ostr >= 0 && strncmp(apat, sipat, astr, ostr, l)) { if (isSingleStart) { // if the ends matches make sure there isn't a PATHSEP in the candidate string // part int i = ostr - istr; while (i > istr) { if (astr[--i] == PATHSEP) { return false; // we cannot match because of a PATHSEP in the matched // part } } } add(new String(astr, istr, ostr - istr)); return true; } // otherwise we do not match return false; } }
private final boolean checkEnds(final int sipat, final boolean isSingleStart) { // if the remaining length of the string isn't the same as that found in the pattern // we do not match final int l = lpat - sipat; // calculate length of comparison final int ostr = lstr - l; // calculate offset into string if (ostr >= 0 && strncmp(apat, sipat, astr, ostr, l)) { if (isSingleStart) { // if the ends matches make sure there isn't a PATHSEP in the candidate string // part int i = ostr - istr; while (i > istr) { if (astr[--i] == PATHSEP) { return false; // we cannot match because of a PATHSEP in the matched // part } } } add(new String(astr, istr, ostr - istr)); return true; } // otherwise we do not match return false; } }
private boolean checkEnds(final int sipat, final boolean isSingleStart) { // if the remaining length of the string isn't the same as that found in the pattern // we do not match final int l = lpat - sipat; // calculate length of comparison final int ostr = lstr - l; // calculate offset into string if (ostr >= 0 && strncmp(apat, sipat, astr, ostr, l)) { if (isSingleStart) { // if the ends matches make sure there isn't a PATHSEP in the candidate string // part int i = ostr - istr; while (i > istr) { if (astr[--i] == PATHSEP) { return false; // we cannot match because of a PATHSEP in the matched // part } } } add(new String(astr, istr, ostr - istr)); return true; } // otherwise we do not match return false; } }
/** * Creates a new Matcher object. * * @param pat * The pattern * @param str * The string */ public Matcher(final String pat, final String str) { apat = pat.toCharArray(); lpat = apat.length; astr = str.toCharArray(); lstr = astr.length; add(str); matched = match(); }