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