@Override public String toString() { return Strings.concat(cause, ": ", message); } }
/** * Set the host address for client connected to this event stream. * * @param remoteHost client remote host address. */ protected void setRemoteHost(String remoteHost) { if (string == null) { string = Strings.concat('#', STREAM_ID++, ':', remoteHost); } }
/** * Get source line for the caller method. * * @return caller method. */ public static String getCallerMethod() { StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); if(stackTrace.length == 0) { return "unknown"; } final StackTraceElement e = stackTrace[0]; return Strings.concat(e.getClassName(), '#', e.getMethodName(), ':', e.getLineNumber()); }
@Override public boolean hasCssClass(String classToMatch) { String classes = node.getAttribute(ATTR_CLASS); if (classes.isEmpty()) { return false; } Pattern pattern = Pattern.compile(Strings.concat(LEADING_SPACE_REX, Strings.escapeRegExp(classToMatch), TRAILING_SPACE_REX)); Matcher matcher = pattern.matcher(classes); return matcher.find(); }
@Override public Element removeCssClass(String classToRemove) { String classes = node.getAttribute(ATTR_CLASS); if (classes.isEmpty()) { return this; } Pattern pattern = Pattern.compile(Strings.concat(LEADING_SPACE_REX, Strings.escapeRegExp(classToRemove), TRAILING_SPACE_REX)); Matcher matcher = pattern.matcher(classes); node.setAttribute(ATTR_CLASS, matcher.replaceFirst(" ").trim()); return this; }
/** * Construct view meta instance. * * @param file template file, * @param implementation implementation class, * @param properties optional view instance specific properties. */ public ViewMeta(File file, Class<? extends View> implementation, Properties properties) { this.name = Files.basename(file); this.file = file; this.implementation = implementation; this.properties = properties; this.string = Strings.concat(name, ':', implementation.getName(), ':', file); }
/** * Dump circular dependencies stack to error log but leave stack unchanged. * * @param value current value object on which circular dependency was discovered. */ private void dumpCircularDependenciesStack(Object value) { ListIterator<Object> it = circularDependenciesStack.listIterator(circularDependenciesStack.size()); StringBuilder dump = new StringBuilder(); while (it.hasPrevious()) { dump.append(Strings.concat("\t- ", it.previous().getClass().getName(), "\r\n")); } log.error("Circular dependecies on value object |%s|. Set it to null. Stack dump:\r\n%s", value.getClass().getName(), dump.toString()); } }
this.mime = Strings.concat(type, '/', subtype);
throw new IndexOutOfBoundsException(Strings.concat("Array Size=", bytes.length, ", offset=", off, ", length=", len));
/** * Servlet life cycle callback executed at this servlet instance initialization. Mainly takes care to initialize parent * container reference. If there is no servlet context attribute with the name {@link TinyContainer#ATTR_INSTANCE} this * initialization fails with servlet permanently unavailable. * <p> * Parent container instance has application life span and its reference is valid for entire life span of this servlet * instance. * * @param config servlet configuration object. * @throws UnavailableException if tiny container is not properly initialized. */ @Override public void init(ServletConfig config) throws UnavailableException { container = (ContainerSPI) config.getServletContext().getAttribute(TinyContainer.ATTR_INSTANCE); if (container == null) { log.fatal("Tiny container instance not properly created, probably misconfigured. Servlet |%s| permanently unvailable.", config.getServletName()); throw new UnavailableException("Tiny container instance not properly created, probably misconfigured."); } servletName = Strings.concat(config.getServletContext().getServletContextName(), '#', config.getServletName()); log.trace("Initialize servlet |%s|.", servletName); }
@Override public Element setRichText(String richText) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new EntityResolverImpl()); org.w3c.dom.Document doc = db.parse(new InputSource(new StringReader(Strings.concat(XML_DECL, XML_DOCTYPE, XML_ROOT_START, richText, XML_ROOT_END)))); Node richTextNode = ownerDoc.getDocument().importNode(doc.getDocumentElement(), true); DocumentFragment richTextFragment = ownerDoc.getDocument().createDocumentFragment(); while (richTextNode.hasChildNodes()) { richTextFragment.appendChild(richTextNode.removeChild(richTextNode.getFirstChild())); } removeChildren(); node.appendChild(richTextFragment); } catch (ParserConfigurationException e) { throw new BugError(e); } catch (SAXException e) { throw new DomException("Invalid fragment source."); } catch (IOException e) { throw new BugError(e); } return this; }
return value; return value.replace(Strings.concat("${", variableName, '}'), variableValue);
context.setRequestURL(queryString != null ? Strings.concat(requestURI, '?', queryString) : requestURI);
@Override public void config(Config config) throws ConfigException { super.config(config); // by convention configuration object name is the web application name appName = config.getName(); privateDir = server.getAppDir(appName); if (!privateDir.exists()) { privateDir.mkdir(); } Config loginConfig = config.getChild("login"); if (loginConfig != null) { loginRealm = loginConfig.getProperty("realm", appName); loginPage = loginConfig.getProperty("page"); if (loginPage != null && !loginPage.startsWith("/")) { loginPage = Strings.concat('/', appName, '/', loginPage); } } }