List of usage examples for org.springframework.util StringUtils quote
@Nullable public static String quote(@Nullable String str)
From source file:org.springmodules.cache.impl.CacheAlreadyExistsException.java
/** * Constructor.//from ww w . j a va 2 s.c o m * * @param cacheName * the name of the cache that already exists in the cache manager */ public CacheAlreadyExistsException(String cacheName) { super("The cache " + StringUtils.quote(cacheName) + " already exists"); }
From source file:org.springmodules.cache.serializable.Puppy.java
/** * @see Object#toString()/*from w w w . j a v a 2 s .c om*/ */ public String toString() { return Objects.identityToString(this).append("[name=").append(StringUtils.quote(name)).append(']') .toString(); }
From source file:gda.device.detector.mythen.data.SimpleAngularCalibrationParameters.java
/** * Reads the angular calibration parameters in the specified file. * //from ww w . j a v a 2 s . co m * @param file the angular calibration file */ public SimpleAngularCalibrationParameters(File file) { parameters = new HashMap<Integer, Double>(); try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)))) { String line; while ((line = br.readLine()) != null) { String[] bits = line.trim().split("\t"); int module = Integer.parseInt(bits[0]); double centre = Double.parseDouble(bits[1]); parameters.put(module, centre); } } catch (IOException e) { throw new RuntimeException("Could not load angular calibration parameters from " + StringUtils.quote(file.getAbsolutePath()), e); } }
From source file:org.springmodules.cache.interceptor.flush.MethodMapFlushingInterceptor.java
/** * @see AbstractFlushingInterceptor#onAfterPropertiesSet() *///w ww. j a v a 2 s . c om protected void onAfterPropertiesSet() throws FatalCacheException { Map flushingModels = getFlushingModels(); if (flushingModels != null && !flushingModels.isEmpty() && getFlushingModelSource() == null) { MethodMapFlushingModelSource newSource = new MethodMapFlushingModelSource(); String key = null; try { for (Iterator i = flushingModels.keySet().iterator(); i.hasNext();) { key = (String) i.next(); FlushingModel model = (FlushingModel) flushingModels.get(key); newSource.addModel(model, key); } } catch (Exception exception) { throw new FatalCacheException("Unable to add model stored under the key " + StringUtils.quote(key), exception); } setFlushingModelSource(newSource); } }
From source file:org.springmodules.cache.util.SemicolonSeparatedPropertiesParser.java
/** * Creates a <code>java.util.Properties</code> from the specified String. * * @param text/* ww w. j av a 2 s . c o m*/ * the String to parse. * @throws IllegalArgumentException * if the specified property does not match the regular expression * pattern defined in <code>KEY_VALUE_REGEX</code>. * @throws IllegalArgumentException * if the set of properties already contains the property specified * by the given String. * @return a new instance of <code>java.util.Properties</code> created from * the given text. */ public static Properties parseProperties(String text) throws IllegalArgumentException { String newText = text; if (!StringUtils.hasText(newText)) { return null; } if (newText.endsWith(PROPERTY_DELIMITER)) { // remove ';' at the end of the text (if applicable) newText = newText.substring(0, newText.length() - PROPERTY_DELIMITER.length()); if (!StringUtils.hasText(newText)) { return null; } } Properties properties = new Properties(); String[] propertiesAsText = StringUtils.delimitedListToStringArray(newText, PROPERTY_DELIMITER); int propertyCount = propertiesAsText.length; for (int i = 0; i < propertyCount; i++) { String property = propertiesAsText[i]; Match match = KEY_VALUE_REGEX.match(property); if (!match.isSuccessful()) { String message = "The String " + StringUtils.quote(property) + " should match the regular expression pattern " + StringUtils.quote(KEY_VALUE_REGEX.getPattern()); throw new IllegalArgumentException(message); } String[] groups = match.getGroups(); String key = groups[1].trim(); String value = groups[2].trim(); if (properties.containsKey(key)) { throw new IllegalArgumentException( "The property " + StringUtils.quote(key) + " is specified more than once"); } properties.setProperty(key, value); } return properties; }
From source file:org.springmodules.cache.interceptor.caching.MethodMapCachingInterceptor.java
/** * @see AbstractCachingInterceptor#onAfterPropertiesSet() */// w ww.j av a 2s .c o m protected void onAfterPropertiesSet() throws FatalCacheException { CachingModelSource cachingModelSource = getCachingModelSource(); if (cachingModelSource == null) { MethodMapCachingModelSource newSource = new MethodMapCachingModelSource(); Map models = models(); String key = null; try { for (Iterator i = models.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); key = (String) entry.getKey(); newSource.addModel((CachingModel) entry.getValue(), key); } } catch (Exception exception) { throw new FatalCacheException("Unable to add model stored under the key " + StringUtils.quote(key), exception); } setCachingModelSource(newSource); } }
From source file:gda.gui.text.parameter.EpicsPanelParameterListener.java
/** * @param deviceName//from w w w. java 2 s.co m * @param recordName * @param fieldName * @param putTimeOut * @param initialValue */ public EpicsPanelParameterListener(String deviceName, String recordName, String fieldName, Double putTimeOut, double initialValue) { this.putTimeOut = putTimeOut; lastSuccessfullySentValue = initialValue; IEpicsDevice experimentEpicsDevice = (IEpicsDevice) Finder.getInstance().find(deviceName); if (experimentEpicsDevice == null) throw new IllegalArgumentException( " ParametersPanelListener. unable to find device " + StringUtils.quote(deviceName)); // if putTimeout is not defined then use -1.0 to make epics device use // default // if put Timeout is null then run in a separate thread as the caller // does not care about the result epicsChannel = experimentEpicsDevice.createEpicsChannel(ReturnType.DBR_NATIVE, recordName, fieldName, putTimeOut != null ? putTimeOut : -1.0); }
From source file:org.springmodules.cache.config.BeanReferenceParserImpl.java
/** * @see BeanReferenceParser#parse(Element,ParserContext,boolean) *//*from w ww .j a va2s.c o m*/ public Object parse(Element element, ParserContext parserContext, boolean registerInnerBean) { String refId = element.getAttribute("refId"); if (StringUtils.hasText(refId)) { return new RuntimeBeanReference(refId); } Element beanElement = null; List beanElements = DomUtils.getChildElementsByTagName(element, "bean"); if (!CollectionUtils.isEmpty(beanElements)) { beanElement = (Element) beanElements.get(0); } if (beanElement == null) { throw new IllegalStateException("The XML element " + StringUtils.quote(element.getNodeName()) + " should either have a " + "reference to an already registered bean definition or contain a " + "bean definition"); } BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(beanElement); String beanName = holder.getBeanName(); if (registerInnerBean && StringUtils.hasText(beanName)) { BeanDefinitionRegistry registry = parserContext.getRegistry(); BeanDefinition beanDefinition = holder.getBeanDefinition(); registry.registerBeanDefinition(beanName, beanDefinition); return new RuntimeBeanReference(beanName); } return holder; }
From source file:gda.gui.epics.EpicsMonitor.java
/** * @param returnType//www .ja v a 2s.c o m * @param deviceName * @param recordName * @param fieldName * @param observer * @param callListenerOnSwingEventThread */ private EpicsMonitor(ReturnType returnType, String deviceName, String recordName, String fieldName, EpicsMonitorListener observer, boolean callListenerOnSwingEventThread, boolean autoStart) { if (observer == null) throw new IllegalArgumentException("Observer is null"); this.returnType = returnType; this.recordName = recordName; this.fieldName = fieldName; this.observer = observer; this.callListenerOnSwingEventThread = callListenerOnSwingEventThread; experimentEpicsDevice = (IEpicsDevice) Finder.getInstance().find(deviceName); if (experimentEpicsDevice == null) throw new IllegalArgumentException("Cannot find device " + StringUtils.quote(deviceName)); if (autoStart) { start(); } }
From source file:org.springmodules.cache.interceptor.caching.Cached.java
/** * @see Object#toString()/*w w w .j a v a 2s. c om*/ */ public String toString() { return Objects.identityToString(this).append("[modelId=").append(StringUtils.quote(modelId)).append("]") .toString(); }