java.util.Properties#get ( )源码实例Demo

下面列出了java.util.Properties#get ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: archiva   文件: ArchivaRuntimeInfo.java
@Inject
public ArchivaRuntimeInfo( @Named( value = "archivaRuntimeProperties" ) Properties archivaRuntimeProperties )
{
    this.version = (String) archivaRuntimeProperties.get( "archiva.version" );
    this.buildNumber = (String) archivaRuntimeProperties.get( "archiva.buildNumber" );
    String archivaTimeStamp = (String) archivaRuntimeProperties.get( "archiva.timestamp" );
    if ( NumberUtils.isNumber( archivaTimeStamp ) )
    {
        this.timestamp = NumberUtils.createLong( archivaTimeStamp );
    }
    else
    {
        this.timestamp = new Date().getTime();
    }
    this.devMode = Boolean.getBoolean( "archiva.devMode" );
}
 
源代码2 项目: p4ic4idea   文件: RpcPropertyDefs.java
/**
 * Convenience method to first try to get the short form from the passed-in
 * properties, then try for the long form. Returns defaultValue if it can't
 * find a definition associated with either short or long form keys.<p>
 * 
 * Note: this method is null safe, i.e. if either or both props or nick is null,
 * it simply returns null.
 */

public static String getProperty(Properties props, String nick, String defaultValue) {
	
	if ((props != null) && (nick != null)) {
		String propStr = null;
		if (props.get(nick) != null) {
			propStr = String.valueOf(props.get(nick));
		}
		
		if (propStr == null) {
			if (props.get(RPC_PROPERTY_PREFIX + nick) != null) {
				propStr = String.valueOf(props.get(RPC_PROPERTY_PREFIX + nick));
			}
		}
		
		if (propStr != null) {
			return propStr;
		}
	}
	
	return defaultValue;
}
 
源代码3 项目: openjdk-jdk8u   文件: Agent.java
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
 
源代码4 项目: howsun-javaee-framework   文件: Collections.java
/**
 * Merge the given Properties instance into the given Map,
 * copying all properties (key-value pairs) over.
 * <p>Uses <code>Properties.propertyNames()</code> to even catch
 * default properties linked into the original Properties instance.
 * @param props the Properties instance to merge (may be <code>null</code>)
 * @param map the target Map to merge the properties into
 */
@SuppressWarnings("unchecked")
public static void mergePropertiesIntoMap(Properties props, Map map) {
	if (map == null) {
		throw new IllegalArgumentException("Map must not be null");
	}
	if (props != null) {
		for (Enumeration en = props.propertyNames(); en.hasMoreElements();) {
			String key = (String) en.nextElement();
			Object value = props.getProperty(key);
			if (value == null) {
				// Potentially a non-String value...
				value = props.get(key);
			}
			map.put(key, value);
		}
	}
}
 
源代码5 项目: dragonwell8_jdk   文件: GenerateCurrencyData.java
private static void readInput() throws IOException {
    currencyData = new Properties();
    currencyData.load(System.in);

    // initialize other lookup strings
    formatVersion = (String) currencyData.get("formatVersion");
    dataVersion = (String) currencyData.get("dataVersion");
    validCurrencyCodes = (String) currencyData.get("all");
    for (int i = 0; i <= SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS; i++) {
        currenciesWithDefinedMinorUnitDecimals[i]
            = (String) currencyData.get("minor"+i);
    }
    currenciesWithMinorUnitsUndefined  = (String) currencyData.get("minorUndefined");
    if (formatVersion == null ||
            dataVersion == null ||
            validCurrencyCodes == null ||
            currenciesWithMinorUnitsUndefined == null) {
        throw new NullPointerException("not all required data is defined in input");
    }
}
 
源代码6 项目: dr-elephant   文件: AnalyticJobTest.java
private void setCounterData(MapReduceCounterData counter, String filePath)
    throws IOException {
  Properties counterData = TestUtil.loadProperties(filePath);

  for (Object groupName : counterData.keySet()) {
    String counterValueString = (String) counterData.get(groupName);
    counterValueString = counterValueString.replaceAll("\\{|\\}", "");

    StringBuilder stringBuilder = new StringBuilder();

    for (String counterKeyValue : counterValueString.split(",")) {
      stringBuilder.append(counterKeyValue.trim()).append('\n');
    }
    ByteArrayInputStream inputStream = new ByteArrayInputStream(stringBuilder.toString().getBytes(DEFAULT_ENCODING));
    Properties counterProperties = new Properties();
    counterProperties.load(inputStream);

    for (Object counterKey : counterProperties.keySet()) {
      long counterValue = Long.parseLong(counterProperties.get(counterKey).toString());
      counter.set(groupName.toString(), counterKey.toString(), counterValue);
    }
  }
}
 
源代码7 项目: hottub   文件: MimeTable.java
void parse(Properties entries) {
    // first, strip out the platform-specific temp file template
    String tempFileTemplate = (String)entries.get("temp.file.template");
    if (tempFileTemplate != null) {
        entries.remove("temp.file.template");
        MimeTable.tempFileTemplate = tempFileTemplate;
    }

    // now, parse the mime-type spec's
    Enumeration<?> types = entries.propertyNames();
    while (types.hasMoreElements()) {
        String type = (String)types.nextElement();
        String attrs = entries.getProperty(type);
        parse(type, attrs);
    }
}
 
源代码8 项目: openjdk-8   文件: GenerateCurrencyData.java
private static void readInput() throws IOException {
    currencyData = new Properties();
    currencyData.load(System.in);

    // initialize other lookup strings
    formatVersion = (String) currencyData.get("formatVersion");
    dataVersion = (String) currencyData.get("dataVersion");
    validCurrencyCodes = (String) currencyData.get("all");
    currenciesWith0MinorUnitDecimals  = (String) currencyData.get("minor0");
    currenciesWith1MinorUnitDecimal  = (String) currencyData.get("minor1");
    currenciesWith3MinorUnitDecimal  = (String) currencyData.get("minor3");
    currenciesWithMinorUnitsUndefined  = (String) currencyData.get("minorUndefined");
    if (formatVersion == null ||
            dataVersion == null ||
            validCurrencyCodes == null ||
            currenciesWith0MinorUnitDecimals == null ||
            currenciesWith1MinorUnitDecimal == null ||
            currenciesWith3MinorUnitDecimal == null ||
            currenciesWithMinorUnitsUndefined == null) {
        throw new NullPointerException("not all required data is defined in input");
    }
}
 
源代码9 项目: letv   文件: AppUpgradeConstants.java
public static String[] getChannelInfo(Context context) {
    String[] channelInfo = new String[2];
    try {
        String pchannel = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData.getString("UMENG_CHANNEL");
        InputStream in = context.getAssets().open("channel-maps.properties");
        if (pchannel == null || in == null) {
            return channelInfo;
        }
        Properties p = new Properties();
        p.load(in);
        String value = (String) p.get(pchannel);
        if (pchannel.contains(" ")) {
            value = (String) p.get(pchannel.split(" ")[0]);
            if (!TextUtils.isEmpty(value) && value.contains(NetworkUtils.DELIMITER_COLON)) {
                value = value.substring(value.indexOf(58) + 1);
            }
        }
        if (TextUtils.isEmpty(value) || !value.contains("#")) {
            return channelInfo;
        }
        String[] data = value.split("#");
        if (data == null || data.length != 2) {
            return channelInfo;
        }
        String appeky = data[1];
        channelInfo[0] = data[0];
        channelInfo[1] = appeky;
        return channelInfo;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
/**
 * GET http://localhost:8080/<portal>/api/rs/en/ideaInstances?id=1
 *
 * @param properties
 * @return
 * @throws Throwable
 */
public JAXBIdeaInstance getIdeaInstanceForApi(Properties properties) throws Throwable {
    JAXBIdeaInstance jaxbIdeaInstance = null;
    try {
        String codeParam = properties.getProperty("code");
        if (StringUtils.isNotBlank(codeParam)) {
            codeParam = URLDecoder.decode(codeParam, "UTF-8");
        }

        UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
        //TODO CREATE ROLE
        List<Integer> ideaStateFilter = new ArrayList<Integer>();
        ideaStateFilter.add(IIdea.STATUS_APPROVED);

        if (null != user && !this.getAuthorizationManager().isAuthOnPermission(user, Permission.SUPERUSER)) {
            ideaStateFilter.clear();
        }
        IdeaInstance ideaInstance = this.getIdeaInstanceManager().getIdeaInstance(codeParam, ideaStateFilter);
        if (null == ideaInstance) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "IdeaInstance with code '" + codeParam + "' does not exist", Response.Status.CONFLICT);
        }
        if (!isAuthOnInstance(user, ideaInstance)) {
            _logger.warn("the current user is not granted to any group required by instance {}", codeParam);
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "IdeaInstance with code '" + codeParam + "' does not exist", Response.Status.CONFLICT);
        }
        jaxbIdeaInstance = new JAXBIdeaInstance(ideaInstance);
    } catch (ApiException ae) {
        throw ae;
    } catch (Throwable t) {
        _logger.error("Error extracting ideaInstance", t);
        throw new ApsSystemException("Error extracting idea instance", t);
    }
    return jaxbIdeaInstance;
}
 
/**
 * Gets whether socket keepAlive is enabled, by consulting the
 * PerformanceTuningSettings.  (If no setting specified, defaults
 * to true.)
 * @return if socketKeepAlive is enabled
 */
protected boolean isSocketKeepAliveEnabled() {
  if (mOwner instanceof AnalysisEngine) {
    Properties settings = ((AnalysisEngine)mOwner).getPerformanceTuningSettings();
    if (settings != null) {
      String enabledStr = (String)settings.get(UIMAFramework.SOCKET_KEEPALIVE_ENABLED);
      return !"false".equalsIgnoreCase(enabledStr);
    }
  }
  return true;
}
 
源代码12 项目: marauroa   文件: AbstractDatabaseAdapter.java
/**
 * creates a new AbstractDatabaseAdapter
 *
 * @param connInfo parameters specifying the
 * @throws DatabaseConnectionException if the connection cannot be established.
 */
public AbstractDatabaseAdapter(Properties connInfo) throws DatabaseConnectionException {
	try {
		this.connection = createConnection(connInfo);
	} catch (SQLException e) {
		throw new DatabaseConnectionException("Unable to create a connection to: "
				+ connInfo.get("jdbc_url"), e);
	}

	this.statements = new LinkedList<Statement>();
	this.resultSets = new LinkedList<ResultSet>();
}
 
源代码13 项目: das   文件: DasClientVersion.java
private static String initVersion() {
    String path = "/version.prop";
    InputStream stream = DasClientVersion.class.getResourceAsStream(path);
    if (stream == null) {
        return "UNKNOWN";
    }
    Properties props = new Properties();
    try {
        props.load(stream);
        stream.close();
        return (String) props.get("version");
    } catch (IOException e) {
        return "UNKNOWN";
    }
}
 
源代码14 项目: datafu   文件: ContextualEvalFunc.java
/**
 * Helper method to return the context properties for this instance of this class
 * 
 * @return instances properties
 */
protected Properties getInstanceProperties() {
  Properties contextProperties = getContextProperties();
  if (!contextProperties.containsKey(getInstanceName())) {
    contextProperties.put(getInstanceName(), new Properties());
  }
  return (Properties)contextProperties.get(getInstanceName());
}
 
源代码15 项目: hibernate-types   文件: JsonTypeDescriptor.java
@Override
public void setParameterValues(Properties parameters) {
    final XProperty xProperty = (XProperty) parameters.get(DynamicParameterizedType.XPROPERTY);
    if (xProperty instanceof JavaXMember) {
        type = ReflectionUtils.invokeGetter(xProperty, "javaType");
    } else {
        type = ((ParameterType) parameters.get(PARAMETER_TYPE)).getReturnedClass();
    }
}
 
源代码16 项目: fabric-sdk-java   文件: Orderer.java
String getEndpoint() {
    if (null == endPoint) {
        Properties properties = parseGrpcUrl(url);
        endPoint = properties.get("host") + ":" + properties.getProperty("port").toLowerCase().trim();
    }
    return endPoint;
}
 
源代码17 项目: deltaspike   文件: DefaultCipherService.java
protected String getMasterKey(String masterSalt)
{
    File masterFile = getMasterFile();
    if (!masterFile.exists())
    {
        throw new IllegalStateException("Could not find master.hash file. Create a master password first!");
    }

    try
    {
        String saltHash = byteToHex(secureHash(masterSalt));
        String saltKey = byteToHex(secureHash(saltHash));

        Properties keys = loadProperties(masterFile.toURI().toURL());

        String encryptedMasterKey = (String) keys.get(saltKey);
        if (encryptedMasterKey == null)
        {
            throw new IllegalStateException("Could not find master key for hash " + saltKey +
                ". Create a master password first!");
        }

        return aesDecrypt(hexToByte(encryptedMasterKey), saltHash);
    }
    catch (MalformedURLException e)
    {
        throw new RuntimeException(e);
    }
}
 
源代码18 项目: singleton   文件: OrderedPropertiesUtils.java
public static Object getPropertyValue(Properties p, String key) {
    return p.get(key);
}
 
源代码19 项目: XBatis-Code-Generator   文件: Settings.java
/**
 * 初始化系统参数
 *
 * @return
 */
public boolean initSystemParam() {
	boolean blnRet = true;
	
	String daopath = "dao/";
	String path = ClassLoader.getSystemResource(daopath).getPath();
	logger.info("开始初始化数据库环境,路径为【" + path + "】");
	//加载DB属性文件
	List<String> files = FileUtil.getFileListWithExt(path, ".properties");
	String propertiesFilename = null;
	if(files!=null&&files.size()==1){
		propertiesFilename = files.get(0);
		logger.info("找到DB属性配置文件,文件名为【" + path + propertiesFilename + "】");
	}
	if(propertiesFilename==null){
		logger.error("OUT---[false]DB属性配置文件在["+path+"]找不到!");
		return false;
	}
	//解析属性文件
	Properties prop = PropertiesUtil.getPropertiesByResourceBundle(daopath + FileUtil.getFilenameWithoutExt(propertiesFilename));
	if (prop == null) {
		logger.error("OUT---[false]属性配置文件内容解析为空!");
		return false;
	}
	
	//设置DB类型及数据库连接信息
	String type = (String) prop.get("DB_TYPE");
	if("Mysql".equals(type)){
		dbType = Settings.DB_TYPE_MYSQL;
	}else{
		logger.error("OUT---[false]属性配置文件指定的DB_TYPE不存在!type:" + type);
		blnRet = false;
	}
	url = (String) prop.get("DB_SERVER");
	port = (String) prop.get("DB_PORT");
	dbName = (String) prop.get("DB_NAME");
	dbUser = (String) prop.get("DB_USER");
	dbPwd = (String) prop.get("DB_PWD");
	//设置生成指定表、使用模版、Java包路径、代码输出路径
	String tablestr = (String) prop.get("DB_TABLES");
	if(tablestr!=null){
		String[] ts = tablestr.split(",");
		for(int i=0;i<ts.length;i++){
			tables.add(ts[i]);
		}
		logger.info("指定生成表:" + tables.toString());
	}
	javaPackage = (String) prop.get("JAVA_PACKAGE");
	String tmpl = (String) prop.get("USE_TMPL");
	if(StringUtils.isBlank(tmpl)){
		tmplPath = daopath + "ibatisdao";
		logger.warn("DAO模版未指定,使用默认模版:" + tmplPath);
	}else{
		tmplPath = daopath + tmpl;
		logger.info("使用模版:" + tmplPath);
	}
	String gendir = (String) prop.get("GEN_PATH");
	if(StringUtils.isBlank(gendir)){
		genPath = System.getProperty("user.dir") + "/gendir/";
		logger.warn("代码生成输出路径未指定,使用默认路径:" + genPath);
	}else{
		File f = new File(gendir);
		if(!f.exists()||!f.isDirectory()){
			genPath = System.getProperty("user.dir") + "/gendir/";
			logger.warn("指定的代码生成输出路径不存在,使用默认路径:" + genPath);
		}else{
			genPath = gendir;
			logger.info("使用指定的代码生成输出路径:" + genPath);
		}
	}
	
	//打印数据库DAO代码生成环境配置信息
	Iterator<Entry<Object,Object>> it = prop.entrySet().iterator();
	logger.info("数据库DAO代码生成环境配置信息如下:");
	while (it.hasNext()) {
		Entry<Object, Object> en = it.next();
		logger.info(en.getKey() + "=" + en.getValue());
	}
	logger.info("结束初始化数据库DAO代码生成环境【" + path + propertiesFilename + "】!");
	return blnRet;
}
 
源代码20 项目: TorrentEngine   文件: ClientIDPlugin.java
protected static void
doHTTPProperties(
	Properties			properties )
{
	Boolean	raw = (Boolean)properties.get( ClientIDGenerator.PR_RAW_REQUEST );
	
	if ( raw != null && raw ){
		
		return;
	}
	
	String	version = Constants.AZUREUS_VERSION;
	
		// trim of any _Bnn or _CVS suffix as unfortunately some trackers can't cope with this
		// (well, apparently can't cope with B10)
		// its not a big deal anyway
	
	int	pos = version.indexOf('_');
	
	if ( pos != -1 ){
		
		version = version.substring(0,pos);
	}
	
	String	agent = Constants.AZUREUS_NAME + " " + version;
			
	if ( send_os ){
						
		agent += ";" + Constants.OSName;
	
		agent += ";Java " + Constants.JAVA_VERSION;
	}
	
	properties.put( ClientIDGenerator.PR_USER_AGENT, agent );
}