本文整理汇总了Java中java.util.Properties.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Properties.getProperty方法的具体用法?Java Properties.getProperty怎么用?Java Properties.getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Properties
的用法示例。
在下文中一共展示了Properties.getProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseConnectionFactory
import java.util.Properties; //导入方法依赖的package包/类
protected void parseConnectionFactory(Context context, Node node) {
ConnectionFactoryConfiguration connectionFactoryConfiguration = new ConnectionFactoryConfiguration();
context.setConnectionFactoryConfiguration(connectionFactoryConfiguration);
Properties attributes = parseAttributes(node);
String type = attributes.getProperty("type"); //$NON-NLS-1$
if (stringHasValue(type)) {
connectionFactoryConfiguration.setConfigurationType(type);
}
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperty(connectionFactoryConfiguration, childNode);
}
}
}
示例2: setup
import java.util.Properties; //导入方法依赖的package包/类
@Before
public void setup() throws IOException {
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream("test_credentials.properties");
// Load properties
Properties properties = new Properties();
properties.load(inputStream);
inputStream.close();
// Load in config
testConfig = new Configuration(
properties.getProperty("username"),
properties.getProperty("password"),
properties.getProperty("user_key")
);
logger.info("Config: {}", testConfig);
// Create and init rest client
restClient = new HttpClientRestClient();
restClient.init(testConfig);
}
示例3: main
import java.util.Properties; //导入方法依赖的package包/类
public static void main(String[] args) {
String port = null;
try {
InputStream in = AppMain.class.getResourceAsStream("/application.properties");
Properties p = new Properties();
p.load(in);
port = p.getProperty("server.port");
} catch (Exception e) {
logger.error("error read port", e);
}
if (port != null) {
new SocketServer(Integer.parseInt(port));
logger.info("server start, port is " + port);
} else {
logger.error("error read port, port is null");
System.exit(0);
}
}
示例4: testCreatePlatforms
import java.util.Properties; //导入方法依赖的package包/类
public void testCreatePlatforms() {
// learn hostname
String hostName = null;
try {
hostName = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException uhe) {
fail("Cannot get hostname: " + uhe.getMessage()); // NOI18N
}
hostName = hostName.replace('-', '_');
// load platforms.properties file
InputStream is = this.getClass().getResourceAsStream("platforms.properties");
Properties props = new Properties();
try {
props.load(is);
} catch (java.io.IOException ioe) {
fail("Cannot load platforms properties: " + ioe.getMessage()); // NOI18N
}
// get folder from prop file
// XXX add correct paths to platform.properties
String folderJDK13Path = props.getProperty(hostName + "_jdk13_folder");
TestProjectUtils.addPlatform(JDK13_NAME, folderJDK13Path);
String folderJDK14Path = props.getProperty(hostName + "_jdk14_folder");
TestProjectUtils.addPlatform(JDK14_NAME, folderJDK14Path);
String folderJDK15Path = props.getProperty(hostName + "_jdk15_folder");
TestProjectUtils.addPlatform(JDK15_NAME, folderJDK15Path);
}
示例5: getTools
import java.util.Properties; //导入方法依赖的package包/类
private String[] getTools(PrintWriter writer, Properties p, String key) {
String value = p.getProperty(key);
if (value == null || value.isEmpty()) {
writer.printf("ERROR: '%s' property is empty%n", key);
return new String[]{};
}
return value.split(" ");
}
示例6: ZookeeperServiceProvider
import java.util.Properties; //导入方法依赖的package包/类
private ZookeeperServiceProvider() {
try {
Properties properties = ConfUtils.appConf;
zkService = new ZkService(properties.getProperty(Constants.ApplicationProp.ZK_SERVERS));
} catch (Exception e) {
throw new InitializationException(e);
}
}
示例7: TestApplication
import java.util.Properties; //导入方法依赖的package包/类
public TestApplication(Stage parent, Properties props) {
initOwner(parent);
MPFUtils.replaceEnviron(props);
String model = props.getProperty(Constants.PROP_PROJECT_LAUNCHER_MODEL);
if (model == null || model.equals("")) {
commandField.setText("Select a launcher and set the parameters required.");
show();
} else {
IRuntimeLauncherModel launcherModel = LauncherModelHelper.getLauncherModel(model);
launchCommand = launcherModel.createLauncher(props);
}
initModality(Modality.APPLICATION_MODAL);
BorderPane content = new BorderPane();
VBox builder = new VBox();
builder.setSpacing(5);
outputArea.setEditable(false);
errorArea.setEditable(false);
VBox.setVgrow(errorArea, Priority.ALWAYS);
builder.getChildren().addAll(new Label("Command"), commandField, new Label("Standard Output & Error"), outputArea,
new Label("Message"), errorArea);
closeButton.setOnAction((event) -> {
if (launchCommand != null) {
launchCommand.destroy();
}
close();
});
content.setCenter(builder);
content.setBottom(new HBox(5, FXUIUtils.createFiller(), closeButton));
setScene(new Scene(content));
}
示例8: test
import java.util.Properties; //导入方法依赖的package包/类
@Test
@Ignore
public void test() throws IOException {
Properties prop = PropertiesUtils.loadProperties("META-INF/generator.properties");
File sourcePath = new File(prop.getProperty(PropertiesUtils.TARGET_FOLDER));
Class<?> clazz = Integer.class;
MongoDBDao mongo = new MongoDBDaoImpl(prop);
PojoCreator creator = new PojoCreatorImpl(prop, mongo);
LOG.info("Creating tests for public methods of " + clazz.getSimpleName());
TypeSpec classTest = creator.getTypeSpec(clazz);
creator.writeJavaFile(sourcePath, clazz, classTest);
}
示例9: getStormUIAddr
import java.util.Properties; //导入方法依赖的package包/类
private static String getStormUIAddr(ZkService zkService,String topologyName){
if(zkService==null){
return null;
}
String stormUIAddr=null;
String zkPath = Constants.TOPOLOGY_ROOT+"/"+topologyName+"/"+Constants.ZkTopoConfForFullPull.COMMON_CONFIG+".properties";
try {
Properties props = zkService.getProperties(zkPath);
stormUIAddr = props.getProperty(DataPullConstants.STORM_UI);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return stormUIAddr;
}
示例10: setUpTest_ImapStorage
import java.util.Properties; //导入方法依赖的package包/类
@BeforeClass
public static void setUpTest_ImapStorage() throws IOException {
Properties imapProps = new Properties();
imapProps.load(Test_ImapStorage.class.getResourceAsStream("imapConfig.txt"));
imapServer = imapProps.getProperty("imapServer");
imapPass = imapProps.getProperty("imapPass");
imapInboxFolder = imapProps.getProperty("imapInboxFolder");
}
示例11: loadDefaultConnectionFile
import java.util.Properties; //导入方法依赖的package包/类
private void loadDefaultConnectionFile() throws IOException {
if (defaultConnectionFile.exists()) {
Properties props = new Properties();
FileReader reader = new FileReader(defaultConnectionFile);
try {
props.load(reader);
} finally {
reader.close();
}
defaultEncryptionManager = props
.getProperty(DATA_ENCRYPTION_MANAGER) == null ? "org.apache.zookeeper.inspector.encryption.BasicDataEncryptionManager"
: props.getProperty(DATA_ENCRYPTION_MANAGER);
defaultTimeout = props.getProperty(SESSION_TIMEOUT) == null ? "5000"
: props.getProperty(SESSION_TIMEOUT);
defaultHosts = props.getProperty(CONNECT_STRING) == null ? "localhost:2181"
: props.getProperty(CONNECT_STRING);
defaultAuthScheme = props.getProperty(AUTH_SCHEME_KEY) == null ? ""
: props.getProperty(AUTH_SCHEME_KEY);
defaultAuthValue = props.getProperty(AUTH_DATA_KEY) == null ? ""
: props.getProperty(AUTH_DATA_KEY);
} else {
defaultEncryptionManager = "org.apache.zookeeper.inspector.encryption.BasicDataEncryptionManager";
defaultTimeout = "5000";
defaultHosts = "localhost:2181";
defaultAuthScheme = "";
defaultAuthValue = "";
}
}
示例12: needBuild
import java.util.Properties; //导入方法依赖的package包/类
/**
* @param policies
* @return
*/
public boolean needBuild(List<BuildPolicy> policies) {
try {
IFile fileCache = getCache();
if (fileCache == null) {
return true;
}
Properties p = ResourceManager.loadIFileAsProperties(fileCache,
getFileCacheName(resource.getProject().getName()));
String svalue = p.getProperty(resource.getName(), null);
if (svalue == null) {
return true;
}
StringTokenizer st = new StringTokenizer(svalue, ":");
long graphfiletime = resource.getLocalTimeStamp();
long lastUpdate = Long.parseLong(st.nextToken());
boolean need = graphfiletime > lastUpdate;
if (need)
return true;
List<BuildPolicy> list = BuildPolicy.deserialize(st.nextToken());
List<BuildPolicy> targetPolicies = new ArrayList<BuildPolicy>(policies);
targetPolicies.removeAll(list);
need = (targetPolicies.size() > 0);
return need;
} catch (Exception e) {
return true;
}
}
示例13: checkVaild
import java.util.Properties; //导入方法依赖的package包/类
private boolean checkVaild(Properties props)
{
String nameserver = props.getProperty(MQConstant.CONFIG_CONSUMER_NAMESERVER);
if (!nameserver.matches("[0-9.:;]+"))
{
return false;
}
String timeout = props.getProperty(MQConstant.CONFIG_CONSUMER_TIMEOUT);
if (!StringUtils.isEmpty(timeout) && !timeout.matches("[0-9]+"))
{
return false;
}
return true;
}
示例14: buildAdESPolicy
import java.util.Properties; //导入方法依赖的package包/类
/** Crea una política AdES a partir de un fichero de propiedades.
* Las propiedades aceptadas son:
* <ul>
* <li><b>policyIdentifier</b>: Identificador de la política de firma (URL u OID
* directo o como URN que identifica unívocamente el fichero de política
* computacionalmente procesable)
* <li><b>policyIdentifierHash</b>: Huella digital de la política de firma en formato
* ASN.1 procesable identificado por <code>policyIdentifier</code>. Puede ser nulo
* <li><b>policyIdentifierHashAlgorithm</b>: Algoritmo de huella digital usado para el
* cálculo del valor indicado en <code>policyIdentifierHashAlgorithm</code>. Es
* obligatorio si el valor indicado en <code>policyIdentifierHashAlgorithm</code> no es nulo
* <li><b>policyQualifier</b>: URL que apunta a una descripción legible de la
* política (normalmente un PDF)
* </ul>
* @param extraParams Propiedades de la política
* @return Configuración de política de firma o {@code null} si no se encontro el
* identificador de la politica en el fichero de propiedades.
* @throws IllegalArgumentException Cuando se indique un identificador de política pero
* el resto de datos sean incongruentes.
*/
public static AdESPolicy buildAdESPolicy(final Properties extraParams) {
if (extraParams == null) {
throw new IllegalArgumentException("Es necesario proporciona las propiedades de la politica"); //$NON-NLS-1$
}
final String policyID = extraParams.getProperty("policyIdentifier"); //$NON-NLS-1$
if (policyID == null) {
return null;
}
return new AdESPolicy(
policyID,
extraParams.getProperty("policyIdentifierHash"), //$NON-NLS-1$
extraParams.getProperty("policyIdentifierHashAlgorithm"), //$NON-NLS-1$
extraParams.getProperty("policyQualifier") //$NON-NLS-1$
);
}
示例15: parseColumnOverride
import java.util.Properties; //导入方法依赖的package包/类
private void parseColumnOverride(TableConfiguration tc, Node node) {
Properties attributes = parseAttributes(node);
String column = attributes.getProperty("column"); //$NON-NLS-1$
String property = attributes.getProperty("property"); //$NON-NLS-1$
String javaType = attributes.getProperty("javaType"); //$NON-NLS-1$
String jdbcType = attributes.getProperty("jdbcType"); //$NON-NLS-1$
String typeHandler = attributes.getProperty("typeHandler"); //$NON-NLS-1$
String delimitedColumnName = attributes
.getProperty("delimitedColumnName"); //$NON-NLS-1$
String isGeneratedAlways = attributes.getProperty("isGeneratedAlways"); //$NON-NLS-1$
ColumnOverride co = new ColumnOverride(column);
if (stringHasValue(property)) {
co.setJavaProperty(property);
}
if (stringHasValue(javaType)) {
co.setJavaType(javaType);
}
if (stringHasValue(jdbcType)) {
co.setJdbcType(jdbcType);
}
if (stringHasValue(typeHandler)) {
co.setTypeHandler(typeHandler);
}
if (stringHasValue(delimitedColumnName)) {
co.setColumnNameDelimited(isTrue(delimitedColumnName));
}
if (stringHasValue(isGeneratedAlways)) {
co.setGeneratedAlways(Boolean.parseBoolean(isGeneratedAlways));
}
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperty(co, childNode);
}
}
tc.addColumnOverride(co);
}