Java Code Examples for java.util.Properties.getProperty()

The following are Jave code examples for showing how to use getProperty() of the java.util.Properties class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: generator_mybatis   File: MyBatisGeneratorConfigurationParser.java   View Source Code Vote up 7 votes
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);
        }
    }
}
 
Example 2
Project: pardot-java-client   File: HttpClientRestClientTest.java   View Source Code Vote up 6 votes
@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);
}
 
Example 3
Project: io-command   File: AppMain.java   View Source Code Vote up 6 votes
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);
	}
	
}
 
Example 4
Project: incubator-netbeans   File: PlatformsTest.java   View Source Code Vote up 5 votes
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);
    
}
 
Example 5
Project: openjdk-jdk10   File: ActionSet.java   View Source Code Vote up 5 votes
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(" ");
}
 
Example 6
Project: DBus   File: ZookeeperServiceProvider.java   View Source Code Vote up 5 votes
private ZookeeperServiceProvider() {
    try {
        Properties properties = ConfUtils.appConf;
        zkService = new ZkService(properties.getProperty(Constants.ApplicationProp.ZK_SERVERS));
    } catch (Exception e) {
        throw new InitializationException(e);
    }
}
 
Example 7
Project: marathonv5   File: TestApplication.java   View Source Code Vote up 5 votes
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));
}
 
Example 8
Project: Jerkoff   File: MainTest.java   View Source Code Vote up 5 votes
@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);
}
 
Example 9
Project: DBus   File: CommandCtrl.java   View Source Code Vote up 5 votes
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;
}
 
Example 10
Project: ats-framework   File: Test_ImapStorage.java   View Source Code Vote up 5 votes
@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");
}
 
Example 11
Project: ZooKeeper   File: ZooInspectorManagerImpl.java   View Source Code Vote up 5 votes
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 = "";
    }
}
 
Example 12
Project: gw4e.project   File: BuildPoliciesCache.java   View Source Code Vote up 5 votes
/**
 * @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;
	}
}
 
Example 13
Project: rocketmq-easyclient   File: EasyMQPushConsumer.java   View Source Code Vote up 5 votes
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;
}
 
Example 14
Project: mi-firma-android   File: AdESPolicy.java   View Source Code Vote up 4 votes
/** Crea una pol&iacute;tica AdES a partir de un fichero de propiedades.
   * Las propiedades aceptadas son:
   * <ul>
   *  <li><b>policyIdentifier</b>: Identificador de la pol&iacute;tica de firma (URL u OID
   *  directo o como URN que identifica un&iacute;vocamente el fichero de pol&iacute;tica
   *  computacionalmente procesable)
   *  <li><b>policyIdentifierHash</b>: Huella digital de la pol&iacute;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&aacute;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&oacute;n legible de la
   *  pol&iacute;tica (normalmente un PDF)
   * </ul>
   * @param extraParams Propiedades de la pol&iacute;tica
   * @return Configuraci&oacute;n de pol&iacute;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&iacute;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$
);
  }
 
Example 15
Project: summer-mybatis-generator   File: MyBatisGeneratorConfigurationParser.java   View Source Code Vote up 4 votes
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);
}
 
Example 16
Project: oscm   File: ServiceInstance.java   View Source Code Vote up 4 votes
private String getStringProperty(Properties rollbackProps,
        String propertyName) {
    String propertyValue = rollbackProps.getProperty(propertyName);
    rollbackProps.remove(propertyName);
    return propertyValue;
}
 
Example 17
Project: parabuild-ci   File: Version.java   View Source Code Vote up 4 votes
private static String readReleaseProperty(final String propertyName) {

    final Properties parabuildVersionProperties = readParabuildVersionProperties();
    return parabuildVersionProperties.getProperty(propertyName);
  }
 
Example 18
Project: incubator-netbeans   File: ForeignClassBundlerImpl.java   View Source Code Vote up 4 votes
private boolean calculateValue() {
        NbMavenProject nbmp = project.getLookup().lookup(NbMavenProject.class);
        if (nbmp == null) {
            return true;
        }
        boolean oldVal = hasProblem.get();
        boolean newVal = false;
        try {
        MavenProject mp = nbmp.getMavenProject();
        Properties props = PluginPropertyUtils.getPluginPropertyParameter(project, "org.apache.felix", "maven-bundle-plugin", "instructions", "bundle");
        if (props != null) {
            //String embed = props.getProperty("Embed-Dependency"); //TODO should we parse it somehow?
            //are embedded ones a problem? not on CP I guess
//            if (embed != null && embed.contains("inline=true")) {
//                return false;
//            }
            String exportedPack = props.getProperty("Export-Package");
            String privatePack = props.getProperty("Private-Package");
            if (exportedPack != null || privatePack != null) {
                Matcher exported = new Matcher(exportedPack);
                Matcher prived = new Matcher(privatePack);
                for (Artifact a : mp.getRuntimeArtifacts()) { //TODO runtime or compile??
                    File f = a.getFile();
                    if (f != null && f.isFile()) {
                        try {
                            JarFile jf = new JarFile(f);
                            Enumeration<JarEntry> en = jf.entries();
                            while (en.hasMoreElements()) {
                                JarEntry je = en.nextElement();
                                if (je.isDirectory() && !je.getName().startsWith("META-INF")) { //is this optimization correct?
                                    String pack = je.getName().substring(0, je.getName().length() - 1).replace("/", "."); //last char is /
                                    if (exported.matches(pack) || prived.matches(pack)) {
                                        newVal = true;
                                        return false;
                                    }
                                }
                            }
                        } catch (IOException ex) {
                            Exceptions.printStackTrace(ex);
                        }
                    }
                }
            }
        }
        } finally {
            if (newVal != oldVal) {
                hasProblem.set(newVal);
                RP.post(new Runnable() {
                    @Override
                    public void run() {
                        pchs.firePropertyChange(ProjectProblemsProvider.PROP_PROBLEMS, null, null);
                    }
                });
            }
        }
        //according to http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html default value is just 
        //project's own sources
        return true;
    }
 
Example 19
Project: LightSIP   File: ServerLog.java   View Source Code Vote up 4 votes
private void setProperties(Properties configurationProperties) {
    this.configurationProperties = configurationProperties;
    // Set a descriptive name for the message trace logger.
    this.description = configurationProperties.getProperty("javax.sip.STACK_NAME");
    this.stackIpAddress = configurationProperties.getProperty("javax.sip.IP_ADDRESS");
    this.logFileName = configurationProperties.getProperty("gov.nist.javax.sip.SERVER_LOG");
    String logLevel = configurationProperties.getProperty("gov.nist.javax.sip.TRACE_LEVEL");
    String logContent = configurationProperties
            .getProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT");

    this.logContent = (logContent != null && logContent.equals("true"));

    if (logLevel != null) {
        if (logLevel.equals("LOG4J")) {
        	CommonLogger.useLegacyLogger = false;
        } else {
            try {
                int ll;
                if (logLevel.equals("DEBUG")) {
                    ll = TRACE_DEBUG;
                } else if (logLevel.equals("INFO")) {
                    ll = TRACE_MESSAGES;
                } else if (logLevel.equals("ERROR")) {
                    ll = TRACE_EXCEPTION;
                } else if (logLevel.equals("NONE") || logLevel.equals("OFF")) {
                    ll = TRACE_NONE;
                } else {
                    ll = Integer.parseInt(logLevel);
                }

                this.setTraceLevel(ll);
            } catch (NumberFormatException ex) {
                System.out.println("ServerLog: WARNING Bad integer " + logLevel);
                System.out.println("logging dislabled ");
                this.setTraceLevel(0);
            }
        }
    }
    checkLogFile();

}
 
Example 20
Project: BaseClient   File: CustomColors.java   View Source Code Vote up 4 votes
private static int[] readSpawnEggColors(Properties p_readSpawnEggColors_0_, String p_readSpawnEggColors_1_, String p_readSpawnEggColors_2_, String p_readSpawnEggColors_3_)
{
    List<Integer> list = new ArrayList();
    Set set = p_readSpawnEggColors_0_.keySet();
    int i = 0;

    for (Object s : set)
    {
        String s1 = p_readSpawnEggColors_0_.getProperty((String) s);

        if (((String) s).startsWith(p_readSpawnEggColors_2_))
        {
            String s2 = StrUtils.removePrefix((String) s, p_readSpawnEggColors_2_);
            int j = getEntityId(s2);
            int k = parseColor(s1);

            if (j >= 0 && k >= 0)
            {
                while (((List)list).size() <= j)
                {
                    list.add(Integer.valueOf(-1));
                }

                list.set(j, Integer.valueOf(k));
                ++i;
            }
            else
            {
                warn("Invalid spawn egg color: " + s + " = " + s1);
            }
        }
    }

    if (i <= 0)
    {
        return null;
    }
    else
    {
        dbg(p_readSpawnEggColors_3_ + " colors: " + i);
        int[] aint = new int[list.size()];

        for (int l = 0; l < aint.length; ++l)
        {
            aint[l] = ((Integer)list.get(l)).intValue();
        }

        return aint;
    }
}