List of usage examples for org.springframework.util StringUtils quote
@Nullable public static String quote(@Nullable String str)
From source file:gda.configuration.properties.LocalProperties.java
public static void checkForObsoleteProperties() { final String GDA_OBJECT_DELIMITER = "gda.objectDelimiter"; if (get(GDA_OBJECT_DELIMITER) != null) { logger.warn("Please remove the " + StringUtils.quote(GDA_OBJECT_DELIMITER) + " property from your java.properties file - it is not used any more"); }/*from ww w. j a v a2s . c om*/ final String GDA_EVENTRECEIVER_PURGE = "gda.eventreceiver.purge"; if (get(GDA_EVENTRECEIVER_PURGE) != null) { logger.warn("Please remove the " + StringUtils.quote(GDA_EVENTRECEIVER_PURGE) + " property from your java.properties file - CorbaEventReceiver does not purge events any more"); } final String GDA_USERS = "gda.users"; if (get(GDA_USERS) != null) { logger.warn("Please remove the " + StringUtils.quote(GDA_USERS) + " property from your java.properties file - this property was used ambiguously and should not be used any more"); } final String GDA_JYTHON_GDASCRIPTDIR = "gda.jython.gdaScriptDir"; if (get(GDA_JYTHON_GDASCRIPTDIR) != null) { logger.warn("Please remove the " + StringUtils.quote(GDA_JYTHON_GDASCRIPTDIR) + "property from your java.properties file - script paths are defined in the Spring configuration for the command_server."); } final String GDA_JYTHON_USERSCRIPTDIR = "gda.jython.userScriptDir"; if (get(GDA_JYTHON_USERSCRIPTDIR) != null) { logger.warn("Please remove the " + StringUtils.quote(GDA_JYTHON_USERSCRIPTDIR) + "property from your java.properties file - script paths are defined in the Spring configuration for the command_server."); } }
From source file:gda.data.scan.datawriter.NexusDataWriter.java
void writeHere(NeXusFileInterface file, INexusTree tree, boolean makeData, boolean attrOnly, List<SelfCreatingLink> links) throws NexusException { if (!tree.isPointDependent() && !makeData) { return;//from www . j ava 2 s. co m } String name = tree.getName(); String nxClass = tree.getNxClass(); Boolean dataOpen = false; Boolean loopNodes = true; Boolean attrBelowThisOnly = attrOnly; Boolean nxClassIsSDS = nxClass.equals(NexusExtractor.SDSClassName); Boolean nxClassIsAttr = nxClass.equals(NexusExtractor.AttrClassName); Boolean nxClassIsExternalSDS = nxClass.equals(NexusExtractor.ExternalSDSLink); if (nxClassIsExternalSDS) { if (makeData) { NexusGroupData data = tree.getData(); try { /** * Create a link of the format * "nxfile://" + path to external file relative to nxs file + "#" + address * * The buffer in data contains * "nxfile://" + abs path to external file + "#" + address * * so we need to replace the abs path with the relative path */ String link = new String((byte[]) data.getBuffer(), "UTF-8"); //link is of format nxfile:// + filepath + # + address String[] linkParts = link.split("nxfile://"); if (linkParts.length != 2) { throw new NexusException("Invalid format for external link " + StringUtils.quote(link)); } String[] parts = linkParts[1].split("#"); if (parts.length != 2) { throw new NexusException("Invalid format for external link " + StringUtils.quote(link)); } Path absExtPath = Paths.get(parts[0]); String address = parts[1]; File f = absExtPath.toFile(); if (!f.exists()) logger.warn("file " + absExtPath + " does not exist at time of adding link"); Path nxsFile = Paths.get(nexusFileUrl); Path nxsParent = nxsFile.getParent(); Path relativize = nxsParent.relativize(absExtPath); String relativeLink = "nxfile://" + relativize + "#" + address; file.linkexternaldataset(name, relativeLink); links.add(new ExternalNXlink(name, relativeLink)); } catch (UnsupportedEncodingException e) { throw new NexusException( "supported encoding in creating string for external linking -- this should never happen"); } } return; } if (nxClassIsAttr) { if (makeData) { NexusGroupData data = tree.getData(); if (data != null && data.getBuffer() != null) { if ("axis".equals(name) || "label".equals(name)) { Integer axisno = getIntfromBuffer(data.getBuffer()); axisno += thisPoint.getScanDimensions().length; file.putattr(name, axisno.toString().getBytes(), NexusFile.NX_CHAR); } else { file.putattr(name, data.getBuffer(), data.type); } } } return; } if (attrOnly) { return; } if (!name.isEmpty() && !nxClass.isEmpty()) { if (!nxClassIsSDS) { if (!(file.groupdir().containsKey(name) && file.groupdir().get(name).equals(nxClass))) { file.makegroup(name, nxClass); } file.opengroup(name, nxClass); } NexusGroupData sds = tree.getData(); if (sds != null) { if (sds.dimensions != null) { for (int i : sds.dimensions) { if (i == 0) throw new NexusException("Data for " + name + " is invalid. SDS Dimension = 0"); } } if (makeData) { int[] dataDimMake = generateDataDim(tree.isPointDependent(), tree.isPointDependent() ? scanDimensions : null, sds.dimensions); if (sds.dimensions != null && sds.dimensions.length > 1) { int[] chunks = Arrays.copyOf(dataDimMake, dataDimMake.length); for (int i = 0; i < chunks.length; i++) { if (chunks[i] == -1) chunks[i] = 1; } if (sds.chunkDimensions != null && sds.chunkDimensions.length <= chunks.length) { int lendiff = chunks.length - sds.chunkDimensions.length; for (int i = 0; i < sds.chunkDimensions.length; i++) { chunks[i + lendiff] = dataDimMake[i + lendiff] == -1 ? sds.chunkDimensions[i] : Math.min(sds.chunkDimensions[i], chunks[i + lendiff]); } } int compression = sds.compressionType != null ? sds.compressionType : NexusFile.NX_COMP_LZW_LVL1; file.compmakedata(name, sds.type, dataDimMake.length, dataDimMake, compression, chunks); } else { file.makedata(name, sds.type, dataDimMake.length, dataDimMake); } file.opendata(name); if (!tree.isPointDependent()) { int[] dataDim = generateDataDim(false, null, sds.dimensions); int[] dataStartPos = generateDataStartPos(null, sds.dimensions); file.putslab(sds.getBuffer(), dataStartPos, dataDim); } if (links != null && sds.isDetectorEntryData) { links.add(new SelfCreatingLink(file.getdataID())); } dataOpen = true; attrBelowThisOnly = true; } else { int[] dataDim = generateDataDim(false, dataDimPrefix, sds.dimensions); int[] dataStartPos = generateDataStartPos(dataStartPosPrefix, sds.dimensions); // Open data array. file.opendata(name); file.putslab(sds.getBuffer(), dataStartPos, dataDim); dataOpen = true; // Close data - do not add children as attributes added for first point only loopNodes = false; } } } else { logger.warn("Name or class is empty:"); } try { if (loopNodes) { for (INexusTree branch : tree) { writeHere(file, branch, makeData, attrBelowThisOnly, links); } } } finally { if (dataOpen) { file.closedata(); } if (!name.isEmpty() && !nxClass.isEmpty() && !nxClassIsSDS) { file.closegroup(); } } }
From source file:gda.device.scannable.MonoScannable.java
@Override public void configure() { theMotor = (ScannableMotor) Finder.getInstance().find(motorName); if (this.inputNames.length == 1 && this.inputNames[0].equals("value")) { this.inputNames = new String[] { getName() }; }// ww w .ja v a2 s. co m try { motorUnit = QuantityFactory.createUnitFromString(this.motorUnitString); if (initialUserUnits == null) { userUnits = motorUnit; } else { userUnits = QuantityFactory.createUnitFromString(initialUserUnits); } acceptableUnits = (Unit[]) ArrayUtils.add(acceptableUnits, NonSIext.mDEG_ANGLE); acceptableUnits = (Unit[]) ArrayUtils.add(acceptableUnits, NonSIext.DEG_ANGLE); acceptableUnits = (Unit[]) ArrayUtils.add(acceptableUnits, NonSI.ANGSTROM); acceptableUnits = (Unit[]) ArrayUtils.add(acceptableUnits, SI.NANO(SI.METER)); acceptableUnits = (Unit[]) ArrayUtils.add(acceptableUnits, NonSI.ELECTRON_VOLT); acceptableUnits = (Unit[]) ArrayUtils.add(acceptableUnits, SI.KILO(NonSI.ELECTRON_VOLT)); this.configured = true; } catch (Exception e) { // do not throw an error as this would stop ObjectFactory from // completing its initialisation logger.error( "Exception during configure of " + getName() + " (motor=" + StringUtils.quote(motorName) + ")", e); } }
From source file:gda.spring.propertyeditors.RealVectorPropertyEditor.java
@Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasText(text)) { try {// w w w . ja va 2 s . c om // remove spaces text = text.replace(" ", ""); // remove leading/trailing braces text = text.replace("{", "").replace("}", ""); String[] valueStrings = text.split(","); double[] values = new double[valueStrings.length]; for (int j = 0; j < valueStrings.length; j++) { values[j] = Double.valueOf(valueStrings[j]); } RealVector vector = MatrixUtils.createRealVector(values); setValue(vector); } catch (Throwable e) { throw new IllegalArgumentException( "Could not convert " + StringUtils.quote(text) + " to a RealVector", e); } } else { setValue(null); } }
From source file:org.springframework.cloud.stream.app.yahoo.quotes.source.YahooQuotesClientImpl.java
private String wouldbeSimplerWithLambdas(List<String> symbols) { for (int i = 0; i < symbols.size(); i++) { if (!symbols.get(i).startsWith("'") && !symbols.get(i).startsWith("\\")) symbols.set(i, StringUtils.quote(symbols.get(i))); }/*ww w.j a v a 2s .co m*/ return StringUtils.collectionToCommaDelimitedString(symbols); }
From source file:org.springmodules.cache.provider.tangosol.CoherenceFacadeTests.java
public void testOnGetFromCache() { setUpCache();/*from ww w . j ava 2 s. c o m*/ cache.put(ENTRY_KEY, ENTRY_VALUE); CoherenceCachingModel model = defaultCachingModel(); assertEquals("Value stored under key " + StringUtils.quote(ENTRY_KEY), ENTRY_VALUE, facade.onGetFromCache(ENTRY_KEY, model)); tearDownCache(); }
From source file:org.springmodules.cache.provider.tangosol.CoherenceFacadeTests.java
private void assertValueIsInCache() { assertEquals("Value stored under key " + StringUtils.quote(ENTRY_KEY), ENTRY_VALUE, cache.get(ENTRY_KEY)); }
From source file:org.springmodules.cache.provider.tangosol.CoherenceFacadeTests.java
private void assertValueIsNotInCache() { assertNull("There should not be any value stored under the key " + StringUtils.quote(ENTRY_KEY), cache.get(ENTRY_KEY)); }
From source file:org.springmodules.cache.provider.tangosol.CoherenceFacadeTests.java
private void setUpCache() { cache = TangosolUtils.getNamedCache(CACHE_NAME); assertTrue("Cache " + StringUtils.quote(CACHE_NAME) + " should be empty", cache.isEmpty()); }