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

The following are Jave code examples for showing how to use get() 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: lams   File: SequenceGenerator.java   View Source Code Vote up 10 votes
@Override
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
	ObjectNameNormalizer normalizer = ( ObjectNameNormalizer ) params.get( IDENTIFIER_NORMALIZER );
	sequenceName = normalizer.normalizeIdentifierQuoting(
			ConfigurationHelper.getString( SEQUENCE, params, "hibernate_sequence" )
	);
	parameters = params.getProperty( PARAMETERS );

	if ( sequenceName.indexOf( '.' ) < 0 ) {
		final String schemaName = normalizer.normalizeIdentifierQuoting( params.getProperty( SCHEMA ) );
		final String catalogName = normalizer.normalizeIdentifierQuoting( params.getProperty( CATALOG ) );
		sequenceName = Table.qualify(
				dialect.quote( catalogName ),
				dialect.quote( schemaName ),
				dialect.quote( sequenceName )
		);
	}
	else {
		// if already qualified there is not much we can do in a portable manner so we pass it
		// through and assume the user has set up the name correctly.
	}

	this.identifierType = type;
	sql = dialect.getSequenceNextValString( sequenceName );
}
 
Example 2
Project: tomcat7   File: GenericParser.java   View Source Code Vote up 7 votes
/**
 * Create a <code>SAXParser</code> configured to support XML Schema and DTD
 * @param properties parser specific properties/features
 * @return an XML Schema/DTD enabled <code>SAXParser</code>
 */
public static SAXParser newSAXParser(Properties properties)
        throws ParserConfigurationException, 
               SAXException,
               SAXNotRecognizedException{ 

    SAXParserFactory factory = 
                    (SAXParserFactory)properties.get("SAXParserFactory");
    SAXParser parser = factory.newSAXParser();
    String schemaLocation = (String)properties.get("schemaLocation");
    String schemaLanguage = (String)properties.get("schemaLanguage");

    try{
        if (schemaLocation != null) {
            parser.setProperty(JAXP_SCHEMA_LANGUAGE, schemaLanguage);
            parser.setProperty(JAXP_SCHEMA_SOURCE, schemaLocation);
        }
    } catch (SAXNotRecognizedException e){
        log.info(parser.getClass().getName() + ": "  
                                    + e.getMessage() + " not supported."); 
    }
    return parser;
}
 
Example 3
Project: lazycat   File: GenericParser.java   View Source Code Vote up 7 votes
/**
 * Create a <code>SAXParser</code> configured to support XML Schema and DTD
 * 
 * @param properties
 *            parser specific properties/features
 * @return an XML Schema/DTD enabled <code>SAXParser</code>
 */
public static SAXParser newSAXParser(Properties properties)
		throws ParserConfigurationException, SAXException, SAXNotRecognizedException {

	SAXParserFactory factory = (SAXParserFactory) properties.get("SAXParserFactory");
	SAXParser parser = factory.newSAXParser();
	String schemaLocation = (String) properties.get("schemaLocation");
	String schemaLanguage = (String) properties.get("schemaLanguage");

	try {
		if (schemaLocation != null) {
			parser.setProperty(JAXP_SCHEMA_LANGUAGE, schemaLanguage);
			parser.setProperty(JAXP_SCHEMA_SOURCE, schemaLocation);
		}
	} catch (SAXNotRecognizedException e) {
		log.info(parser.getClass().getName() + ": " + e.getMessage() + " not supported.");
	}
	return parser;
}
 
Example 4
Project: apache-tomcat-7.0.73-with-comment   File: XercesParser.java   View Source Code Vote up 6 votes
/**
 * Create a <code>SAXParser</code> based on the underlying
 * <code>Xerces</code> version.
 * @param properties parser specific properties/features
 * @return an XML Schema/DTD enabled <code>SAXParser</code>
 */
public static SAXParser newSAXParser(Properties properties) 
        throws ParserConfigurationException, 
               SAXException,
               SAXNotSupportedException {

    SAXParserFactory factory =  
                    (SAXParserFactory)properties.get("SAXParserFactory");

    if (versionNumber == null){
        versionNumber = getXercesVersion();
        version = Float.parseFloat(versionNumber);
    }

    // Note: 2.2 is completely broken (with XML Schema). 
    if (version > 2.1) {

        configureXerces(factory);
        return factory.newSAXParser();
    } else {
        SAXParser parser = factory.newSAXParser();
        configureOldXerces(parser,properties);
        return parser;
    }
}
 
Example 5
Project: OpenJSharp   File: MimeTable.java   View Source Code Vote up 6 votes
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);
    }
}
 
Example 6
Project: flume-release-1.7.0   File: FlumeConfiguration.java   View Source Code Vote up 6 votes
/**
 * Creates a populated Flume Configuration object.
 * @deprecated please use the other constructor
 */
@Deprecated
public FlumeConfiguration(Properties properties) {
  agentConfigMap = new HashMap<String, AgentConfiguration>();
  errors = new LinkedList<FlumeConfigurationError>();
  // Construct the in-memory component hierarchy
  for (Object name : properties.keySet()) {
    Object value = properties.get(name);
    if (!addRawProperty(name.toString(), value.toString())) {
      logger.warn("Configuration property ignored: " + name + " = " + value);
    }
  }
  // Now iterate thru the agentContext and create agent configs and add them
  // to agentConfigMap

  // validate and remove improperly configured components
  validateConfiguration();
}
 
Example 7
Project: lams   File: SQLExceptionConverterFactory.java   View Source Code Vote up 6 votes
/**
 * Build a SQLExceptionConverter instance.
 * <p/>
 * First, looks for a {@link Environment#SQL_EXCEPTION_CONVERTER} property to see
 * if the configuration specified the class of a specific converter to use.  If this
 * property is set, attempt to construct an instance of that class.  If not set, or
 * if construction fails, the converter specific to the dialect will be used.
 *
 * @param dialect    The defined dialect.
 * @param properties The configuration properties.
 * @return An appropriate SQLExceptionConverter instance.
 * @throws HibernateException There was an error building the SQLExceptionConverter.
 */
public static SQLExceptionConverter buildSQLExceptionConverter(Dialect dialect, Properties properties) throws HibernateException {
	SQLExceptionConverter converter = null;

	String converterClassName = (String) properties.get( Environment.SQL_EXCEPTION_CONVERTER );
	if ( StringHelper.isNotEmpty( converterClassName ) ) {
		converter = constructConverter( converterClassName, dialect.getViolatedConstraintNameExtracter() );
	}

	if ( converter == null ) {
		LOG.trace( "Using dialect defined converter" );
		converter = dialect.buildSQLExceptionConverter();
	}

	if ( converter instanceof Configurable ) {
		try {
			( (Configurable) converter ).configure( properties );
		}
		catch (HibernateException e) {
			LOG.unableToConfigureSqlExceptionConverter( e );
			throw e;
		}
	}

	return converter;
}
 
Example 8
Project: openjdk-jdk10   File: Agent.java   View Source Code Vote up 6 votes
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());
        }
    }
}
 
Example 9
Project: oscm   File: DbMessages.java   View Source Code Vote up 6 votes
/**
 * Gets an object for the given key from this resource bundle (if we have
 * customized translations use them otherwise return the default one).
 * Returns null if this resource bundle does not contain an object for the
 * given key.
 * 
 * @param key
 *            the key for the desired object
 * 
 * @return the object for the given key, or null
 * 
 * @throws NullPointerException
 *             if key is null
 */
@Override
public Object handleGetObject(String key) {
    if (key == null) {
        throw new NullPointerException();
    }

    final Properties properties = getProperties();
    if (properties != null) {
        final Object obj = properties.get(key);
        if (obj != null && obj.toString().trim().length() != 0) {
            return obj;
        }
    }
    if (this.getClass().equals(DbMessages.class)
            && key.startsWith("locale.")) {
        return "";
    }
    return super.handleGetObject(key);
}
 
Example 10
Project: lams   File: XercesParser.java   View Source Code Vote up 6 votes
/**
 * Create a <code>SAXParser</code> based on the underlying
 * <code>Xerces</code> version.
 * @param properties parser specific properties/features
 * @return an XML Schema/DTD enabled <code>SAXParser</code>
 */
public static SAXParser newSAXParser(Properties properties) 
        throws ParserConfigurationException, 
               SAXException,
               SAXNotSupportedException {

    SAXParserFactory factory =  
                    (SAXParserFactory)properties.get("SAXParserFactory");

    if (versionNumber == null){
        versionNumber = getXercesVersion();
        version = new Float( versionNumber ).floatValue();
    }

    // Note: 2.2 is completely broken (with XML Schema). 
    if (version > 2.1) {

        configureXerces(factory);
        return factory.newSAXParser();
    } else {
        SAXParser parser = factory.newSAXParser();
        configureOldXerces(parser,properties);
        return parser;
    }
}
 
Example 11
Project: gocd-filebased-authentication-plugin   File: Util.java   View Source Code Vote up 5 votes
public static String pluginVersion() {
    String s = readResource("/plugin.properties");
    try {
        Properties properties = new Properties();
        properties.load(new StringReader(s));
        return (String) properties.get("version");
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 12
Project: openjdk-jdk10   File: ToStream.java   View Source Code Vote up 5 votes
/**
 * Specifies an output format for this serializer. It the
 * serializer has already been associated with an output format,
 * it will switch to the new format. This method should not be
 * called while the serializer is in the process of serializing
 * a document.
 *
 * @param format The output format to use
 */
public void setOutputFormat(Properties format) {
    boolean shouldFlush = m_shouldFlush;

    if (format != null) {
        // Set the default values first,
        // and the non-default values after that,
        // just in case there is some unexpected
        // residual values left over from over-ridden default values
        Enumeration propNames;
        propNames = format.propertyNames();
        while (propNames.hasMoreElements()) {
            String key = (String) propNames.nextElement();
            // Get the value, possibly a default value
            String value = format.getProperty(key);
            // Get the non-default value (if any).
            String explicitValue = (String) format.get(key);
            if (explicitValue == null && value != null) {
                // This is a default value
                this.setOutputPropertyDefault(key,value);
            }
            if (explicitValue != null) {
                // This is an explicit non-default value
                this.setOutputProperty(key,explicitValue);
            }
        }
    }

    // Access this only from the Hashtable level... we don't want to
    // get default properties.
    String entitiesFileName =
        (String) format.get(OutputPropertiesFactory.S_KEY_ENTITIES);

    if (null != entitiesFileName) {
        String method = (String) format.get(OutputKeys.METHOD);
        m_charInfo = CharInfo.getCharInfo(entitiesFileName, method);
    }

    m_shouldFlush = shouldFlush;
}
 
Example 13
Project: monarch   File: TierEvictorThread.java   View Source Code Vote up 5 votes
/**
 * Get the required table attributes like time-to-expire and partitioning-interval. For tests,
 * when enabled via TEST_EVICT, returns the values the map.
 *
 * @param tierProps the tier properties
 * @return an array with time-to-expire and partitioning-interval
 */
private long[] getTableAttributes(final Properties tierProps) {
  return TEST_EVICT && TEST_TIER_EVICT_INTERVAL.get(tierName) != null
      ? new long[] {TEST_TIER_EVICT_INTERVAL.get(tierName) * TO_MS,
          TierStoreConfiguration.DEFAULT_TIER_PARTITION_INTERVAL_MS}
      /* get the required information from table descriptor */
      : new long[] {(long) tierProps.get(TierStoreConfiguration.TIER_TIME_TO_EXPIRE),
          (long) tierProps.get(TierStoreConfiguration.TIER_PARTITION_INTERVAL)};
}
 
Example 14
Project: Equella   File: DeleteLuceneIndex.java   View Source Code Vote up 5 votes
@Override
public void upgrade(UpgradeResult result, File tleInstallDir) throws Exception
{
	result.setCanRetry(true);
	final File configFolder = new File(tleInstallDir, CONFIG_FOLDER);
	Properties props = loadProperties(new File(configFolder, PropertyFileModifier.MANDATORY_CONFIG));
	File indexDir = new File((String) props.get("freetext.index.location"));
	if( !indexDir.isAbsolute() )
	{
		result.addLogMessage("Freetext dir is not absolute (" + indexDir + "), skipping");
		return;
	}
	FileUtils.delete(indexDir);
}
 
Example 15
Project: CentauriCloud   File: CloudConfiguration.java   View Source Code Vote up 4 votes
public CloudConfiguration(Properties properties) {

		this.hostname = (String) properties.get("hostname");
		this.port = Integer.parseInt(properties.getProperty("port"));
		this.prefix = (String) properties.get("prefix");
	}
 
Example 16
Project: wxcard   File: PropertiesUtil.java   View Source Code Vote up 4 votes
private static void init() throws IOException{
	Properties properties = new Properties();
	properties.load(PropertiesUtil.class.getClassLoader().getResourceAsStream("wx.properties"));
	appid = (String) properties.get("appid");
	appsecret = (String) properties.get("appsecret");
}
 
Example 17
Project: oscm   File: IdentityServiceBean.java   View Source Code Vote up 4 votes
@Override
@Interceptors({ ServiceProviderInterceptor.class })
public List<VOUserDetails> searchLdapUsers(final String userIdPattern)
        throws ValidationException {

    ArgumentValidator.notNull("userIdPattern", userIdPattern);

    Organization organization = dm.getCurrentUser().getOrganization();

    LdapConnector connector = getLdapConnectionForOrganization(
            organization);
    Properties dirProperties = connector.getDirProperties();
    Map<SettingType, String> attrMap = connector.getAttrMap();
    String baseDN = connector.getBaseDN();

    List<SettingType> attrList = new ArrayList<>(attrMap.keySet());
    ILdapResultMapper<VOUserDetails> mapper = new LdapVOUserDetailsMapper(
            null, attrMap);
    try {
        // read user from LDAP
        List<VOUserDetails> voUserList = ldapAccess.search(dirProperties,
                baseDN, getLdapSearchFilter(attrMap, userIdPattern), mapper,
                false);

        int size = voUserList.size();
        for (int i = 0; i < size; i++) {
            VOUserDetails voUser = voUserList.get(i);
            PlatformUser user = getPlatformUserByOrgAndReamUserId(
                    organization, voUser.getRealmUserId());
            if (null != user) {
                // update the domain object with possibly changed LDAP
                // attributes and return a complete value object
                UserDataAssembler.updatePlatformUser(voUser, attrList,
                        user);
                voUserList.set(i, UserDataAssembler.toVOUserDetails(user));
            } else {
                // set some mandatory attributes
                voUser.setOrganizationId(organization.getOrganizationId());
                String locale = voUser.getLocale();
                if (locale == null || locale.trim().length() == 0) {
                    voUser.setLocale(organization.getLocale());
                }
            }
        }
        return voUserList;
    } catch (NamingException e) {
        Object[] params = new Object[] {
                dirProperties.get(Context.PROVIDER_URL), e.getMessage() };
        ValidationException vf = new ValidationException(
                ReasonEnum.LDAP_CONNECTION_REFUSED, null, params);
        logger.logError(Log4jLogger.SYSTEM_LOG, vf,
                LogMessageIdentifier.ERROR_LDAP_SYSTEM_CONNECTION_REFUSED);
        throw vf;
    }
}
 
Example 18
Project: BaseClient   File: TextureAnimation.java   View Source Code Vote up 4 votes
public TextureAnimation(String p_i83_1_, byte[] p_i83_2_, String p_i83_3_, ResourceLocation p_i83_4_, int p_i83_5_, int p_i83_6_, int p_i83_7_, int p_i83_8_, Properties p_i83_9_, int p_i83_10_)
{
    this.srcTex = p_i83_1_;
    this.dstTex = p_i83_3_;
    this.dstTexLoc = p_i83_4_;
    this.dstX = p_i83_5_;
    this.dstY = p_i83_6_;
    this.frameWidth = p_i83_7_;
    this.frameHeight = p_i83_8_;
    int i = p_i83_7_ * p_i83_8_ * 4;

    if (p_i83_2_.length % i != 0)
    {
        Config.warn("Invalid animated texture length: " + p_i83_2_.length + ", frameWidth: " + p_i83_7_ + ", frameHeight: " + p_i83_8_);
    }

    this.srcData = p_i83_2_;
    int j = p_i83_2_.length / i;

    if (p_i83_9_.get("tile.0") != null)
    {
        for (int k = 0; p_i83_9_.get("tile." + k) != null; ++k)
        {
            j = k + 1;
        }
    }

    String s2 = (String)p_i83_9_.get("duration");
    int l = Config.parseInt(s2, p_i83_10_);
    this.frames = new TextureAnimationFrame[j];

    for (int i1 = 0; i1 < this.frames.length; ++i1)
    {
        String s = (String)p_i83_9_.get("tile." + i1);
        int j1 = Config.parseInt(s, i1);
        String s1 = (String)p_i83_9_.get("duration." + i1);
        int k1 = Config.parseInt(s1, l);
        TextureAnimationFrame textureanimationframe = new TextureAnimationFrame(j1, k1);
        this.frames[i1] = textureanimationframe;
    }
}
 
Example 19
Project: lams   File: TableGenerator.java   View Source Code Vote up 2 votes
/**
 * Determine the name of the column used to indicate the segment for each
 * row.  This column acts as the primary key.
 * <p/>
 * Called during {@link #configure configuration}.
 *
 * @see #getSegmentColumnName()
 * @param params The params supplied in the generator config (plus some standard useful extras).
 * @param dialect The dialect in effect
 * @return The name of the segment column
 */
protected String determineSegmentColumnName(Properties params, Dialect dialect) {
	final ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( IDENTIFIER_NORMALIZER );
	final String name = ConfigurationHelper.getString( SEGMENT_COLUMN_PARAM, params, DEF_SEGMENT_COLUMN );
	return dialect.quote( normalizer.normalizeIdentifierQuoting( name ) );
}
 
Example 20
Project: lams   File: TableGenerator.java   View Source Code Vote up 2 votes
/**
 * Determine the name of the column in which we will store the generator persistent value.
 * <p/>
 * Called during {@link #configure configuration}.
 *
 * @see #getValueColumnName()
 * @param params The params supplied in the generator config (plus some standard useful extras).
 * @param dialect The dialect in effect
 * @return The name of the value column
 */
protected String determineValueColumnName(Properties params, Dialect dialect) {
	final ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( IDENTIFIER_NORMALIZER );
	final String name = ConfigurationHelper.getString( VALUE_COLUMN_PARAM, params, DEF_VALUE_COLUMN );
	return dialect.quote( normalizer.normalizeIdentifierQuoting( name ) );
}