List of usage examples for java.lang StringBuffer substring
@Override public synchronized String substring(int start)
From source file:org.kuali.kra.proposaldevelopment.rule.event.CalculateCreditSplitEvent.java
@Override protected void logEvent() { StringBuffer logMessage = new StringBuffer(StringUtils.substringAfterLast(this.getClass().getName(), ".")); logMessage.append(" with "); for (ProposalPerson person : ((ProposalDevelopmentDocument) getDocument()).getDevelopmentProposal() .getProposalPersons()) {/* w w w . j a va 2 s. c om*/ logMessage.append(person.toString()); logMessage.append(", "); } if (logMessage.substring(logMessage.length() - 2).equals(", ")) { logMessage.delete(logMessage.length() - 2, logMessage.length()); } debug(logMessage); }
From source file:org.kuali.coeus.propdev.impl.person.SaveKeyPersonEvent.java
/** * Logs the event type and some information about the associated accountingLine *///from ww w. java 2s . c om protected void logEvent() { StringBuffer logMessage = new StringBuffer(StringUtils.substringAfterLast(this.getClass().getName(), ".")); logMessage.append(" with "); for (ProposalPerson person : ((ProposalDevelopmentDocument) getDocument()).getDevelopmentProposal() .getProposalPersons()) { logMessage.append(person.toString()); logMessage.append(", "); } if (logMessage.substring(logMessage.length() - 2).equals(", ")) { logMessage.delete(logMessage.length() - 2, logMessage.length()); } LOG.debug(logMessage); }
From source file:org.kuali.kra.proposaldevelopment.rule.event.SaveKeyPersonEvent.java
/** * Logs the event type and some information about the associated accountingLine *//*ww w .j a v a 2s. c o m*/ protected void logEvent() { StringBuffer logMessage = new StringBuffer(StringUtils.substringAfterLast(this.getClass().getName(), ".")); logMessage.append(" with "); for (ProposalPerson person : ((ProposalDevelopmentDocument) getDocument()).getDevelopmentProposal() .getProposalPersons()) { logMessage.append(person.toString()); logMessage.append(", "); } if (logMessage.substring(logMessage.length() - 2).equals(", ")) { logMessage.delete(logMessage.length() - 2, logMessage.length()); } debug(logMessage); }
From source file:org.iterx.miru.spring.beans.SpringBeanFactory.java
public Object getBeanOfType(Class[] types) { assert (types != null && types.length > 0) : "types == null"; try {/* w w w.ja v a 2 s .c o m*/ Map map; if ((factory instanceof ListableBeanFactory) && (map = BeanFactoryUtils.beansOfTypeIncludingAncestors((ListableBeanFactory) factory, types[0], true, false)).size() > 0) { for (Iterator beans = (map.values()).iterator(); beans.hasNext();) { Object bean; Class cls; int i; cls = (bean = beans.next()).getClass(); for (i = types.length; i-- > 1;) { if (!types[i].isAssignableFrom(cls)) break; } if (i < 1) return bean; } } } catch (BeansException e) { if (logger.isDebugEnabled()) { StringBuffer buffer; buffer = new StringBuffer(); for (int i = 0; i < types.length; i++) { buffer.append(','); buffer.append(types[i]); } logger.debug("Failed to create bean implementation [" + buffer.substring(1) + "]", e); } } return (parent != null) ? parent.getBeanOfType(types) : null; }
From source file:org.bibsonomy.rest.RestServlet.java
/** * Strips the API URL part from the beginning of the complete URL. * //from w w w.j ava2 s .c om * @param request * @return */ private String getPathInfo(final HttpServletRequest request) { final String pathInfo = request.getPathInfo(); if (present(pathInfo)) return pathInfo; final StringBuffer url = request.getRequestURL(); return url.substring(urlRenderer.getApiUrl().length()).toString(); }
From source file:com.quartercode.classmod.extra.def.DefaultFunctionInvocation.java
@Override public R next(Object... arguments) throws ExecutorInvocationException { // Argument validation try {/*from w w w .j ava2 s . co m*/ List<Class<?>> parameters = source.getParameters(); // Generate error string StringBuffer errorStringBuffer = new StringBuffer(); for (Class<?> parameter : parameters) { errorStringBuffer.append(", ").append(parameter.getSimpleName()); } String errorString = "Wrong arguments: '" + (errorStringBuffer.length() == 0 ? "" : errorStringBuffer.substring(2)) + "' required"; // Check all arguments for (int index = 0; index < parameters.size(); index++) { if (!parameters.get(index).isAssignableFrom(arguments[index].getClass())) { Validate.isTrue(parameters.get(index).isArray(), errorString); for (int varargIndex = index; varargIndex < arguments.length; varargIndex++) { Validate.isTrue(parameters.get(index).getComponentType() .isAssignableFrom(arguments[varargIndex].getClass()), errorString); } } } } catch (IllegalArgumentException e) { throw new ExecutorInvocationException(e); } if (remainingExecutors.size() == 0) { // Abort because all executors were already invoked return null; } else { try { return remainingExecutors.poll().invoke(this, arguments); } catch (RuntimeException e) { throw new ExecutorInvocationException(); } } }
From source file:org.iterx.miru.support.spring.bean.factory.SpringBeanFactory.java
public Object getBeanOfType(Class[] types) { assert (types != null && types.length > 0) : "types == null"; try {//from w w w . j a v a 2 s .c om String[] names; if ((beanFactory instanceof ListableBeanFactory) && (names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors( (ListableBeanFactory) beanFactory, types[0], true, false)).length > 0) { for (int i = 0; i < names.length; i++) { Object object; String name; int j; name = names[i]; object = beanFactory.getBean(name); for (j = types.length; j-- > 1;) { if (!types[j].isAssignableFrom(object.getClass())) break; } if (j < 1) { if (object instanceof BeanAware) ((BeanAware) object).setId(name); return object; } } } } catch (BeansException e) { if (LOGGER.isWarnEnabled()) { StringBuffer buffer; buffer = new StringBuffer(); for (int i = 0; i < types.length; i++) { buffer.append(','); buffer.append(types[i]); } LOGGER.warn("Failed to create bean implementation [" + buffer.substring(1) + "]", e); } } return (parent != null) ? parent.getBeanOfType(types) : null; }
From source file:URLUtilities.java
/** * Build an HTTP URL relative to the application context using the given path. This is a path * such as http://servername/webapp/path/myfile.html * * @return /webapp/path/myfile.html//from w ww. j a va2 s .c o m */ public String requestPath() { if (fieldRequest == null) { return null; } StringBuffer ctx = fieldRequest.getRequestURL(); String requestPath = ctx.substring(ctx.indexOf("/", 7)); //just the path return requestPath; }
From source file:edu.jhu.cvrg.waveform.utility.WebServiceUtility.java
/** Looks up the long definition text from the/ECGOntology at Bioportal for the specfied tree node ID. * /* ww w .j av a2s. c o m*/ * @param treeNodeID - the id to look up, as supplied by the OntologyTree popup. * @return - long definition text */ public static String annotationXMLLookup(String restURL) { String definition = "WARNING TEST FILLER From BrokerServiceImpl.java"; String label = "TEST LABEL"; String sReturn = ""; URL url; try { url = new URL(restURL); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String inputLine; boolean isDescriptionFollowing = false; StringBuffer buff = null; while ((inputLine = in.readLine()) != null) { String regex = "^\\s+<label>\\w+</label>$"; boolean bLabel = inputLine.matches(regex); if (bLabel) { label = inputLine.trim(); } if (isDescriptionFollowing) { // <label> if (inputLine.length() != 0) { if (inputLine.indexOf("</definitions>") > -1) { isDescriptionFollowing = false; break; } else { buff.append(inputLine); } } } else { if (inputLine.indexOf("<definitions>") > -1) { isDescriptionFollowing = true; buff = new StringBuffer(); } } } in.close(); if (buff.length() > 0) { definition = buff.substring(0); definition = definition.replace("/n", ""); definition = definition.replace("<string>", ""); definition = definition.replace("</string>", ""); definition = definition.trim(); } else { definition = "Detailed definition not available."; } sReturn = label + definition; } catch (MalformedURLException mue) { mue.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } return sReturn; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppObj.java
private String getRenderableClause() { if (mRenderableClause != null) { String renderable = mRenderableClause.get(); if (renderable != null) { return renderable; }//w ww .j a v a2 s.c o m } StringBuffer allowed = new StringBuffer(); String[] types = DbObjects.getRenderableTypes(); for (String type : types) { if (!AppObj.TYPE.equals(type)) { allowed.append(",'").append(type).append("'"); } } String clause = DbObject.TYPE + " in (" + allowed.substring(1) + ")"; mRenderableClause = new SoftReference<String>(clause); return clause; }