001/*****************************************************************************
002 * Copyright by The HDF Group.                                               *
003 * Copyright by the Board of Trustees of the University of Illinois.         *
004 * All rights reserved.                                                      *
005 *                                                                           *
006 * This file is part of the HDF Java Products distribution.                  *
007 * The full copyright notice, including terms governing use, modification,   *
008 * and redistribution, is contained in the files COPYING and Copyright.html. *
009 * COPYING can be found at the root of the source code distribution tree.    *
010 * Or, see https://support.hdfgroup.org/products/licenses.html               *
011 * If you do not have access to either file, you may request a copy from     *
012 * help@hdfgroup.org.                                                        *
013 ****************************************************************************/
014
015package hdf.object.h5;
016
017import java.util.List;
018
019import hdf.hdf5lib.structs.H5O_info_t;
020import hdf.object.FileFormat;
021import hdf.object.HObject;
022import hdf.object.MetaDataContainer;
023
024/**
025 * An H5Link object represents an existing HDF5 object in file.
026 * <p>
027 * H5Link object is an HDF5 object that is either a soft or an external link to
028 * an object in a file that does not exist. The type of the object is unknown.
029 * Once the object being linked to is created, and the type is known, then
030 * H5link object will change its type.
031 *
032 * @version 2.7.2 7/6/2010
033 * @author Nidhi Gupta
034 */
035
036public class H5Link extends HObject implements MetaDataContainer {
037    private static final long serialVersionUID = -8137277460521594367L;
038
039    @SuppressWarnings("unused")
040    private H5O_info_t obj_info;
041
042    /**
043     * Constructs an HDF5 link with specific name, path, and parent.
044     *
045     * @param theFile
046     *            the file which containing the link.
047     * @param name
048     *            the name of this link, e.g. "link1".
049     * @param path
050     *            the full path of this link, e.g. "/groups/".
051     */
052    public H5Link(FileFormat theFile, String name, String path) {
053        this (theFile, name, path, null);
054    }
055
056    @SuppressWarnings("deprecation")
057    public H5Link(FileFormat theFile, String theName, String thePath,
058            long[] oid) {
059        super(theFile, theName, thePath, oid);
060
061        obj_info = new H5O_info_t(-1L, -1L, -1, 0, -1L, 0L, 0L, 0L, 0L, null,null,null);
062    }
063
064    @Override
065    public void close(long id) {
066    }
067
068    @Override
069    public long open() {
070        return 0;
071    }
072
073    @SuppressWarnings("rawtypes")
074    public List getMetadata() throws Exception {
075
076        try{
077            this.linkTargetObjName= H5File.getLinkTargetName(this);
078        }catch(Exception ex){
079        }
080
081        return null;
082    }
083
084    public boolean hasAttribute() {
085        return false;
086    }
087
088    public void removeMetadata(Object info) throws Exception {
089    }
090
091    public void writeMetadata(Object info) throws Exception {
092    }
093
094    public void updateMetadata(Object info) throws Exception {
095    }
096
097    @SuppressWarnings("rawtypes")
098    public List getMetadata(int... attrPropList) throws Exception {
099        return null;
100    }
101
102    /*
103     * (non-Javadoc)
104     *
105     * @see hdf.object.HObject#setName(java.lang.String)
106     */
107    @Override
108    public void setName(String newName) throws Exception {
109        if (newName == null)
110            throw new IllegalArgumentException("The new name is NULL");
111
112        H5File.renameObject(this, newName);
113        super.setName(newName);
114    }
115}