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

src.gov.nasa.worldwind.ogc.collada.ColladaAbstractParamContainer Maven / Gradle / Ivy

Go to download

World Wind is a collection of components that interactively display 3D geographic information within Java applications or applets.

There is a newer version: 2.0.0-986
Show newest version
/*
 * Copyright (C) 2012 United States Government as represented by the Administrator of the
 * National Aeronautics and Space Administration.
 * All Rights Reserved.
 */

package gov.nasa.worldwind.ogc.collada;

import java.util.*;

/**
 * Base class for COLLADA elements that hold parameters.
 *
 * @author pabercrombie
 * @version $Id: ColladaAbstractParamContainer.java 654 2012-06-25 04:15:52Z pabercrombie $
 */
public class ColladaAbstractParamContainer extends ColladaAbstractObject
{
    /** Named newparam elements in the container. */
    protected Map newParams;

    /**
     * Construct an instance.
     *
     * @param namespaceURI the qualifying namespace URI. May be null to indicate no namespace qualification.
     */
    protected ColladaAbstractParamContainer(String namespaceURI)
    {
        super(namespaceURI);
    }

    /**
     * Find a NewParam item by scoped ID (the sid attribute of the param).
     *
     * @param sid Id to search for.
     *
     * @return The requested parameter, or null if no such parameter can be found.
     */
    public ColladaNewParam getParam(String sid)
    {
        if (this.newParams != null)
            return this.newParams.get(sid);

        return null;
    }

    /** {@inheritDoc} */
    @Override
    public void setField(String keyName, Object value)
    {
        if ("newparam".equals(keyName))
        {
            ColladaNewParam param = (ColladaNewParam) value;
            String sid = (String) param.getField("sid");

            // SID is a required attribute of newparam, so should never be null. Check for null to guard against
            // malformed documents, and just ignore the parameter in this these cases.
            if (sid != null)
            {
                if (this.newParams == null)
                    this.newParams = new HashMap();

                this.newParams.put(sid, param);
            }
        }
        else
        {
            super.setField(keyName, value);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy