KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > media > format > image > iio > IIOMediaHeader


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package org.jboss.media.format.image.iio;
9
10 import javax.emb.MediaHeader;
11 import javax.imageio.metadata.IIOMetadata JavaDoc;
12
13 import org.jboss.media.util.DOMUtils;
14 import org.w3c.dom.Node JavaDoc;
15
16 /**
17  * Java Image I/O API generic implementation of the <code>MediaHeader</code>
18  * interface.
19  *
20  * @version <tt>$Revision: 1.1 $</tt>
21  * @author <a HREF="mailto:ricardoarguello@users.sourceforge.net">Ricardo Argüello</a>
22  */

23 public abstract class IIOMediaHeader implements MediaHeader
24 {
25    protected IIOMetadata JavaDoc imageMetadata;
26    protected Node JavaDoc metadataRootNode;
27
28    /**
29     * Constructor.
30     *
31     * @param imageMetadata
32     * @param formatName
33     */

34    public IIOMediaHeader(IIOMetadata JavaDoc imageMetadata, String JavaDoc formatName)
35    {
36       this.imageMetadata = imageMetadata;
37       this.metadataRootNode = imageMetadata.getAsTree(formatName);
38    }
39
40    /**
41     * @see javax.emb.MediaHeader#getFieldNames()
42     */

43    public abstract String JavaDoc[] getFieldNames();
44
45    /**
46     * @see javax.emb.MediaHeader#getField(java.lang.String)
47     */

48    public abstract Object JavaDoc getField(String JavaDoc fieldname);
49
50    protected Node JavaDoc getNode(String JavaDoc node)
51    {
52       return getNode(metadataRootNode, node);
53    }
54
55    protected Node JavaDoc getNode(Node JavaDoc parentNode, String JavaDoc node)
56    {
57       return DOMUtils.findNode(parentNode, node);
58    }
59
60    protected String JavaDoc getAttribute(String JavaDoc node, String JavaDoc attribute)
61    {
62       return getAttribute(getNode(node), attribute);
63    }
64
65    protected String JavaDoc getAttribute(Node JavaDoc node, String JavaDoc attribute)
66    {
67       return DOMUtils.getNodeAttribute(node, attribute);
68    }
69 }
70
Popular Tags