Here you can find the source of range(String field, int start, int end)
Parameter | Description |
---|---|
field | The field |
start | Range starts |
end | Range ends |
public static boolean range(String field, int start, int end)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 - 2013 Ushahidi Inc. * All rights reserved/*from w w w .j a va2 s. com*/ * Website: http://www.ushahidi.com * * GNU AFFERO GENERAL PUBLIC LICENSE Version 3 Usage * This file may be used under the terms of the GNU AFFERO GENERAL * PUBLIC LICENSE Version 3 as published by the Free Software * Foundation and appearing in the file LICENSE included in the * packaging of this file. Please review the following information to * ensure the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 requirements * will be met: http://www.gnu.org/licenses/agpl.html. ******************************************************************************/ public class Main { /** * Validate how long a field can be * * @param field The field * @param start Range starts * @param end Range ends * @return True if the field is within range */ public static boolean range(String field, int start, int end) { if (field == null) { return false; } int length = field.length(); if (end >= length) { end = length - 1; } return (start >= 0) && (end >= 0) && (start <= end) && (length > 0); } }