diff options
author | Thomas Fitzsimmons <fitzsim@redhat.com> | 2006-06-09 16:07:07 +0000 |
---|---|---|
committer | Thomas Fitzsimmons <fitzsim@gcc.gnu.org> | 2006-06-09 16:07:07 +0000 |
commit | 02440ca432f1aa4de7aeda563d2493a20148554b (patch) | |
tree | 0802013820f309170e8ae5584b09e9672bab2cb6 /libjava/classpath/gnu/javax | |
parent | 6c65d7577ca4e36675571fd8bad43ef6d34e2831 (diff) | |
download | gcc-02440ca432f1aa4de7aeda563d2493a20148554b.zip gcc-02440ca432f1aa4de7aeda563d2493a20148554b.tar.gz gcc-02440ca432f1aa4de7aeda563d2493a20148554b.tar.bz2 |
String.java, [...]: Merge from GNU Classpath HEAD.
2006-06-09 Thomas Fitzsimmons <fitzsim@redhat.com>
* java/lang/String.java, classpath/native/jni/classpath/jcl.h,
classpath/native/jni/qt-peer/eventmethods.h,
classpath/native/jni/qt-peer/qtmenupeer.cpp,
classpath/native/jni/qt-peer/.cvsignore,
classpath/native/jni/gtk-peer/gdkdisplay.h,
classpath/native/jni/gtk-peer/cairographics2d.h,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c,
classpath/native/jni/gtk-peer/.cvsignore,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c,
classpath/native/jni/gtk-peer/gtkpeer.h,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c,
classpath/native/jni/gtk-peer/Makefile.am,
classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c,
classpath/native/jawt/Makefile.am,
classpath/native/jawt/.cvsignore,
classpath/native/target/Linux/Makefile.in,
classpath/native/plugin/gcjwebplugin.cc,
classpath/native/plugin/Makefile.am,
classpath/native/plugin/.cvsignore,
classpath/resource/Makefile.in,
classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java,
classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,
classpath/gnu/java/awt/peer/gtk/CairoSurface.java,
classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java,
classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java,
classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java,
classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java,
classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java,
classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java,
classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java,
classpath/gnu/java/awt/peer/gtk/GdkGraphics.java,
classpath/gnu/java/awt/peer/gtk/GtkToolkit.java,
classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java,
classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java,
classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java,
classpath/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java,
classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java,
classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java,
classpath/gnu/java/awt/peer/gtk/GtkImage.java,
classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java,
classpath/gnu/java/awt/peer/gtk/GdkGlyphVector.java,
classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java,
classpath/gnu/java/awt/peer/swing/SwingContainerPeer.java,
classpath/gnu/java/awt/peer/swing/SwingComponent.java,
classpath/gnu/java/awt/peer/swing/SwingTextFieldPeer.java,
classpath/gnu/java/awt/peer/swing/SwingMenuBarPeer.java,
classpath/gnu/java/awt/peer/swing/SwingFramePeer.java,
classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java,
classpath/gnu/java/awt/peer/swing/SwingWindowPeer.java,
classpath/gnu/java/awt/print/JavaPrinterJob.java,
classpath/gnu/java/awt/print/PostScriptGraphics2D.java,
classpath/gnu/java/awt/print/SpooledDocument.java,
classpath/gnu/java/awt/print/JavaPrinterGraphics.java,
classpath/gnu/java/awt/BitwiseXORComposite.java,
classpath/gnu/java/awt/font/GNUGlyphVector.java,
classpath/gnu/java/awt/font/opentype/NameDecoder.java,
classpath/gnu/java/awt/java2d/RasterGraphics.java,
classpath/gnu/java/awt/java2d/TexturePaintContext.java,
classpath/gnu/java/awt/java2d/PolyEdge.java,
classpath/gnu/java/awt/java2d/AbstractGraphics2D.java,
classpath/gnu/java/awt/java2d/AlphaCompositeContext.java,
classpath/gnu/java/awt/java2d/ImagePaint.java,
classpath/gnu/java/awt/Buffers.java,
classpath/gnu/classpath/Configuration.java.in,
classpath/gnu/javax/swing/text/html/CombinedAttributes.java,
classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java,
classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java,
classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java,
classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java,
classpath/tools/toolwrapper.c,
classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java,
classpath/tools/gnu/classpath/tools/native2ascii/Messages.java,
classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java,
classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java,
classpath/tools/gnu/classpath/tools/getopt/OptionException.java,
classpath/tools/gnu/classpath/tools/getopt/Messages.java,
classpath/tools/gnu/classpath/tools/getopt/Option.java,
classpath/tools/gnu/classpath/tools/getopt/Parser.java,
classpath/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java,
classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java,
classpath/tools/gnu/classpath/tools/jarsigner/Main.java,
classpath/tools/gnu/classpath/tools/jarsigner/Messages.java,
classpath/tools/gnu/classpath/tools/jarsigner/package.html,
classpath/tools/gnu/classpath/tools/keytool/ListCmd.java,
classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java,
classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java,
classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java,
classpath/tools/gnu/classpath/tools/keytool/Messages.java,
classpath/tools/gnu/classpath/tools/keytool/package.html,
classpath/tools/gnu/classpath/tools/keytool/Command.java,
classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java,
classpath/tools/gnu/classpath/tools/keytool/Main.java,
classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java,
classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java,
classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java,
classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java,
classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java,
classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java,
classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java,
classpath/tools/gnu/classpath/tools/rmi/registry/package.html,
classpath/tools/gnu/classpath/tools/rmi/RMIC.txt,
classpath/tools/gnu/classpath/tools/rmi/RMIC.java,
classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java,
classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java,
classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java,
classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java,
classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java,
classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java,
classpath/tools/gnu/classpath/tools/appletviewer/AppletWarning.java,
classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java,
classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java,
classpath/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java,
classpath/tools/gnu/classpath/tools/appletviewer/Main.java,
classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java,
classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java,
classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java,
classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java,
classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java,
classpath/tools/gnu/classpath/tools/serialver/Messages.java,
classpath/tools/gnu/classpath/tools/serialver/SerialVer.java,
classpath/tools/gnu/classpath/tools/jar/Creator.java,
classpath/tools/gnu/classpath/tools/jar/Entry.java,
classpath/tools/gnu/classpath/tools/jar/Lister.java,
classpath/tools/gnu/classpath/tools/jar/Main.java,
classpath/tools/gnu/classpath/tools/jar/Updater.java,
classpath/tools/gnu/classpath/tools/jar/Messages.java,
classpath/tools/gnu/classpath/tools/jar/Extractor.java,
classpath/tools/gnu/classpath/tools/jar/Action.java,
classpath/tools/gnu/classpath/tools/jar/Indexer.java,
classpath/tools/gnu/classpath/tools/jar/WorkSet.java,
classpath/tools/gnu/classpath/tools/giop/GRMIC.txt,
classpath/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java,
classpath/tools/gnu/classpath/tools/giop/GRMIC.java,
classpath/tools/Makefile.am, classpath/tools/jarsigner.in,
classpath/tools/keytool.in, classpath/tools/appletviewer.in,
classpath/tools/.cvsignore, classpath/configure.ac,
classpath/javax/swing/JTabbedPane.java,
classpath/javax/swing/AbstractButton.java,
classpath/javax/swing/JViewport.java,
classpath/javax/swing/KeyboardManager.java,
classpath/javax/swing/JMenuItem.java,
classpath/javax/swing/JMenuBar.java,
classpath/javax/swing/MenuSelectionManager.java,
classpath/javax/swing/JOptionPane.java,
classpath/javax/swing/JSpinner.java,
classpath/javax/swing/JCheckBoxMenuItem.java,
classpath/javax/swing/JEditorPane.java,
classpath/javax/swing/JFormattedTextField.java,
classpath/javax/swing/JTree.java,
classpath/javax/swing/CellRendererPane.java,
classpath/javax/swing/JScrollPane.java,
classpath/javax/swing/tree/VariableHeightLayoutCache.java,
classpath/javax/swing/tree/TreeNode.java,
classpath/javax/swing/tree/FixedHeightLayoutCache.java,
classpath/javax/swing/tree/DefaultTreeCellEditor.java,
classpath/javax/swing/tree/TreePath.java,
classpath/javax/swing/tree/RowMapper.java,
classpath/javax/swing/tree/DefaultMutableTreeNode.java,
classpath/javax/swing/tree/DefaultTreeModel.java,
classpath/javax/swing/tree/AbstractLayoutCache.java,
classpath/javax/swing/tree/TreeSelectionModel.java,
classpath/javax/swing/tree/DefaultTreeSelectionModel.java,
classpath/javax/swing/tree/DefaultTreeCellRenderer.java,
classpath/javax/swing/tree/ExpandVetoException.java,
classpath/javax/swing/JList.java,
classpath/javax/swing/table/JTableHeader.java,
classpath/javax/swing/table/AbstractTableModel.java,
classpath/javax/swing/table/DefaultTableModel.java,
classpath/javax/swing/table/TableCellEditor.java,
classpath/javax/swing/table/TableCellRenderer.java,
classpath/javax/swing/ProgressMonitor.java,
classpath/javax/swing/JToolBar.java,
classpath/javax/swing/TransferHandler.java,
classpath/javax/swing/DefaultCellEditor.java,
classpath/javax/swing/DefaultButtonModel.java,
classpath/javax/swing/JLayeredPane.java,
classpath/javax/swing/text/DefaultEditorKit.java,
classpath/javax/swing/text/DefaultCaret.java,
classpath/javax/swing/text/FieldView.java,
classpath/javax/swing/text/JTextComponent.java,
classpath/javax/swing/text/TextAction.java,
classpath/javax/swing/text/StyleContext.java,
classpath/javax/swing/text/html/HTMLDocument.java,
classpath/javax/swing/text/html/MinimalHTMLWriter.java,
classpath/javax/swing/text/html/ImageView.java,
classpath/javax/swing/text/html/HTMLEditorKit.java,
classpath/javax/swing/text/AbstractWriter.java,
classpath/javax/swing/text/GapContent.java,
classpath/javax/swing/text/Utilities.java,
classpath/javax/swing/text/PlainView.java,
classpath/javax/swing/UIManager.java,
classpath/javax/swing/JSplitPane.java,
classpath/javax/swing/JComponent.java,
classpath/javax/swing/SwingUtilities.java,
classpath/javax/swing/border/AbstractBorder.java,
classpath/javax/swing/border/CompoundBorder.java,
classpath/javax/swing/border/TitledBorder.java,
classpath/javax/swing/border/MatteBorder.java,
classpath/javax/swing/border/BevelBorder.java,
classpath/javax/swing/RepaintManager.java,
classpath/javax/swing/JTable.java,
classpath/javax/swing/UIDefaults.java,
classpath/javax/swing/DefaultDesktopManager.java,
classpath/javax/swing/JMenu.java,
classpath/javax/swing/JLabel.java,
classpath/javax/swing/JSlider.java,
classpath/javax/swing/plaf/basic/BasicToolBarUI.java,
classpath/javax/swing/plaf/basic/BasicButtonUI.java,
classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java,
classpath/javax/swing/plaf/basic/BasicTextAreaUI.java,
classpath/javax/swing/plaf/basic/BasicToggleButtonUI.java,
classpath/javax/swing/plaf/basic/BasicSpinnerUI.java,
classpath/javax/swing/plaf/basic/BasicSliderUI.java,
classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,
classpath/javax/swing/plaf/basic/BasicComboPopup.java,
classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java,
classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java,
classpath/javax/swing/plaf/basic/BasicProgressBarUI.java,
classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java,
classpath/javax/swing/plaf/basic/BasicPanelUI.java,
classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java,
classpath/javax/swing/plaf/basic/BasicTreeUI.java,
classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java,
classpath/javax/swing/plaf/basic/BasicFileChooserUI.java,
classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java,
classpath/javax/swing/plaf/basic/BasicComboBoxUI.java,
classpath/javax/swing/plaf/basic/BasicListUI.java,
classpath/javax/swing/plaf/basic/BasicIconFactory.java,
classpath/javax/swing/plaf/basic/BasicTextUI.java,
classpath/javax/swing/plaf/basic/BasicLookAndFeel.java,
classpath/javax/swing/plaf/basic/BasicDirectoryModel.java,
classpath/javax/swing/plaf/basic/BasicRootPaneUI.java,
classpath/javax/swing/plaf/basic/BasicTableUI.java,
classpath/javax/swing/plaf/basic/SharedUIDefaults.java,
classpath/javax/swing/plaf/multi/MultiComboBoxUI.java,
classpath/javax/swing/plaf/multi/MultiListUI.java,
classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java,
classpath/javax/swing/plaf/multi/MultiFileChooserUI.java,
classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java,
classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java,
classpath/javax/swing/plaf/multi/MultiLookAndFeel.java,
classpath/javax/swing/plaf/metal/MetalSliderUI.java,
classpath/javax/swing/plaf/metal/MetalIconFactory.java,
classpath/javax/swing/plaf/metal/MetalComboBoxIcon.java,
classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java,
classpath/javax/swing/plaf/metal/MetalLookAndFeel.java,
classpath/javax/swing/plaf/metal/MetalCheckBoxUI.java,
classpath/javax/swing/plaf/metal/MetalSeparatorUI.java,
classpath/javax/swing/plaf/metal/MetalBorders.java,
classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java,
classpath/javax/swing/plaf/metal/MetalScrollBarUI.java,
classpath/javax/swing/plaf/metal/MetalRootPaneUI.java,
classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java,
classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java,
classpath/javax/swing/plaf/metal/MetalToolTipUI.java,
classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java,
classpath/javax/swing/plaf/metal/MetalFileChooserUI.java,
classpath/javax/swing/plaf/metal/MetalUtils.java,
classpath/javax/swing/plaf/metal/MetalComboBoxButton.java,
classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java,
classpath/javax/swing/plaf/metal/MetalButtonUI.java,
classpath/javax/swing/JPopupMenu.java,
classpath/javax/swing/JProgressBar.java,
classpath/javax/swing/WindowConstants.java,
classpath/javax/swing/JFrame.java,
classpath/javax/swing/JFileChooser.java,
classpath/javax/swing/JComboBox.java,
classpath/javax/swing/event/EventListenerList.java,
classpath/javax/swing/ListSelectionModel.java,
classpath/javax/swing/JScrollBar.java,
classpath/java/text/SimpleDateFormat.java,
classpath/java/text/NumberFormat.java,
classpath/java/text/class-dependencies.conf,
classpath/java/awt/image/ColorModel.java,
classpath/java/awt/image/BufferedImage.java,
classpath/java/awt/Window.java,
classpath/java/awt/ContainerOrderFocusTraversalPolicy.java,
classpath/java/awt/LightweightDispatcher.java,
classpath/java/awt/EventDispatchThread.java,
classpath/java/awt/BasicStroke.java,
classpath/java/awt/ColorPaintContext.java,
classpath/java/awt/Container.java,
classpath/java/awt/TexturePaint.java,
classpath/java/awt/Component.java, classpath/java/awt/Font.java,
classpath/java/awt/GraphicsConfiguration.java,
classpath/java/awt/DefaultKeyboardFocusManager.java,
classpath/java/awt/print/PrinterJob.java,
classpath/java/awt/im/InputContext.java,
classpath/java/awt/dnd/DragGestureRecognizer.java,
classpath/java/awt/Toolkit.java,
classpath/java/awt/font/GraphicAttribute.java,
classpath/java/awt/font/ImageGraphicAttribute.java,
classpath/java/awt/font/GlyphVector.java,
classpath/java/awt/font/GlyphMetrics.java,
classpath/java/awt/font/ShapeGraphicAttribute.java,
classpath/java/awt/Graphics2D.java,
classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h,
classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h,
classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h,
classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h,
classpath/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h,
classpath/include/config.h.in,
classpath/include/gnu_java_awt_peer_gtk_GdkTextLayout.h,
classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h,
classpath/include/gnu_java_awt_peer_gtk_GdkFontPeer.h,
classpath/include/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h,
classpath/include/gnu_java_awt_peer_gtk_GtkVolatileImage.h,
classpath/include/gnu_java_awt_peer_gtk_GtkImage.h,
classpath/include/gnu_java_awt_peer_gtk_CairoSurface.h,
classpath/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h:
Merge from GNU Classpath HEAD.
From-SVN: r114510
Diffstat (limited to 'libjava/classpath/gnu/javax')
5 files changed, 1024 insertions, 24 deletions
diff --git a/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java b/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java new file mode 100644 index 0000000..5f73095 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java @@ -0,0 +1,192 @@ +/* CharacterAttributeTranslator.java -- + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.javax.swing.text.html; + +import java.awt.Color; +import java.util.HashMap; +import java.util.StringTokenizer; + +import javax.swing.text.MutableAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.html.HTML.Attribute; +import javax.swing.text.html.HTML.Tag; + +/** + * This is a small utility class to translate HTML character attributes to + * Swing StyleConstants + */ +public class CharacterAttributeTranslator +{ + /** + * Maps color name to its hex encoding. + */ + private static final HashMap colorMap = new HashMap(); + static + { + colorMap.put("aqua" , "#00FFFF"); + colorMap.put("blue" , "#0000FF"); + colorMap.put("black", "#000000"); + colorMap.put("fuchsia" , "#FF00FF"); + colorMap.put("gray" , "#808080"); + colorMap.put("green" , "#008000"); + colorMap.put("lime" , "#00FF00"); + colorMap.put("maroon" , "#800000"); + colorMap.put("navy" , "#000080"); + colorMap.put("olive" , "#808000"); + colorMap.put("purple" , "#800080"); + colorMap.put("red" , "#FF0000"); + colorMap.put("silver" , "#C0C0C0"); + colorMap.put("teal" , "#008080"); + colorMap.put("white" , "#FFFFFF"); + colorMap.put("yellow" , "#FFFF00"); + }; + + /** + * Convert the color string represenation into java.awt.Color. The valid + * values are like "aqua" , "#00FFFF" or "rgb(1,6,44)". + * + * @param colorName the color to convert. + * @return the matching java.awt.color + */ + private static Color getColor(String colorName) + { + colorName = colorName.toLowerCase(); + try + { + if (colorName.startsWith("rgb")) + { + // rgb(red, green, blue) notation. + StringTokenizer st = new StringTokenizer(colorName, " ,()"); + String representation = st.nextToken(); + + // Return null if the representation is not supported. + if (! representation.equals("rgb")) + return null; + int red = Integer.parseInt(st.nextToken()); + int green = Integer.parseInt(st.nextToken()); + int blue = Integer.parseInt(st.nextToken()); + + return new Color(red, green, blue); + } + else + { + String s2 = (String) colorMap.get(colorName); + if (s2 == null) + s2 = colorName; + return Color.decode(s2); + } + } + catch (Exception nex) + { + // Can be either number format exception or illegal argument + // exception. + return null; + } + } + + /** + * Translate the HTML character attribute to the Swing style constant. + * + * @param charAttr the character attributes of the html tag + * @param t the html tag itself + * @param a the attribute set where the translated attributes will be stored + * + * @return true if some attributes were translated, false otherwise. + */ + public static boolean translateTag(MutableAttributeSet charAttr, + Tag t, MutableAttributeSet a) + { + if(t == Tag.FONT) + { + Object color = a.getAttribute(Attribute.COLOR); + if(color != null) + { + Color c = getColor(color.toString()); + if( c == null ) + return false; + charAttr.addAttribute(StyleConstants.Foreground, c); + return true; + } + + if(a.getAttribute(Attribute.SIZE) != null) + { + // FIXME + // charAttr.addAttribute(StyleConstants.FontSize, + // new java.lang.Integer(72)); + return true; + } + } + + if( t == Tag.B ) + { + charAttr.addAttribute(StyleConstants.Bold, Boolean.TRUE); + return true; + } + + if( t == Tag.I ) + { + charAttr.addAttribute(StyleConstants.Italic, Boolean.TRUE); + return true; + } + + if( t == Tag.U ) + { + charAttr.addAttribute(StyleConstants.Underline, Boolean.TRUE); + return true; + } + + if( t == Tag.STRIKE ) + { + charAttr.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE); + return true; + } + + if( t == Tag.SUP ) + { + charAttr.addAttribute(StyleConstants.Superscript, Boolean.TRUE); + return true; + } + + if( t == Tag.SUB ) + { + charAttr.addAttribute(StyleConstants.Subscript, Boolean.TRUE); + return true; + } + return false; + } +} diff --git a/libjava/classpath/gnu/javax/swing/text/html/CombinedAttributes.java b/libjava/classpath/gnu/javax/swing/text/html/CombinedAttributes.java new file mode 100644 index 0000000..b1e3de6 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/text/html/CombinedAttributes.java @@ -0,0 +1,213 @@ +/* CombinedAttributes.java -- A two combined sets of attributes + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.swing.text.html; + +import java.io.Serializable; +import java.util.Enumeration; + +import javax.swing.text.AttributeSet; +import javax.swing.text.SimpleAttributeSet; + +/** + * Contains the two combined attribute sets what are searched subsequently. + * This is used to combine style sheet attributes with the HTML view attributes. + * The parent cannot be used as the view may have its own attribute hierarchy. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ +public class CombinedAttributes implements AttributeSet, Serializable +{ + /** + * Returns the elements from both enumerations. + */ + class CombinedEnumeration implements Enumeration + { + /** + * Create a combined enumeration that enumerates over two enumerations. + * + * @param first the first enumeration to enumerate + * @param second the second enumeration to enumerate + */ + CombinedEnumeration(Enumeration first, Enumeration second) + { + a = first; + b = second; + } + + /** + * The first enumeration (elements returned first) + */ + final Enumeration a; + + /** + * The second enumeration (elements returned later) + */ + final Enumeration b; + + /** @inheritDoc */ + public boolean hasMoreElements() + { + return a.hasMoreElements() || b.hasMoreElements(); + } + + /** @inheritDoc */ + public Object nextElement() + { + return a.hasMoreElements() ? a.nextElement():b.nextElement(); + } + } + + + /** + * The first attribute set. + */ + final AttributeSet a; + + /** + * The second attribute set. + */ + final AttributeSet b; + + /** + * Create the CombinedAttributes what search in the two sets. If any of the + * two passed sets is null, another set is returned. Otherwise, the combined + * attribute set is returned. + * + * @param primary the first set (searched first) + * @param secondary the second set (searched later). + */ + public static AttributeSet combine(AttributeSet primary, + AttributeSet secondary) + { + if (primary == null) + return secondary; + else if (secondary == null) + return primary; + else + return new CombinedAttributes(primary, secondary); + } + + /** + * Create the CombinedAttributes what search in the two sets. + * + * @param primary the first set (searched first) + * @param secondary the second set (searched later). + */ + private CombinedAttributes(AttributeSet primary, AttributeSet secondary) + { + a = primary; + b = secondary; + } + + /** @inheritDoc */ + public boolean containsAttribute(Object name, Object value) + { + return a.containsAttribute(name, value) || b.containsAttribute(name, value); + } + + /** @inheritDoc */ + public boolean containsAttributes(AttributeSet attributes) + { + Enumeration names = attributes.getAttributeNames(); + Object name; + while (names.hasMoreElements()) + { + name = names.nextElement(); + if (!containsAttribute(name, attributes.getAttribute(name))) + return false; + } + return true; + } + + /** @inheritDoc */ + public AttributeSet copyAttributes() + { + SimpleAttributeSet copy = new SimpleAttributeSet(); + copy.addAttributes(a); + copy.addAttributes(b); + return copy; + } + + /** @inheritDoc */ + public Object getAttribute(Object key) + { + Object value = a.getAttribute(key); + if (value == null) + value = b.getAttribute(key); + + return value; + } + + /** @inheritDoc */ + public int getAttributeCount() + { + return a.getAttributeCount()+b.getAttributeCount(); + } + + /** @inheritDoc */ + public Enumeration getAttributeNames() + { + return new CombinedEnumeration(a.getAttributeNames(), b.getAttributeNames()); + } + + /** + * There is no one. + * + * @return null, always. + */ + public AttributeSet getResolveParent() + { + return null; + } + + /** @inheritDoc */ + public boolean isDefined(Object attrName) + { + return a.isDefined(attrName) || b.isDefined(attrName); + } + + /** @inheritDoc */ + public boolean isEqual(AttributeSet attr) + { + if (attr.getAttributeCount() == getAttributeCount()) + return containsAttributes(attr); + else + return false; + } +} diff --git a/libjava/classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java b/libjava/classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java new file mode 100644 index 0000000..862e690 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java @@ -0,0 +1,282 @@ +package gnu.javax.swing.text.html; + + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.io.Serializable; + +import javax.swing.Icon; +import javax.swing.plaf.metal.MetalLookAndFeel; + +/** + * Creates icons for ImageView. The icons reflect the basic ideas of the Sun's + * icons as they would be described in the text (sheet of paper with image and + * broken sheet of paper with image). They are not pixel to pixel identical and + * contain elements from the metal icon factory. + * + * @author Audrius Meskauskas (audriusa@bioinformatics.org) + */ +public class ImageViewIconFactory +{ + private static Icon noImageIcon; + + private static Icon loadingImageIcon; + + /** + * This icon reflects the general concept (broken sheet of paper with + * image), but is currently not pixel to pixel identical with the Sun's + * implementation. + */ + public static class NoImageIcon implements Icon, Serializable + { + /** + * Creates a new icon. + */ + public NoImageIcon() + { + // Nothing to do here. + } + + /** + * Returns the width of the icon, in pixels. + * + * @return The width of the icon. + */ + public int getIconWidth() + { + return 38; + } + + /** + * Returns the height of the icon, in pixels. + * + * @return The height of the icon. + */ + public int getIconHeight() + { + return 38; + } + + /** + * Paints the icon using colors from the {@link MetalLookAndFeel}. + * + * @param c + * the component (ignored). + * @param g + * the graphics device. + * @param x + * the x-coordinate for the top-left of the icon. + * @param y + * the y-coordinate for the top-left of the icon. + */ + public void paintIcon(Component c, Graphics g, int x, int y) + { + // frame + Color savedColor = g.getColor(); + + g.setColor(MetalLookAndFeel.getBlack()); + + g.drawLine(x, y, x + 19, y); + + g.drawLine(x, y + 1, x, y + 5); + g.drawLine(x, y + 13, x, y + 25); + + g.drawLine(x, y + 25, x + 22, y + 25); + + g.drawLine(x + 22, y + 25, x + 22, y + 21); + g.drawLine(x + 22, y + 13, x + 22, y + 6); + + g.drawLine(x + 22, y + 6, x + 19, y); + + g.drawLine(x + 17, y + 2, x + 21, y + 6); + + g.drawLine(x + 18, y + 1, x + 19, y + 1); + + g.setColor(MetalLookAndFeel.getControlShadow()); + + g.drawLine(x + 1, y + 1, x + 17, y + 1); + + g.drawLine(x + 1, y + 1, x + 1, y + 5); + g.drawLine(x + 1, y + 13, x + 1, y + 24); + + g.drawLine(x + 1, y + 24, x + 21, y + 24); + + g.drawLine(x + 21, y + 24, x + 21, y + 21); + g.drawLine(x + 21, y + 13, x + 21, y + 7); + + g.drawLine(x + 18, y + 2, x + 20, y + 4); + + // Breaking line + + // Shadow + g.drawLine(x + 1, y + 6, x + 20, y + 13); + g.drawLine(x + 1, y + 13, x + 20, y + 20); + + // Edge + g.setColor(MetalLookAndFeel.getBlack()); + g.drawLine(x, y + 6, x + 21, y + 14); + g.drawLine(x, y + 12, x + 21, y + 20); + + // Picture + + y += 1; + x += 3; + + g.setColor(MetalLookAndFeel.getBlack()); + + // roof + g.drawLine(x + 4, y + 5, x + 8, y + 1); + g.drawLine(x + 8, y + 1, x + 15, y + 8); + + // chimney + g.drawLine(x + 11, y + 2, x + 11, y + 4); + g.drawLine(x + 12, y + 2, x + 12, y + 5); + + g.setColor(MetalLookAndFeel.getControlDarkShadow()); + + // roof paint + int xx = x + 8; + for (int i = 0; i < 4; i++) + g.drawLine(xx - i, y + 2 + i, xx + i, y + 2 + i); + g.fillRect(x + 4, y + 6, 9, 2); + + // base of house + g.drawLine(x + 3, y + 14, x + 3, y + 18); + g.drawLine(x + 3, y + 18, x + 13, y + 18); + + g.setColor(savedColor); + } + } + + /** + * This icon reflects the general concept (sheet of paper with image), but is + * currently not pixel to pixel identical with the Sun's implementation. + */ + public static class LoadingImageIcon implements Icon, Serializable + { + + /** + * Creates a new icon. + */ + public LoadingImageIcon() + { + // Nothing to do here. + } + + /** + * Returns the width of the icon, in pixels. + * + * @return The width of the icon. + */ + public int getIconWidth() + { + return 38; + } + + /** + * Returns the height of the icon, in pixels. + * + * @return The height of the icon. + */ + public int getIconHeight() + { + return 38; + } + + /** + * Paints the icon using colors from the {@link MetalLookAndFeel}. + * + * @param c + * the component (ignored). + * @param g + * the graphics device. + * @param x + * the x-coordinate for the top-left of the icon. + * @param y + * the y-coordinate for the top-left of the icon. + */ + public void paintIcon(Component c, Graphics g, int x, int y) + { + // frame + Color savedColor = g.getColor(); + + g.setColor(Color.black); + g.drawLine(x, y, x + 19, y); + g.drawLine(x, y + 1, x, y + 25); + g.drawLine(x, y + 25, x + 22, y + 25); + g.drawLine(x + 22, y + 25, x + 22, y + 6); + g.drawLine(x + 22, y + 6, x + 19, y); + + g.drawLine(x + 17, y + 2, x + 21, y + 6); + g.drawLine(x + 18, y + 1, x + 19, y + 1); + + g.setColor(new Color(204, 204, 255)); + + g.drawLine(x + 1, y + 1, x + 17, y + 1); + g.drawLine(x + 1, y + 1, x + 1, y + 24); + g.drawLine(x + 1, y + 24, x + 21, y + 24); + g.drawLine(x + 21, y + 24, x + 21, y + 7); + g.drawLine(x + 18, y + 2, x + 20, y + 4); + + // Picture (house) + + y += 3; + x += 3; + + g.setColor(MetalLookAndFeel.getBlack()); + + // roof + g.drawLine(x + 1, y + 8, x + 8, y + 1); + g.drawLine(x + 8, y + 1, x + 15, y + 8); + + // base of house + g.drawLine(x + 3, y + 6, x + 3, y + 15); + g.drawLine(x + 3, y + 15, x + 13, y + 15); + g.drawLine(x + 13, y + 6, x + 13, y + 15); + + // door frame + g.drawLine(x + 6, y + 9, x + 6, y + 15); + g.drawLine(x + 6, y + 9, x + 10, y + 9); + g.drawLine(x + 10, y + 9, x + 10, y + 15); + + // chimney + g.drawLine(x + 11, y + 2, x + 11, y + 4); + g.drawLine(x + 12, y + 2, x + 12, y + 5); + + g.setColor(MetalLookAndFeel.getControlDarkShadow()); + + // roof paint + int xx = x + 8; + for (int i = 0; i < 4; i++) + g.drawLine(xx - i, y + 2 + i, xx + i, y + 2 + i); + g.fillRect(x + 4, y + 6, 9, 2); + + // door knob + g.drawLine(x + 9, y + 12, x + 9, y + 12); + + // house paint + g.setColor(MetalLookAndFeel.getPrimaryControl()); + g.drawLine(x + 4, y + 8, x + 12, y + 8); + g.fillRect(x + 4, y + 9, 2, 6); + g.fillRect(x + 11, y + 9, 2, 6); + + g.setColor(savedColor); + } + } + + public static Icon getNoImageIcon() + { + if (noImageIcon == null) + noImageIcon = new NoImageIcon(); + return noImageIcon; + } + + public static Icon getLoadingImageIcon() + { + if (loadingImageIcon == null) + loadingImageIcon = new LoadingImageIcon(); + return loadingImageIcon; + } + +} diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java b/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java new file mode 100644 index 0000000..45e1dce --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java @@ -0,0 +1,263 @@ +/* SmallHtmlAttributeSet.java -- Small fixed HTML attribute set + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.swing.text.html.parser; + +import java.io.Serializable; +import java.util.Enumeration; +import java.util.NoSuchElementException; + +import javax.swing.text.AttributeSet; +import javax.swing.text.html.HTML.Attribute; +import javax.swing.text.html.HTML.Tag; + +/** + * Small fixed HTML attribute set. The most of the HTML elements contain only + * several attributes. With four attributes, the number of operations in more + * complex algorithms is not larger than using the naive algorithm. + * + * Same as HtmlAttributeSet, this set allows both strings and non-string as + * keys. The strings are case insensitive, the non strings are compared with + * .equals. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ +public class SmallHtmlAttributeSet + implements AttributeSet, Cloneable, Serializable +{ + private static final long serialVersionUID = 1; + + /** + * The keys, stored in this attribute set. + */ + final Object[] keys; + + /** + * The values, stored in this attribute set. + */ + final Object[] values; + + /** + * The parent, used for resolving the values, not found in this set. + */ + final AttributeSet parent; + + /** + * Create a new small fixed attribute set that contains the unchangeable copy + * of the passed attribute set and inherits its parent. + * + * @param copyFrom the attribute set, containing the attribute values to copy. + */ + public SmallHtmlAttributeSet(AttributeSet copyFrom) + { + int n = copyFrom.getAttributeCount(); + + keys = new Object[n]; + values = new Object[n]; + parent = copyFrom.getResolveParent(); + + Enumeration en = copyFrom.getAttributeNames(); + Object key; + Object value; + + for (int i = 0; i < n; i++) + { + key = en.nextElement(); + keys[i] = key; + value = copyFrom.getAttribute(key); + if (value instanceof String) + value = ((String) value).toLowerCase(); + values[i] = value; + } + } + + public boolean containsAttribute(Object name, Object value) + { + Object contains = getAttribute(name); + if (value == null) + return value == contains; + else + return value.equals(contains); + } + + public boolean containsAttributes(AttributeSet attributes) + { + if (attributes == this) + return true; + Object v; + for (int i = 0; i < keys.length; i++) + { + v = attributes.getAttribute(keys[i]); + if (v != values[i]) + { + if (values[i] == null) + return false; + else if (! values[i].equals(v)) + return false; + } + } + return true; + } + + /** + * THIS can be safely returned as the set is not mutable. + */ + public AttributeSet copyAttributes() + { + return this; + } + + /** + * Get the attribute value, matching this key. If not found in this set, the + * call is delegated to parent. + * + * @return the value, matching key (or null if none). + */ + public Object getAttribute(Object key) + { + // Null and HTML attributes or tags can be searched by direct comparison. + if (key == null || key instanceof Attribute || key instanceof Tag) + { + for (int i = 0; i < keys.length; i++) + { + if (keys[i] == key) + return values[i]; + } + } + + // Strings are case insensitive. Only string can be match the string. + else if (key instanceof String) + { + String ks = (String) key; + for (int i = 0; i < keys.length; i++) + { + if (keys[i] instanceof String) + if (ks.equalsIgnoreCase((String) keys[i])) + return values[i]; + } + } + + // Otherwise, defaults to .equals + else + { + for (int i = 0; i < keys.length; i++) + { + if (key.equals(keys[i])) + return values[i]; + } + } + + if (parent != null) + return parent.getAttribute(key); + else + return null; + } + + /** + * Get the number of the stored attributes. + */ + public int getAttributeCount() + { + return keys.length; + } + + /** + * Get enumeration, containing the attribute names. No guard agains the + * concurent modification is required as the set is not mutable. + */ + public Enumeration getAttributeNames() + { + return new Enumeration() + { + int p = 0; + + public boolean hasMoreElements() + { + return p < keys.length; + } + + public Object nextElement() + { + if (p < keys.length) + return keys[p++]; + else + throw new NoSuchElementException(); + } + }; + } + + /** + * Get the parent that this set uses to resolve the not found attributes. + */ + public AttributeSet getResolveParent() + { + return parent; + } + + /** + * Check if the given attribute is defined in this set (not in the parent). + */ + public boolean isDefined(Object attrName) + { + if (attrName instanceof String) + attrName = ((String) attrName).toLowerCase(); + + for (int i = 0; i < keys.length; i++) + { + if (attrName.equals(keys[i])) + return true; + } + return false; + } + + /** + * Check this set and another set for equality by content. + */ + public boolean isEqual(AttributeSet attr) + { + return keys.length == attr.getAttributeCount() && containsAttributes(attr); + } + + /** + * It is safe to return THIS on cloning, if one happens. + */ + protected Object clone() + { + return this; + } +} diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java b/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java index a4e6f73..b89eec6 100644 --- a/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java +++ b/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java @@ -46,6 +46,7 @@ import javax.swing.text.html.HTML; /** * A set, adapted to store HTML attributes. + * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ public class htmlAttributeSet @@ -53,23 +54,34 @@ public class htmlAttributeSet { public static final htmlAttributeSet EMPTY_HTML_ATTRIBUTE_SET = new htmlAttributeSet(); + AttributeSet parent; /** - * Looks in this set and, if not found, later looks in the parent set. - * Calls toString(), allowing to pass as HTML.Attribute, as String - * to this method. - * @param key A key to search for a value. + * Looks in this set and, if not found, later looks in the parent set. Calls + * toString(), allowing to pass as HTML.Attribute, as String to this method. + * + * @param _key A key to search for a value. * @return The value, if one is defined. */ public Object getAttribute(Object _key) { + Object v = super.getAttribute(_key); + if (v != null || _key == null) + return v; + Object key = _key.toString().toLowerCase(); - Object v = super.getAttribute(key); + v = super.getAttribute(key); + if (v != null) + return v; + + key = HTML.getAttributeKey((String) key); + v = super.getAttribute(key); if (v != null) return v; - else if (parent != null) + + if (parent != null) return parent.getAttribute(key); else return null; @@ -85,26 +97,29 @@ public class htmlAttributeSet final Enumeration enumeration = super.getAttributeNames(); return new Enumeration() + { + public boolean hasMoreElements() + { + return enumeration.hasMoreElements(); + } + + public Object nextElement() { - public boolean hasMoreElements() - { - return enumeration.hasMoreElements(); - } - - public Object nextElement() - { - Object key = enumeration.nextElement(); - HTML.Attribute hKey = HTML.getAttributeKey((String) key); - if (hKey != null) - return hKey; - else - return key; - } - }; + Object key = enumeration.nextElement(); + if (key instanceof String) + { + HTML.Attribute hKey = HTML.getAttributeKey((String) key); + if (hKey != null) + return hKey; + } + return key; + } + }; } /** * Set the parent set, containing the default values. + * * @param a_parent */ public void setResolveParent(AttributeSet a_parent) @@ -114,7 +129,8 @@ public class htmlAttributeSet /** * Get the parent set, containing the default values. - * @return + * + * @return the parent, used to resolve the attributes. */ public AttributeSet getResolveParent() { @@ -123,11 +139,45 @@ public class htmlAttributeSet /** * Add the attribute to this attribute set. - * @param key Attribute key (will be case insensitive) + * + * @param key Attribute key (if string, it will be case insensitive) * @param value Attribute value */ public void addAttribute(Object key, Object value) { - super.addAttribute(key.toString().toLowerCase(), value); + if (key instanceof String) + super.addAttribute(((String) key).toLowerCase(), value); + else + super.addAttribute(key, value); } + + /** + * Copy attributes. The returned copy does not longer contains the extended + * features, needed to participate in the HTML parsing. The returned set may + * not be mutable. + */ + public AttributeSet copyAttributes() + { + if (getAttributeCount() <= 8) + // For the small size, typical in HTML tags, the direct iteration is + // faster than more complex algorithms. + return new SmallHtmlAttributeSet(this); + else + return (AttributeSet) clone(); + } + + /** + * Returns a clone of the attribute set. + * + * @return A clone of the attribute set. + */ + public Object clone() + { + htmlAttributeSet set = new htmlAttributeSet(); + set.addAttributes(this); + AttributeSet parent = getResolveParent(); + if (parent != null) + set.setResolveParent(parent); + return set; + } } |