List of usage examples for org.springframework.util StringUtils quote
@Nullable public static String quote(@Nullable String str)
From source file:org.springmodules.cache.config.AbstractCacheProviderFacadeParser.java
/** * Parses the given XML element to obtain the value of the property * <code>serializableFactory</code>. This property specify the factory that * forces cache entries to implement the interface <code>Serializable</code>. * /* www . j ava 2s . c o m*/ * @param element * the XML element to parse * @return the value of the property <code>serializableFactory</code> * @throws IllegalStateException * if the value of the property <code>serializableFactory</code> * is not equal to "NONE" or "XSTREAM" */ private PropertyValue parseSerializableFactoryProperty(Element element) throws IllegalStateException { String serializableFactoryAttr = element.getAttribute("serializableFactory"); if (!StringUtils.hasText(serializableFactoryAttr) || SerializableFactory.NONE.equalsIgnoreCase(serializableFactoryAttr)) { return new PropertyValue(PropertyName.SERIALIZABLE_FACTORY, null); } if (SerializableFactory.XSTREAM.equalsIgnoreCase(serializableFactoryAttr)) { return new PropertyValue(PropertyName.SERIALIZABLE_FACTORY, new XStreamSerializableFactory()); } throw new IllegalStateException( StringUtils.quote(serializableFactoryAttr) + " is not a serializableFactory. Valid values include " + StringUtils.quote(SerializableFactory.NONE) + " and " + StringUtils.quote(SerializableFactory.XSTREAM)); }
From source file:egovframework.rte.itl.integration.metadata.SystemDefinition.java
@Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(this.getClass().getName()).append(" {").append("\n\tkey = ").append(StringUtils.quote(key)); if (organization == null) { sb.append("\n\torganization = null"); } else {/*from ww w .j a v a 2s .com*/ sb.append("\n\torganization.id = ").append(StringUtils.quote(organization.getId())); } sb.append("\n\tid = ").append(StringUtils.quote(id)).append("\n\tname = ").append(StringUtils.quote(name)) .append("\n\tstandard = ").append(standard); if (services == null) { sb.append("\n\tservices = null"); } else { sb.append("\n\tservices = {"); for (Entry<String, ServiceDefinition> entry : services.entrySet()) { sb.append("\n\t\t<key = ").append(StringUtils.quote(entry.getKey())).append(", value = ") .append(entry.getValue() == null ? "" : "\n").append(entry.getValue()).append(">"); } sb.append("\n\t}"); } sb.append("\n}"); return sb.toString(); }
From source file:egovframework.rte.itl.integration.metadata.RecordTypeDefinition.java
@Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(this.getClass().getName()).append(" {").append("\n\tid = ").append(StringUtils.quote(id)) .append("\n\tname = ").append(StringUtils.quote(name)).append("\n\tparent = ") .append(parent == null ? "" : "\n").append(parent); if (fields == null) { sb.append("\n\tfields = null"); } else {/*from ww w. j a v a2s .c om*/ sb.append("\n\tfields = {"); for (Entry<String, RecordTypeFieldDefinition> entry : fields.entrySet()) { sb.append("\n\t\t<key = ").append(StringUtils.quote(entry.getKey())).append(", value = ") .append(entry.getValue() == null ? "" : "\n").append(entry.getValue()).append(">"); } sb.append("\n\t}"); } sb.append("\n}"); return sb.toString(); }
From source file:org.springmodules.cache.interceptor.caching.AbstractCachingInterceptor.java
private void validateModels() throws FatalCacheException { if (CollectionUtils.isEmpty(modelMap)) throw new FatalCacheException("The map of caching models should not be empty"); CacheModelValidator validator = cache.modelValidator(); String id = null;//from w w w.j a v a 2s . c om try { for (Iterator i = modelMap.keySet().iterator(); i.hasNext();) { id = (String) i.next(); validator.validateCachingModel(modelMap.get(id)); } } catch (Exception exception) { throw new FatalCacheException("Unable to validate caching model with id " + StringUtils.quote(id), exception); } }
From source file:egovframework.rte.itl.integration.type.AbstractType.java
@Override public String toString() { return this.getClass().getName() + " {id = " + StringUtils.quote(id) + "}"; }
From source file:egovframework.rte.itl.integration.metadata.ServiceDefinition.java
@Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(this.getClass().getName()).append(" {").append("\n\tkey = ").append(StringUtils.quote(key)); if (system == null) { sb.append("\n\tsystem = null"); } else {/*from w w w. j a v a2s.co m*/ sb.append("\n\tsystem.key = ").append(StringUtils.quote(system.getKey())); } sb.append("\n\tid = ").append(StringUtils.quote(id)).append("\n\tname = ").append(StringUtils.quote(name)) .append("\n\trequestMessageTypeId = ").append(StringUtils.quote(requestMessageTypeId)) .append("\n\tresponseMessageTypeId = ").append(StringUtils.quote(responseMessageTypeId)) .append("\n\tserivceProviderBeanId = ").append(StringUtils.quote(serviceProviderBeanId)) .append("\n\tusing = ").append(using).append("\n\tstandard = ").append(standard).append("\n}"); return sb.toString(); }
From source file:egovframework.rte.itl.webservice.data.WebServiceClientDefinition.java
@Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(this.getClass().getName()).append(" {").append("\n\tkey = ").append(StringUtils.quote(key)) .append("\n\tserviceDefinition = ").append(serviceDefinition).append("\n\tnamespace = ") .append(StringUtils.quote(namespace)).append("\n\twsdlAddress = ") .append(StringUtils.quote(wsdlAddress)).append("\n\tserviceName = ") .append(StringUtils.quote(serviceName)).append("\n\tportName = ") .append(StringUtils.quote(portName)).append("\n\toperationName = ") .append(StringUtils.quote(operationName)); if (requestMappingInfos == null) { sb.append("\n\trequestMappingInfos = null"); } else {//from ww w.j a v a 2 s. c om sb.append("\n\trequestMappingInfos = {"); for (Entry<String, MappingInfo> entry : requestMappingInfos.entrySet()) { sb.append("\n\t\t<key = ").append(StringUtils.quote(entry.getKey())).append(", value = ") .append(entry.getValue()).append(">"); } sb.append("\n\t}"); } if (responseMappingInfos == null) { sb.append("\n\tresponseMappingInfos = null"); } else { sb.append("\n\tresponseMappingInfos = {"); for (Entry<String, MappingInfo> entry : responseMappingInfos.entrySet()) { sb.append("\n\t\t<key = ").append(StringUtils.quote(entry.getKey())).append(", value = ") .append(entry.getValue()).append(">"); } sb.append("\n\t}"); } sb.append("\n}"); return sb.toString(); }
From source file:gda.util.logging.LogbackUtils.java
/** * Configures Logback for either a server- or client-side process, using a default configuration file, followed by * a specified configuration file (using the value of a property, or falling back to the value of a legacy * property).//from www .ja v a 2 s. c o m * * @param processName the name of the process for which logging is being configured * @param defaultConfigFile the default logging configuration file, which will be applied first * @param propertyName the property name to use for the custom logging configuration file */ protected static void configureLoggingForProcess(String processName, URL defaultConfigFile, String propertyName) { LoggerContext context = getLoggerContext(); // Look for the property String configFile = LocalProperties.get(propertyName); // If the property isn't found, log an error. Treat this as non-fatal, because Logback will still // be in its default state (so log messages will still be displayed on the console). if (configFile == null) { final String msg = String .format("Please set the %s property, to specify the logging configuration file", propertyName); logger.error(msg); return; } // Reset logging. resetLogging(context); // If anything goes wrong from here onwards, we should throw an exception. It's not worth trying to log the // error, since there may be no appenders. // Configure using the default logging configuration, if it can be found. if (defaultConfigFile != null) { try { configureLogging(context, defaultConfigFile); } catch (JoranException e) { final String msg = String.format("Unable to configure logging using default configuration file %s", defaultConfigFile); throw new RuntimeException(msg, e); } } // Configure using the specified logging configuration. try { //Use stdout as use of logger is no good if the logging configuration is wrong System.out.println("Configure logging using file " + StringUtils.quote(configFile)); configureLogging(context, configFile); } catch (JoranException e) { final String msg = String.format("Unable to configure logging using %s", configFile); throw new RuntimeException(msg, e); } context.putProperty(SOURCE_PROPERTY_NAME, processName); setEventDelayToZeroInAllSocketAppenders(context); }
From source file:gda.device.scannable.keyence.Keyence.java
@Override public double[] getPosition() throws DeviceException { String reply = processCommand("T1"); String[] posStrings = reply.split(","); if (!"T1".equals(posStrings[0])) { throw new DeviceException( "communication or measurement error (device not in run mode?): " + StringUtils.quote(reply)); }/*from w w w .ja v a 2 s.com*/ int positionsRead = posStrings.length - 1; if (extraNames.length > 0 && extraNames.length != positionsRead) throw new DeviceException( "unexpected number of measurements, are we running the right program? expected <" + extraNames.length + "> got <" + positionsRead + ">. Reply was " + StringUtils.quote(reply.replace("\n", "\\n").replace("\r", "\\r"))); double[] positions = new double[positionsRead]; for (int i = 1; i < posStrings.length; i++) { positions[i - 1] = Double.parseDouble(posStrings[i]); } return positions; }
From source file:org.springmodules.util.Objects.java
/** * Returns a string representation of the contents of the specified array. The * string representation consists of a list of the array's elements, enclosed * in curly braces (<code>"{}"</code>). Adjacent elements are separated by * the characters <code>", "</code> (a comma followed by a space). Returns * <code>"null"</code> if <code>array</code> is <code>null</code>. * //from w w w . j a v a2s. c o m * @param array * the array whose string representation to return. * @return a string representation of <code>array</code>. */ public static String nullSafeToString(String[] array) { if (array == null) return NULL_ARRAY; int length = array.length; if (length == 0) return EMPTY_ARRAY; StringBuffer buffer = new StringBuffer(); for (int i = 0; i < length; i++) { if (i == 0) buffer.append(ARRAY_START); else buffer.append(ARRAY_ELEMENT_SEPARATOR); buffer.append(StringUtils.quote(array[i])); } buffer.append(ARRAY_END); return buffer.toString(); }