All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.persistence.internal.oxm.schema.SchemaModelGeneratorProperties Maven / Gradle / Ivy

There is a newer version: 4.0.2
Show newest version
/*
 * Copyright (c) 1998, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0,
 * or the Eclipse Distribution License v. 1.0 which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 */

// Contributors:
// dmccann - Mar 2/2009 - 2.0 - Initial implementation
package org.eclipse.persistence.internal.oxm.schema;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.eclipse.persistence.internal.oxm.schema.model.Schema;

/**
 * INTERNAL:
 *  

Purpose:Encapsulates a Map of Namespace URIs to Properties. *

Responsibilities:

    *
  • Provide an API to set key/value pairs on a per namespace URI bases
  • *
  • Lazily initialize a new Properties object for each namespace
  • *
  • Provide an API to retrieve the entire map of namespace URI to Properties
  • *
  • Provide an API to retrieve the property value for a given namespace URI and key
  • *
*

This class is used to hold onto a Map of Properties objects on a per namespace basis. * It is intended to be used in conjunction with the SchemaModelGenerator class, to hand in * Properties to be applied to the Schema that is generated for a given namespace. * * @see Schema * @see SchemaModelGenerator * @see Properties */ public class SchemaModelGeneratorProperties { protected Map propMap; // statics public static final String ATTRIBUTE_FORM_QUALIFIED_KEY = "attributeFormQualified"; public static final String ELEMENT_FORM_QUALIFIED_KEY = "elementFormQualified"; public SchemaModelGeneratorProperties() {} /** * Lazily initialize the URI->Properties map * @return */ public Map getPropertiesMap() { if (propMap == null) { propMap = new HashMap(); } return propMap; } /** * Adds the key/value pair to the Properties object associated with the given * namespace URI. If no entry exists for the given URI, a Properties object * will be created. * * @param uri * @param key * @param value */ public void addProperty(String uri, String key, Object value) { if (uri == null || key == null || value == null) { return; } Map pMap = getPropertiesMap(); Properties props = pMap.get(uri); if (props == null) { props = new Properties(); pMap.put(uri, props); } props.put(key, value); } /** * Return the property value for a given namespace/key pair. * * @param uri * @param key * @return */ public Object getProperty(String uri, String key) { if (uri == null || key == null) { return null; } Map pMap = getPropertiesMap(); Properties props = pMap.get(uri); if (props == null) { return null; } return props.get(key); } /** * Return the Properties object for the given namespace uri. * If none exists a new Properties is created and returned. * * @return */ public Properties getProperties(String uri) { return getPropertiesMap().get(uri); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy