OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [javax/] [swing/] [text/] [html/] [ObjectView.java] - Blame information for rev 772

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 772 jeremybenn
/* ObjectView.java -- A view for HTML object tags
2
   Copyright (C) 2006 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package javax.swing.text.html;
40
 
41
import java.awt.Component;
42
 
43
import javax.swing.text.AttributeSet;
44
import javax.swing.text.ComponentView;
45
import javax.swing.text.Element;
46
 
47
/**
48
 * A view for HTML <code>&lt;object&gt;</code> tags.
49
 *
50
 * This is a {@link ComponentView} that creates special components depending
51
 * on the object specification. If the object tag has a classid attribute, then
52
 * this view will try to load the class specified by this attribute using the
53
 * classloader that loaded the associated document. If the class could be
54
 * loaded, an instance is created and the type narrowed to {@link Component}.
55
 *
56
 * It is also possible to set bean properties on the created component using
57
 * nested <code>&lt;param&gt;</code> tags. For example:
58
 * <pre>
59
 * <object classid="javax.swing.JLabel">
60
 *   <param name="text" value="sample text">
61
 * </object>
62
 * </pre>
63
 *
64
 * @author Roman Kennke (kennke@aicas.com)
65
 */
66
public class ObjectView extends ComponentView
67
{
68
 
69
  /**
70
   * Creates a new <code>ObjectView</code>.
71
   *
72
   * @param el the element for which to create a view
73
   */
74
  public ObjectView(Element el)
75
  {
76
    super(el);
77
  }
78
 
79
  /**
80
   * Creates a component based on the specification in the element of this
81
   * view. See the class description for details.
82
   */
83
  protected Component createComponent()
84
  {
85
    Component comp = null;
86
    Element el = getElement();
87
    AttributeSet atts = el.getAttributes();
88
    String classId = (String) atts.getAttribute("classid");
89
    try
90
      {
91
        Class<?> objectClass = Class.forName(classId);
92
        Object instance = objectClass.newInstance();
93
        comp = (Component) instance;
94
      }
95
    catch (ClassNotFoundException ex)
96
      {
97
        // Ignored.
98
      }
99
    catch (IllegalAccessException ex)
100
      {
101
        // Ignored.
102
      }
103
    catch (InstantiationException ex)
104
      {
105
        // Ignored.
106
      }
107
    // FIXME: Handle param tags and set bean properties accordingly.
108
    return comp;
109
  }
110
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.