@Override public boolean apply(ClassInfo info) { return info.className.indexOf('$') == -1; } };
/** * Returns the index of the first character in {@code input} that contains a character in {@code * delimiters}. Returns limit if there is no such character. */ public static int delimiterOffset(String input, int pos, int limit, String delimiters) { for (int i = pos; i < limit; i++) { if (delimiters.indexOf(input.charAt(i)) != -1) return i; } return limit; }
@Override public int read() throws IOException { int readChar; do { readChar = delegate.read(); } while (readChar != -1 && toIgnore.indexOf((char) readChar) >= 0); return readChar; }
/** * Try to consume the supplied token against the supplied content and update the * in comment parse state to the supplied value. Returns the index into the content * which is after the token or -1 if the token is not found. */ private int commentToken(String line, String token, boolean inCommentIfPresent) { int index = line.indexOf(token); if (index > - 1) { this.inComment = inCommentIfPresent; } return (index == -1 ? index : index + token.length()); }
private int getEndPathIndex(String lookupPath) { int suffixIndex = lookupPath.length(); int queryIndex = lookupPath.indexOf('?'); if (queryIndex > 0) { suffixIndex = queryIndex; } int hashIndex = lookupPath.indexOf('#'); if (hashIndex > 0) { suffixIndex = Math.min(suffixIndex, hashIndex); } return suffixIndex; }
/** * Returns the next index in {@code input} at or after {@code pos} that contains a character from * {@code characters}. Returns the input length if none of the requested characters can be found. */ public static int skipUntil(String input, int pos, String characters) { for (; pos < input.length(); pos++) { if (characters.indexOf(input.charAt(pos)) != -1) { break; } } return pos; }
/** * Extract the "raw" bean name from the given (potentially generated) bean name, * excluding any "#..." suffixes which might have been added for uniqueness. * @param name the potentially generated bean name * @return the raw bean name * @see #GENERATED_BEAN_NAME_SEPARATOR */ public static String originalBeanName(String name) { Assert.notNull(name, "'name' must not be null"); int separatorIndex = name.indexOf(GENERATED_BEAN_NAME_SEPARATOR); return (separatorIndex != -1 ? name.substring(0, separatorIndex) : name); }
boolean matches(String hostname) { if (pattern.startsWith(WILDCARD)) { int firstDot = hostname.indexOf('.'); return (hostname.length() - firstDot - 1) == canonicalHostname.length() && hostname.regionMatches(false, firstDot + 1, canonicalHostname, 0, canonicalHostname.length()); } return hostname.equals(canonicalHostname); }
private static String getSubmittedFileName(Part part) { for (String cd : part.getHeader("content-disposition").split(";")) { if (cd.trim().startsWith("filename")) { String fileName = cd.substring(cd.indexOf('=') + 1).trim().replace("\"", ""); return fileName.substring(fileName.lastIndexOf('/') + 1).substring(fileName.lastIndexOf('\\') + 1); // MSIE fix. } } return null; }
/** Add an header line containing a field name, a literal colon, and a value. */ public Builder add(String line) { int index = line.indexOf(":"); if (index == -1) { throw new IllegalArgumentException("Unexpected header: " + line); } return add(line.substring(0, index).trim(), line.substring(index + 1)); }
@Override public boolean canDecode(CharSequence chars) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < chars.length(); i++) { char c = chars.charAt(i); if (separator.indexOf(c) < 0) { builder.append(c); } } return delegate.canDecode(builder); }
@Override int decodeTo(byte[] target, CharSequence chars) throws DecodingException { StringBuilder stripped = new StringBuilder(chars.length()); for (int i = 0; i < chars.length(); i++) { char c = chars.charAt(i); if (separator.indexOf(c) < 0) { stripped.append(c); } } return delegate.decodeTo(target, stripped); }
protected int extractLink(int index, char endChar, String content, Set<ContentChunkInfo> result) { int start = index + 1; int end = content.indexOf(endChar, start); result.add(new ContentChunkInfo(start, end, true)); return end + 1; }
public static Method findMethod(String desc, ClassLoader loader) { try { int lparen = desc.indexOf('('); int dot = desc.lastIndexOf('.', lparen); String className = desc.substring(0, dot).trim(); String methodName = desc.substring(dot + 1, lparen).trim(); return getClass(className, loader).getDeclaredMethod(methodName, parseTypes(desc, loader)); } catch (ClassNotFoundException | NoSuchMethodException ex) { throw new CodeGenerationException(ex); } }
public static Constructor findConstructor(String desc, ClassLoader loader) { try { int lparen = desc.indexOf('('); String className = desc.substring(0, lparen).trim(); return getClass(className, loader).getConstructor(parseTypes(desc, loader)); } catch (ClassNotFoundException | NoSuchMethodException ex) { throw new CodeGenerationException(ex); } }
@Test public void testExceptionStackTrace() { JMSException jmsEx = new JMSException("could not connect"); Exception innerEx = new Exception("host not found"); jmsEx.setLinkedException(innerEx); JmsException springJmsEx = JmsUtils.convertJmsAccessException(jmsEx); StringWriter sw = new StringWriter(); PrintWriter out = new PrintWriter(sw); springJmsEx.printStackTrace(out); String trace = sw.toString(); assertTrue("inner jms exception not found", trace.indexOf("host not found") > 0); }
@Test public void testAdviceUsingJoinPoint() { ClassPathXmlApplicationContext bf = newContext("usesJoinPointAspect.xml"); ITestBean adrian1 = (ITestBean) bf.getBean("adrian"); adrian1.getAge(); AdviceUsingThisJoinPoint aspectInstance = (AdviceUsingThisJoinPoint) bf.getBean("aspect"); //(AdviceUsingThisJoinPoint) Aspects.aspectOf(AdviceUsingThisJoinPoint.class); //assertEquals("method-execution(int TestBean.getAge())",aspectInstance.getLastMethodEntered()); assertTrue(aspectInstance.getLastMethodEntered().indexOf("TestBean.getAge())") != 0); }