Here you can find the source of regionMatches(CharSequence seq, int toff, CharSequence other, int ooff, int len)
Parameter | Description |
---|---|
seq | The test CharSequence. |
toff | Offset for the test sequence. |
other | The sequence to compare to. |
ooff | Offset of the comparison sequence. |
len | How many characters to compare. |
public static boolean regionMatches(CharSequence seq, int toff, CharSequence other, int ooff, int len)
//package com.java2s; /*/*w ww . jav a 2 s. co m*/ * StandardUtilities.java - Various miscallaneous utility functions * :tabSize=4:indentSize=4:noTabs=false: * :folding=explicit:collapseFolds=1: * * Copyright (C) 1999, 2006 Matthieu Casanova, Slava Pestov * Portions copyright (C) 2000 Richard S. Hall * Portions copyright (C) 2001 Dirk Moebius * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ public class Main { /** * Implementation of String.regionMatches() for CharSequence. * * @param seq The test CharSequence. * @param toff Offset for the test sequence. * @param other The sequence to compare to. * @param ooff Offset of the comparison sequence. * @param len How many characters to compare. * @return Whether the two subsequences are equal. * @see String#regionMatches(int,String,int,int) * * @since jEdit 4.3pre15 */ public static boolean regionMatches(CharSequence seq, int toff, CharSequence other, int ooff, int len) { if (toff < 0 || ooff < 0 || len < 0) return false; boolean ret = true; for (int i = 0; i < len; i++) { char c1; if (i + toff < seq.length()) c1 = seq.charAt(i + toff); else { ret = false; break; } char c2; if (i + ooff < other.length()) c2 = other.charAt(i + ooff); else { ret = false; break; } if (c1 != c2) { ret = false; break; } } return ret; } }