@Override public CharSequence subSequence(int start, int end) { return string.subSequence(start, end); }
@Override public CharSequence subSequence(int start, int end) { return string.subSequence(start, end); } }
@Override public CharSequence subSequence(int start, int end) { return "foo".subSequence(start, end); }
public static CharSequence filterOutBrotliFromAcceptEncoding(String acceptEncoding) { // we don't support Brotly ATM if (acceptEncoding.endsWith(BROTLY_ACCEPT_ENCODING_SUFFIX)) { return acceptEncoding.subSequence(0, acceptEncoding.length() - BROTLY_ACCEPT_ENCODING_SUFFIX.length()); } return acceptEncoding; } }
@Override public CharSequence subSequence(final int arg0, final int arg1) { return value.subSequence(arg0, arg1); }
@Override public CharSequence subSequence(int start, int end) { return toString().subSequence(start, end); }
@Override public CharSequence subSequence(int start, int end) { return toString().subSequence(start, end); }
/** * Get LineColumn from string till index. * @param source Source string. * @param index An index into the string. * @return A position in the source representing what line and column that index appears on. */ private static LineColumn getLineColumnOfIndex(String source, int index) { final String precedingText = source.subSequence(0, index).toString(); final String[] precedingLines = NEWLINE_PATTERN.split(precedingText); final String lastLine = precedingLines[precedingLines.length - 1]; return new LineColumn(precedingLines.length, lastLine.length()); }
@Override public CharSequence subSequence(int start, int end) { return s.subSequence(start, end); }
@Override public CharSequence subSequence(int beginIndex, int endIndex) { return contents().subSequence(beginIndex, endIndex); }
@Override public final CharSequence subSequence(int start, int end) { return toString().subSequence(start, end); }
@Override public CharSequence subSequence(final int start, final int end) { return seq.subSequence(start, end); }
public static Object parseMockValue(String mock, Type[] returnTypes) throws Exception { Object value = null; if ("empty".equals(mock)) { value = ReflectUtils.getEmptyObject(returnTypes != null && returnTypes.length > 0 ? (Class<?>) returnTypes[0] : null); } else if ("null".equals(mock)) { value = null; } else if ("true".equals(mock)) { value = true; } else if ("false".equals(mock)) { value = false; } else if (mock.length() >= 2 && (mock.startsWith("\"") && mock.endsWith("\"") || mock.startsWith("\'") && mock.endsWith("\'"))) { value = mock.subSequence(1, mock.length() - 1); } else if (returnTypes != null && returnTypes.length > 0 && returnTypes[0] == String.class) { value = mock; } else if (StringUtils.isNumeric(mock)) { value = JSON.parse(mock); } else if (mock.startsWith("{")) { value = JSON.parseObject(mock, Map.class); } else if (mock.startsWith("[")) { value = JSON.parseObject(mock, List.class); } else { value = mock; } if (ArrayUtils.isNotEmpty(returnTypes)) { value = PojoUtils.realize(value, (Class<?>) returnTypes[0], returnTypes.length > 1 ? returnTypes[1] : null); } return value; }
public static Object parseMockValue(String mock, Type[] returnTypes) throws Exception { Object value = null; if ("empty".equals(mock)) { value = ReflectUtils.getEmptyObject(returnTypes != null && returnTypes.length > 0 ? (Class<?>) returnTypes[0] : null); } else if ("null".equals(mock)) { value = null; } else if ("true".equals(mock)) { value = true; } else if ("false".equals(mock)) { value = false; } else if (mock.length() >= 2 && (mock.startsWith("\"") && mock.endsWith("\"") || mock.startsWith("\'") && mock.endsWith("\'"))) { value = mock.subSequence(1, mock.length() - 1); } else if (returnTypes != null && returnTypes.length > 0 && returnTypes[0] == String.class) { value = mock; } else if (StringUtils.isNumeric(mock)) { value = JSON.parse(mock); } else if (mock.startsWith("{")) { value = JSON.parseObject(mock, Map.class); } else if (mock.startsWith("[")) { value = JSON.parseObject(mock, List.class); } else { value = mock; } if (ArrayUtils.isNotEmpty(returnTypes)) { value = PojoUtils.realize(value, (Class<?>) returnTypes[0], returnTypes.length > 1 ? returnTypes[1] : null); } return value; }
boolean isVersionOnedotSixOrHigher(String hgout) { String hgVersion = parseGitVersion(hgout); Float aFloat = NumberUtils.createFloat(hgVersion.subSequence(0, 3).toString()); return aFloat >= 1.6; }
boolean isVersionOnedotZeorOrHigher(String hgout) { String hgVersion = parseHgVersion(hgout); Float aFloat = NumberUtils.createFloat(hgVersion.subSequence(0, 3).toString()); return aFloat >= 1; }
private static void checkDbIdentifierCharacters(String identifier, String identifierDesc) { checkArgument(identifier.length() > 0, "Identifier must not be empty"); checkArgument( LOWER_CASE_ASCII_LETTERS_CHAR_MATCHER.or(DIGIT_CHAR_MATCHER).or(anyOf("_")).matchesAllOf(identifier), "%s must be lower case and contain only alphanumeric chars or '_', got '%s'", identifierDesc, identifier); checkArgument( DIGIT_CHAR_MATCHER.or(UNDERSCORE_CHAR_MATCHER).matchesNoneOf(identifier.subSequence(0, 1)), "%s must not start by a number or '_', got '%s'", identifierDesc, identifier); } }
@Test public void testSpeedCheck3() throws EncoderException { final BeiderMorseEncoder bmpm = this.createGenericApproxEncoder(); final String phrase = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; for (int i = 1; i <= phrase.length(); i++) { bmpm.encode(phrase.subSequence(0, i)); } } }
@Test public void testSpeedCheck2() throws EncoderException { final BeiderMorseEncoder bmpm = this.createGenericApproxEncoder(); final String phrase = "ItstheendoftheworldasweknowitandIfeelfine"; for (int i = 1; i <= phrase.length(); i++) { bmpm.encode(phrase.subSequence(0, i)); } }
@Test public void givenInitializingWithAttributeSet_whenMaxLengthDefined_thenRestrictTextLengthToMaxLength() { int maxLength = anyInteger(); AttributeSet attrs = Robolectric.buildAttributeSet() .addAttribute(android.R.attr.maxLength, maxLength + "") .build(); EditText editText = new EditText(context, attrs); String excessiveInput = stringOfLength(maxLength * 2); editText.setText(excessiveInput); assertThat((CharSequence) editText.getText().toString()).isEqualTo(excessiveInput.subSequence(0, maxLength)); }