List of usage examples for java.util Properties stringPropertyNames
public Set<String> stringPropertyNames()
From source file:org.codehaus.mojo.license.DefaultThirdPartyTool.java
protected void handleStuff(Properties customMappings, SortedMap<String, MavenProject> artifactCache) { // Store any custom mappings that are not used by this project List<String> unusedDependencies = new ArrayList<String>(); // If the custom mapping file contains GAV entries with type+classifier, remove type+classifier // A simple GAV is enough to figure out appropriate licensing Map<String, String> migrateKeys = migrateCustomMappingKeys(customMappings.stringPropertyNames()); for (String id : migrateKeys.keySet()) { String migratedId = migrateKeys.get(id); MavenProject project = artifactCache.get(migratedId); if (project == null) { // Now we are sure this is an unused dependency // Add this GAV as one that we don't care about for this project unusedDependencies.add(id);//from w ww.ja v a 2 s . co m } else { if (!id.equals(migratedId)) { // migrates id to migratedId getLogger().info("Migrates [" + id + "] to [" + migratedId + "] in the custom mapping file."); Object value = customMappings.get(id); customMappings.remove(id); customMappings.put(migratedId, value); } } } if (!unusedDependencies.isEmpty()) { // there are some unused dependencies in the custom mappings file, remove them for (String id : unusedDependencies) { getLogger().debug("dependency [" + id + "] does not exist in this project"); // Remove it from the custom mappings file since we don't care about it for this project customMappings.remove(id); } } }
From source file:org.apache.zeppelin.interpreter.Interpreter.java
/** * Replace markers #{contextFieldName} by values from {@link InterpreterContext} fields * with same name and marker #{user}. If value == null then replace by empty string. *//*w ww .j av a2 s.c o m*/ private void replaceContextParameters(Properties properties) { InterpreterContext interpreterContext = InterpreterContext.get(); if (interpreterContext != null) { String markerTemplate = "#\\{%s\\}"; List<String> skipFields = Arrays.asList("paragraphTitle", "paragraphId", "paragraphText"); List typesToProcess = Arrays.asList(String.class, Double.class, Float.class, Short.class, Byte.class, Character.class, Boolean.class, Integer.class, Long.class); for (String key : properties.stringPropertyNames()) { String p = properties.getProperty(key); if (StringUtils.isNotEmpty(p)) { for (Field field : InterpreterContext.class.getDeclaredFields()) { Class clazz = field.getType(); if (!skipFields.contains(field.getName()) && (typesToProcess.contains(clazz) || clazz.isPrimitive())) { Object value = null; try { value = FieldUtils.readField(field, interpreterContext, true); } catch (Exception e) { logger.error("Cannot read value of field {0}", field.getName()); } p = p.replaceAll(String.format(markerTemplate, field.getName()), value != null ? value.toString() : StringUtils.EMPTY); } } p = p.replaceAll(String.format(markerTemplate, "user"), StringUtils.defaultString(userName, StringUtils.EMPTY)); properties.setProperty(key, p); } } } }
From source file:org.apache.slider.common.tools.SliderUtils.java
public static String propertiesToString(Properties props) { TreeSet<String> keys = new TreeSet<String>(props.stringPropertyNames()); StringBuilder builder = new StringBuilder(); for (String key : keys) { builder.append(key).append("=").append(props.getProperty(key)).append("\n"); }//from www . j av a 2 s.co m return builder.toString(); }
From source file:com.erudika.scoold.utils.LanguageUtils.java
private Map<String, String> readLanguageFromFile(String langCode) { if (langCode != null) { Properties lang = new Properties(); String file = "lang_" + langCode.toLowerCase() + ".properties"; InputStream ins = null;//from w ww. jav a2s. co m try { ins = LanguageUtils.class.getClassLoader().getResourceAsStream(file); if (ins != null) { lang.load(ins); if (!lang.isEmpty()) { int progress = 0; Map<String, String> langmap = new TreeMap<String, String>(); for (String propKey : lang.stringPropertyNames()) { String propVal = lang.getProperty(propKey); if (!langCode.equalsIgnoreCase(getDefaultLanguageCode())) { String defaultVal = getDefaultLanguage().get(propKey); if (!StringUtils.isBlank(propVal) && !StringUtils.equalsIgnoreCase(propVal, defaultVal)) { progress++; } } langmap.put(propKey, propVal); } if (langCode.equalsIgnoreCase(getDefaultLanguageCode())) { progress = langmap.size(); // 100% } if (progress > 0) { updateTranslationProgressMap(langCode, progress); } return langmap; } } } catch (Exception e) { logger.info("Could not read language file " + file + ": ", e); } finally { try { if (ins != null) { ins.close(); } } catch (IOException ex) { logger.error(null, ex); } } } return null; }
From source file:adalid.util.meta.sql.MetaPlatformSql.java
/** * Adds .string, .class, .instance, .programmer and .wrapper properties to the velocity context * *//* w w w .ja v a 2 s . c om*/ @SuppressWarnings("unchecked") // unchecked cast private void putProperties(VelocityContext context, File propertiesFile) { String hint = HINT + "check property \"{0}\" at file \"{1}\""; String pattern1 = "failed to load {2}" + hint; String pattern2 = "failed to initialise {2}" + hint; String pattern3 = "{2} does not implement {3}" + hint; String pattern4 = "{2} is not a valid wrapper for {3}" + hint; String string1; String string2; String message; String argument; Object object2; Class<?> clazz1; Class<?> clazz2; Class<? extends Wrapper> wrapperClass; Class<? extends Wrappable> wrappableClass; Class<?> parameterType; String velocityKey; Properties properties = PropertiesHandler.loadProperties(propertiesFile); Set<String> stringPropertyNames = properties.stringPropertyNames(); for (String name : stringPropertyNames) { checkPropertyName(name, propertiesFile); if (StringUtils.endsWithIgnoreCase(name, DOT_STRING)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_STRING); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, string2); } else if (StringUtils.endsWithIgnoreCase(name, DOT_CLASS)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_CLASS); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); message = MessageFormat.format(pattern1, name, propertiesFile, string2); object2 = getClassForName(string2, message); if (object2 != null) { velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, object2); continue; } throw new RuntimeException(message, new IllegalArgumentException(string2)); } } }
From source file:org.jflicks.tv.programdata.sd.SchedulesDirect.java
private String[] getStationsByLineupName(String name) { String[] result = null;/*w ww . j ava 2 s . c o m*/ if (name != null) { name = name + ".properties"; LogUtil.log(LogUtil.DEBUG, "looking to conf file <" + name + ">"); File conf = new File("conf"); File pfile = new File(conf, name); Properties p = Util.findProperties(pfile); if (p != null) { Set<String> set = p.stringPropertyNames(); if (set != null) { result = set.toArray(new String[set.size()]); } } } return (result); }
From source file:com.dilmus.dilshad.scabi.core.async.DComputeAsync.java
public DComputeAsync input(Properties propertyInput) { Dson dson = new Dson(); Set<String> st = propertyInput.stringPropertyNames(); for (String s : st) { dson = dson.add(s, propertyInput.getProperty(s)); }//from w w w .j a va 2 s . c o m m_jsonStrInput = dson.toString(); return this; }
From source file:org.jflicks.tv.programdata.sd.SchedulesDirect.java
private StationID[] getStationIDsByLineupName(String name) { StationID[] result = null;/* w w w . ja v a 2 s.c o m*/ if (name != null) { name = name + ".properties"; LogUtil.log(LogUtil.DEBUG, "looking to conf file <" + name + ">"); File conf = new File("conf"); File pfile = new File(conf, name); Properties p = Util.findProperties(pfile); if (p != null) { Set<String> set = p.stringPropertyNames(); if (set != null) { String[] tags = set.toArray(new String[set.size()]); if ((tags != null) && (tags.length > 0)) { result = new StationID[tags.length]; for (int i = 0; i < result.length; i++) { String val = p.getProperty(tags[i]); if (val != null) { int index = val.indexOf("|"); if (index >= 0) { StationID tmp = new StationID(); tmp.setStationID(tags[i]); tmp.setChannel(val.substring(0, index)); result[i] = tmp; } } } } } } } return (result); }
From source file:org.voltdb.utils.CatalogUtil.java
/** * Set deployment time settings for export * @param catalog The catalog to be updated. * @param exportsType A reference to the <exports> element of the deployment.xml file. *//*from w w w . ja v a 2 s. c o m*/ private static void setExportInfo(Catalog catalog, ExportType exportType) { if (exportType == null) { return; } List<String> streamList = new ArrayList<String>(); boolean noEmptyTarget = (exportType.getConfiguration().size() != 1); for (ExportConfigurationType exportConfiguration : exportType.getConfiguration()) { boolean connectorEnabled = exportConfiguration.isEnabled(); // Get the stream name from the xml attribute "stream" // Should default to Constants.DEFAULT_EXPORT_CONNECTOR_NAME if not specified String streamName = exportConfiguration.getStream(); if (streamName == null || streamName.trim().isEmpty()) { throw new RuntimeException("stream must be specified along with type in export configuration."); } if (connectorEnabled) { if (streamList.contains(streamName)) { throw new RuntimeException( "Multiple connectors can not be assigned to single export stream: " + streamName + "."); } else { streamList.add(streamName); } } boolean defaultConnector = streamName.equals(Constants.DEFAULT_EXPORT_CONNECTOR_NAME); Database db = catalog.getClusters().get("cluster").getDatabases().get("database"); org.voltdb.catalog.Connector catconn = db.getConnectors().get(streamName); if (catconn == null) { if (connectorEnabled) { if (defaultConnector) { hostLog.info("Export configuration enabled and provided for the default export " + "stream in deployment file, however, no export " + "tables are assigned to the default stream. " + "Export stream will be disabled."); } else { hostLog.info("Export configuration enabled and provided for export stream " + streamName + " in deployment file however no export " + "tables are assigned to the this stream. " + "Export stream " + streamName + " will be disabled."); } } continue; } Properties processorProperties = checkExportProcessorConfiguration(exportConfiguration); for (String name : processorProperties.stringPropertyNames()) { ConnectorProperty prop = catconn.getConfig().add(name); prop.setName(name); prop.setValue(processorProperties.getProperty(name)); } // on-server export always uses the guest processor catconn.setLoaderclass(ExportManager.PROCESSOR_CLASS); catconn.setEnabled(connectorEnabled); if (!connectorEnabled) { if (defaultConnector) { hostLog.info("Export configuration for the default export stream is present and is " + "configured to be disabled. The default export stream will be disabled."); } else { hostLog.info("Export configuration for export stream " + streamName + " is present and is " + "configured to be disabled. Export stream " + streamName + " will be disabled."); } } else { if (defaultConnector) { hostLog.info("Default export stream is configured and enabled with type=" + exportConfiguration.getType()); } else { hostLog.info("Export stream " + streamName + " is configured and enabled with type=" + exportConfiguration.getType()); } if (exportConfiguration.getProperty() != null) { if (defaultConnector) { hostLog.info("Default export stream configuration properties are: "); } else { hostLog.info("Export stream " + streamName + " configuration properties are: "); } for (PropertyType configProp : exportConfiguration.getProperty()) { if (!configProp.getName().toLowerCase().contains("password")) { hostLog.info("Export Configuration Property NAME=" + configProp.getName() + " VALUE=" + configProp.getValue()); } } } } } }
From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileUtils.java
private static void setLocalePropertiesMap(final Session session, final PentahoJcrConstants pentahoJcrConstants, final Node localeRootNode, final Map<String, Properties> localePropertiesMap) throws RepositoryException { String prefix = session.getNamespacePrefix(PentahoJcrConstants.PHO_NS); Assert.hasText(prefix);// w ww . j av a2 s.com if (localePropertiesMap != null && !localePropertiesMap.isEmpty()) { for (String locale : localePropertiesMap.keySet()) { Properties properties = localePropertiesMap.get(locale); if (properties != null) { // create node and set properties for each locale Node localeNode; if (!NodeHelper.checkHasNode(localeRootNode, locale)) { localeNode = localeRootNode.addNode(locale, pentahoJcrConstants.getNT_UNSTRUCTURED()); } else { localeNode = NodeHelper.checkGetNode(localeRootNode, locale); } for (String propertyName : properties.stringPropertyNames()) { try { localeNode.setProperty(propertyName, properties.getProperty(propertyName)); } catch (Throwable th) { // Continue setting other properties continue; } } } } } }