summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax')
-rw-r--r--libjava/classpath/javax/accessibility/AccessibleRelationSet.java4
-rw-r--r--libjava/classpath/javax/accessibility/AccessibleStateSet.java4
-rw-r--r--libjava/classpath/javax/activation/ActivationDataFlavor.java161
-rw-r--r--libjava/classpath/javax/activation/CommandInfo.java117
-rw-r--r--libjava/classpath/javax/activation/CommandMap.java212
-rw-r--r--libjava/classpath/javax/activation/CommandObject.java62
-rw-r--r--libjava/classpath/javax/activation/DataContentHandler.java85
-rw-r--r--libjava/classpath/javax/activation/DataContentHandlerFactory.java56
-rw-r--r--libjava/classpath/javax/activation/DataHandler.java482
-rw-r--r--libjava/classpath/javax/activation/DataHandlerDataSource.java84
-rw-r--r--libjava/classpath/javax/activation/DataSource.java76
-rw-r--r--libjava/classpath/javax/activation/DataSourceDataContentHandler.java126
-rw-r--r--libjava/classpath/javax/activation/FileDataSource.java123
-rw-r--r--libjava/classpath/javax/activation/FileTypeMap.java108
-rw-r--r--libjava/classpath/javax/activation/MailcapCommandMap.java804
-rw-r--r--libjava/classpath/javax/activation/MimeType.java293
-rw-r--r--libjava/classpath/javax/activation/MimeTypeParameterList.java336
-rw-r--r--libjava/classpath/javax/activation/MimeTypeParseException.java84
-rw-r--r--libjava/classpath/javax/activation/MimetypesFileTypeMap.java440
-rw-r--r--libjava/classpath/javax/activation/ObjectDataContentHandler.java128
-rw-r--r--libjava/classpath/javax/activation/URLDataSource.java138
-rw-r--r--libjava/classpath/javax/activation/UnsupportedDataTypeException.java70
-rw-r--r--libjava/classpath/javax/activation/package.html44
-rw-r--r--libjava/classpath/javax/imageio/ImageIO.java1
-rw-r--r--libjava/classpath/javax/imageio/plugins/jpeg/JPEGHuffmanTable.java4
-rw-r--r--libjava/classpath/javax/imageio/plugins/jpeg/JPEGQTable.java4
-rw-r--r--libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java4
-rw-r--r--libjava/classpath/javax/management/DefaultLoaderRepository.java4
-rw-r--r--libjava/classpath/javax/management/JMX.java2
-rw-r--r--libjava/classpath/javax/management/MBeanAttributeInfo.java4
-rw-r--r--libjava/classpath/javax/management/MBeanConstructorInfo.java4
-rw-r--r--libjava/classpath/javax/management/MBeanOperationInfo.java4
-rw-r--r--libjava/classpath/javax/management/MBeanPermission.java32
-rw-r--r--libjava/classpath/javax/management/MBeanServerDelegate.java12
-rw-r--r--libjava/classpath/javax/management/MBeanServerFactory.java7
-rw-r--r--libjava/classpath/javax/management/MBeanServerInvocationHandler.java4
-rw-r--r--libjava/classpath/javax/management/MBeanServerPermission.java18
-rw-r--r--libjava/classpath/javax/management/ObjectName.java33
-rw-r--r--libjava/classpath/javax/management/StandardMBean.java24
-rw-r--r--libjava/classpath/javax/management/openmbean/ArrayType.java23
-rw-r--r--libjava/classpath/javax/management/openmbean/CompositeDataSupport.java11
-rw-r--r--libjava/classpath/javax/management/openmbean/CompositeType.java6
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java23
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java8
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java23
-rw-r--r--libjava/classpath/javax/management/openmbean/SimpleType.java2
-rw-r--r--libjava/classpath/javax/management/openmbean/TabularDataSupport.java31
-rw-r--r--libjava/classpath/javax/management/openmbean/TabularType.java5
-rw-r--r--libjava/classpath/javax/management/remote/rmi/RMIConnection.java10
-rw-r--r--libjava/classpath/javax/naming/BinaryRefAddr.java4
-rw-r--r--libjava/classpath/javax/naming/CompositeName.java6
-rw-r--r--libjava/classpath/javax/naming/CompoundName.java6
-rw-r--r--libjava/classpath/javax/naming/NamingException.java4
-rw-r--r--libjava/classpath/javax/naming/spi/NamingManager.java4
-rw-r--r--libjava/classpath/javax/security/auth/x500/X500Principal.java10
-rw-r--r--libjava/classpath/javax/security/sasl/SaslException.java4
-rw-r--r--libjava/classpath/javax/sound/sampled/AudioFormat.java4
-rw-r--r--libjava/classpath/javax/sound/sampled/CompoundControl.java4
-rw-r--r--libjava/classpath/javax/sound/sampled/DataLine.java4
-rw-r--r--libjava/classpath/javax/swing/AbstractButton.java4
-rw-r--r--libjava/classpath/javax/swing/JButton.java4
-rw-r--r--libjava/classpath/javax/swing/JComboBox.java4
-rw-r--r--libjava/classpath/javax/swing/JComponent.java4
-rw-r--r--libjava/classpath/javax/swing/JDesktopPane.java4
-rw-r--r--libjava/classpath/javax/swing/JFileChooser.java4
-rw-r--r--libjava/classpath/javax/swing/JFrame.java4
-rw-r--r--libjava/classpath/javax/swing/JLabel.java4
-rw-r--r--libjava/classpath/javax/swing/JList.java4
-rw-r--r--libjava/classpath/javax/swing/JMenuBar.java4
-rw-r--r--libjava/classpath/javax/swing/JPopupMenu.java4
-rw-r--r--libjava/classpath/javax/swing/JProgressBar.java4
-rw-r--r--libjava/classpath/javax/swing/JScrollBar.java4
-rw-r--r--libjava/classpath/javax/swing/JSlider.java4
-rw-r--r--libjava/classpath/javax/swing/JSplitPane.java4
-rw-r--r--libjava/classpath/javax/swing/JTabbedPane.java4
-rw-r--r--libjava/classpath/javax/swing/JToolBar.java4
-rw-r--r--libjava/classpath/javax/swing/JToolTip.java4
-rw-r--r--libjava/classpath/javax/swing/UIManager.java4
-rw-r--r--libjava/classpath/javax/swing/event/EventListenerList.java4
-rw-r--r--libjava/classpath/javax/swing/table/AbstractTableModel.java4
-rw-r--r--libjava/classpath/javax/swing/text/AbstractDocument.java4
-rw-r--r--libjava/classpath/javax/swing/text/DefaultEditorKit.java4
-rw-r--r--libjava/classpath/javax/swing/text/DefaultStyledDocument.java6
-rw-r--r--libjava/classpath/javax/swing/text/JTextComponent.java4
-rw-r--r--libjava/classpath/javax/swing/text/MaskFormatter.java6
-rw-r--r--libjava/classpath/javax/swing/text/TabSet.java4
-rw-r--r--libjava/classpath/javax/swing/text/html/CSSParser.java6
-rw-r--r--libjava/classpath/javax/swing/text/html/HTMLWriter.java6
-rw-r--r--libjava/classpath/javax/swing/text/html/StyleSheet.java39
-rw-r--r--libjava/classpath/javax/swing/text/html/ViewAttributeSet.java6
-rw-r--r--libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java2
-rw-r--r--libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java4
-rw-r--r--libjava/classpath/javax/tools/FileObject.java6
-rw-r--r--libjava/classpath/javax/xml/datatype/DatatypeFactory.java8
-rw-r--r--libjava/classpath/javax/xml/namespace/NamespaceContext.java1
-rw-r--r--libjava/classpath/javax/xml/namespace/QName.java4
-rw-r--r--libjava/classpath/javax/xml/parsers/DocumentBuilderFactory.java2
-rw-r--r--libjava/classpath/javax/xml/parsers/SAXParserFactory.java2
-rw-r--r--libjava/classpath/javax/xml/stream/XMLEventFactory.java7
-rw-r--r--libjava/classpath/javax/xml/stream/XMLEventReader.java1
-rw-r--r--libjava/classpath/javax/xml/stream/XMLInputFactory.java2
-rw-r--r--libjava/classpath/javax/xml/stream/XMLOutputFactory.java2
-rw-r--r--libjava/classpath/javax/xml/stream/events/DTD.java2
-rw-r--r--libjava/classpath/javax/xml/stream/events/EndElement.java1
-rw-r--r--libjava/classpath/javax/xml/stream/events/StartElement.java2
-rw-r--r--libjava/classpath/javax/xml/transform/TransformerException.java5
-rw-r--r--libjava/classpath/javax/xml/transform/TransformerFactory.java4
-rw-r--r--libjava/classpath/javax/xml/validation/SchemaFactory.java4
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathFactory.java2
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathFunction.java1
110 files changed, 4375 insertions, 246 deletions
diff --git a/libjava/classpath/javax/accessibility/AccessibleRelationSet.java b/libjava/classpath/javax/accessibility/AccessibleRelationSet.java
index 49161d77e9d..0770fdbeb78 100644
--- a/libjava/classpath/javax/accessibility/AccessibleRelationSet.java
+++ b/libjava/classpath/javax/accessibility/AccessibleRelationSet.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.accessibility;
+import gnu.java.lang.CPStringBuilder;
+
import java.util.Locale;
import java.util.Vector;
@@ -216,7 +218,7 @@ public class AccessibleRelationSet
if (i == 0)
return "";
// Pre-allocate an average of 10 chars per state.
- StringBuffer b = new StringBuffer(i * 10);
+ CPStringBuilder b = new CPStringBuilder(i * 10);
while (--i >= 0)
b.append(relations.get(i)).append(',');
return b.substring(0, b.length() - 1);
diff --git a/libjava/classpath/javax/accessibility/AccessibleStateSet.java b/libjava/classpath/javax/accessibility/AccessibleStateSet.java
index 783f5412742..83bf3d49167 100644
--- a/libjava/classpath/javax/accessibility/AccessibleStateSet.java
+++ b/libjava/classpath/javax/accessibility/AccessibleStateSet.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.accessibility;
+import gnu.java.lang.CPStringBuilder;
+
import java.util.Locale;
import java.util.Vector;
@@ -165,7 +167,7 @@ public class AccessibleStateSet
if (i == 0)
return "";
// Pre-allocate an average of 10 chars per state.
- StringBuffer b = new StringBuffer(i * 10);
+ CPStringBuilder b = new CPStringBuilder(i * 10);
while (--i >= 0)
b.append(states.get(i)).append(',');
return b.substring(0, b.length() - 1);
diff --git a/libjava/classpath/javax/activation/ActivationDataFlavor.java b/libjava/classpath/javax/activation/ActivationDataFlavor.java
new file mode 100644
index 00000000000..07ba1a38363
--- /dev/null
+++ b/libjava/classpath/javax/activation/ActivationDataFlavor.java
@@ -0,0 +1,161 @@
+/* ActivationDataFlavor.java -- Activation-specific DataFlavor instance.
+ Copyright (C) 2004 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 javax.activation;
+
+import gnu.java.lang.CPStringBuilder;
+
+import java.awt.datatransfer.DataFlavor;
+import java.io.InputStream;
+
+/**
+ * Activation-specific DataFlavor with improved MIME parsing.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.0.2
+ */
+public class ActivationDataFlavor extends DataFlavor
+{
+
+ private final String mimeType;
+ private final Class<?> representationClass;
+ private String humanPresentableName;
+
+ /**
+ * Constructor.
+ * @param representationClass the representation class
+ * @param mimeType the MIME type of the data
+ * @param humanPresentableName the human-presentable name of the data
+ * flavor
+ */
+ // Raw types enforced as part of spec.
+ @SuppressWarnings("unchecked")
+ public ActivationDataFlavor(Class representationClass, String mimeType,
+ String humanPresentableName)
+ {
+ super(mimeType, humanPresentableName);
+ this.mimeType = mimeType;
+ this.humanPresentableName = humanPresentableName;
+ this.representationClass = representationClass;
+ }
+
+ /**
+ * Constructor.
+ * @param representationClass the representation class
+ * @param humanPresentableName the human-presentable name of the data
+ * flavor
+ */
+ // Raw types enforced as part of spec.
+ @SuppressWarnings("unchecked")
+ public ActivationDataFlavor(Class representationClass,
+ String humanPresentableName)
+ {
+ super(representationClass, humanPresentableName);
+ mimeType = super.getMimeType();
+ this.representationClass = representationClass;
+ this.humanPresentableName = humanPresentableName;
+ }
+
+ /**
+ * Constructor. The representation class is an InputStream.
+ * @param mimeType the MIME type of the data
+ * @param humanPresentableName the human-presentable name of the data
+ * flavor
+ */
+ public ActivationDataFlavor(String mimeType, String humanPresentableName)
+ {
+ super(mimeType, humanPresentableName);
+ this.mimeType = mimeType;
+ this.humanPresentableName = humanPresentableName;
+ representationClass = InputStream.class;
+ }
+
+ public String getMimeType()
+ {
+ return mimeType;
+ }
+
+ // Raw types enforced as part of spec.
+ @SuppressWarnings("unchecked")
+ public Class getRepresentationClass()
+ {
+ return representationClass;
+ }
+
+ public String getHumanPresentableName()
+ {
+ return humanPresentableName;
+ }
+
+ public void setHumanPresentableName(String humanPresentableName)
+ {
+ this.humanPresentableName = humanPresentableName;
+ }
+
+ public boolean equals(DataFlavor dataFlavor)
+ {
+ return (isMimeTypeEqual(dataFlavor) &&
+ dataFlavor.getRepresentationClass() == representationClass);
+ }
+
+ public boolean isMimeTypeEqual(String mimeType)
+ {
+ try
+ {
+ return new MimeType(this.mimeType).match(new MimeType(mimeType));
+ }
+ catch (MimeTypeParseException e)
+ {
+ return false;
+ }
+ }
+
+ protected String normalizeMimeTypeParameter(String parameterName,
+ String parameterValue)
+ {
+ return new CPStringBuilder(parameterName)
+ .append('=')
+ .append(parameterValue)
+ .toString();
+ }
+
+ protected String normalizeMimeType(String mimeType)
+ {
+ return mimeType;
+ }
+
+}
diff --git a/libjava/classpath/javax/activation/CommandInfo.java b/libjava/classpath/javax/activation/CommandInfo.java
new file mode 100644
index 00000000000..d420c6ee106
--- /dev/null
+++ b/libjava/classpath/javax/activation/CommandInfo.java
@@ -0,0 +1,117 @@
+/* CommandInfo.java -- Description of the result of a command request.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.beans.Beans;
+import java.io.Externalizable;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+/**
+ * Description of the result of a command request.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public class CommandInfo
+{
+
+ private final String verb;
+ private final String className;
+
+ /**
+ * Constructor.
+ * @param verb the command verb
+ * @param className the command class name
+ */
+ public CommandInfo(String verb, String className)
+ {
+ this.verb = verb;
+ this.className = className;
+ }
+
+ /**
+ * Returns the command verb.
+ */
+ public String getCommandName()
+ {
+ return verb;
+ }
+
+ /**
+ * Returns the command class name.
+ */
+ public String getCommandClass()
+ {
+ return className;
+ }
+
+ /**
+ * Returns the instantiated bean.
+ * If the bean implements <code>CommandObject</code>, its
+ * <code>setCommandContext</code> method will be called.
+ * @param dh the data handler describing the command data
+ * @param loader the class loader used to instantiate the bean
+ */
+ public Object getCommandObject(DataHandler dh, ClassLoader loader)
+ throws IOException, ClassNotFoundException
+ {
+ Object object = Beans.instantiate(loader, className);
+ if (object != null)
+ {
+ if (object instanceof CommandObject)
+ {
+ CommandObject command = (CommandObject)object;
+ command.setCommandContext(verb, dh);
+ }
+ else if (dh != null && (object instanceof Externalizable))
+ {
+ InputStream in = dh.getInputStream();
+ if (in != null)
+ {
+ Externalizable externalizable = (Externalizable)object;
+ externalizable.readExternal(new ObjectInputStream(in));
+ }
+ }
+ }
+ return object;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/CommandMap.java b/libjava/classpath/javax/activation/CommandMap.java
new file mode 100644
index 00000000000..fd749612a30
--- /dev/null
+++ b/libjava/classpath/javax/activation/CommandMap.java
@@ -0,0 +1,212 @@
+/* CommandMap.java -- Registry of available command objects.
+ Copyright (C) 2004, 2005 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 javax.activation;
+
+/**
+ * Registry of command objects available to the system.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public abstract class CommandMap
+{
+
+ /* Class scope */
+
+ private static CommandMap defaultCommandMap;
+
+ /**
+ * Returns the default command map.
+ * This returns a MailcapCommandMap if no value has been set using
+ * <code>setDefaultCommandMap</code>.
+ */
+ public static CommandMap getDefaultCommandMap()
+ {
+ if (defaultCommandMap == null)
+ {
+ defaultCommandMap = new MailcapCommandMap();
+ }
+ return defaultCommandMap;
+ }
+
+ /**
+ * Sets the default command map.
+ * @param commandMap the new default command map
+ */
+ public static void setDefaultCommandMap(CommandMap commandMap)
+ {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ try
+ {
+ security.checkSetFactory();
+ }
+ catch (SecurityException e)
+ {
+ if (commandMap != null && CommandMap.class.getClassLoader() !=
+ commandMap.getClass().getClassLoader())
+ {
+ throw e;
+ }
+ }
+ }
+ defaultCommandMap = commandMap;
+ }
+
+ /* Instance scope */
+
+ /**
+ * Returns the list of preferred commands for a MIME type.
+ * @param mimeType the MIME type
+ */
+ public abstract CommandInfo[] getPreferredCommands(String mimeType);
+
+ /**
+ * Returns the complete list of commands for a MIME type.
+ * @param mimeType the MIME type
+ */
+ public abstract CommandInfo[] getAllCommands(String mimeType);
+
+ /**
+ * Returns the command corresponding to the specified MIME type and
+ * command name.
+ * @param mimeType the MIME type
+ * @param cmdName the command name
+ */
+ public abstract CommandInfo getCommand(String mimeType, String cmdName);
+
+ /**
+ * Returns a DataContentHandler corresponding to the MIME type.
+ * @param mimeType the MIME type
+ */
+ public abstract DataContentHandler createDataContentHandler(String mimeType);
+
+ /**
+ * Get all the MIME types known to this command map.
+ * If the command map doesn't support this operation, null is returned.
+ * @return array of MIME types as strings, or null if not supported
+ * @since JAF 1.1
+ */
+ public String[] getMimeTypes()
+ {
+ return null;
+ }
+
+ /**
+ * Get the preferred command list from a MIME Type. The actual semantics
+ * are determined by the implementation of the CommandMap.
+ * <p>
+ * The <code>DataSource</code> provides extra information, such as
+ * the file name, that a CommandMap implementation may use to further
+ * refine the list of commands that are returned. The implementation
+ * in this class simply calls the <code>getPreferredCommands</code>
+ * method that ignores this argument.
+ * @param mimeType the MIME type
+ * @param ds a DataSource for the data
+ * @return the CommandInfo classes that represent the command Beans.
+ * @since JAF 1.1
+ */
+ public CommandInfo[] getPreferredCommands(String mimeType,
+ DataSource ds)
+ {
+ return getPreferredCommands(mimeType);
+ }
+
+ /**
+ * Get all the available commands for this type. This method
+ * should return all the possible commands for this MIME type.
+ * <p>
+ * The <code>DataSource</code> provides extra information, such as
+ * the file name, that a CommandMap implementation may use to further
+ * refine the list of commands that are returned. The implementation
+ * in this class simply calls the <code>getAllCommands</code>
+ * method that ignores this argument.
+ * @param mimeType the MIME type
+ * @param ds a DataSource for the data
+ * @return the CommandInfo objects representing all the commands.
+ * @since JAF 1.1
+ */
+ public CommandInfo[] getAllCommands(String mimeType, DataSource ds)
+ {
+ return getAllCommands(mimeType);
+ }
+
+ /**
+ * Get the default command corresponding to the MIME type.
+ * <p>
+ * The <code>DataSource</code> provides extra information, such as
+ * the file name, that a CommandMap implementation may use to further
+ * refine the command that is chosen. The implementation
+ * in this class simply calls the <code>getCommand</code>
+ * method that ignores this argument.
+ * @param mimeType the MIME type
+ * @param cmdName the command name
+ * @param ds a DataSource for the data
+ * @return the CommandInfo corresponding to the command.
+ * @since JAF 1.1
+ */
+ public CommandInfo getCommand(String mimeType, String cmdName,
+ DataSource ds)
+ {
+ return getCommand(mimeType, cmdName);
+ }
+
+ /**
+ * Locate a DataContentHandler that corresponds to the MIME type.
+ * The mechanism and semantics for determining this are determined
+ * by the implementation of the particular CommandMap.
+ * <p>
+ * The <code>DataSource</code> provides extra information, such as
+ * the file name, that a CommandMap implementation may use to further
+ * refine the choice of DataContentHandler. The implementation
+ * in this class simply calls the <code>createDataContentHandler</code>
+ * method that ignores this argument.
+ * @param mimeType the MIME type
+ * @param ds a DataSource for the data
+ * @return the DataContentHandler for the MIME type
+ * @since JAF 1.1
+ */
+ public DataContentHandler createDataContentHandler(String mimeType,
+ DataSource ds)
+ {
+ return createDataContentHandler(mimeType);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/CommandObject.java b/libjava/classpath/javax/activation/CommandObject.java
new file mode 100644
index 00000000000..594622dae9a
--- /dev/null
+++ b/libjava/classpath/javax/activation/CommandObject.java
@@ -0,0 +1,62 @@
+/* CommandObject.java -- Bean interface for notifications.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.io.IOException;
+
+/**
+ * Bean interface to implement in order to receive notification of the
+ * command verb.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public interface CommandObject
+{
+
+ /**
+ * Initializes the command with the verb it is expected to perform and
+ * the data handler describing the data to operate on.
+ * @param verb the command verb
+ * @param dh the data handler describing the data to process
+ */
+ void setCommandContext(String verb, DataHandler dh)
+ throws IOException;
+
+}
+
diff --git a/libjava/classpath/javax/activation/DataContentHandler.java b/libjava/classpath/javax/activation/DataContentHandler.java
new file mode 100644
index 00000000000..f9507398b5a
--- /dev/null
+++ b/libjava/classpath/javax/activation/DataContentHandler.java
@@ -0,0 +1,85 @@
+/* DataContentHandler.java -- Converts streams to objects and vice versa.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Provider that can convert streams to objects and vice versa.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public interface DataContentHandler
+{
+
+ /**
+ * Returns a list of the flavors that data can be provided in, ordered
+ * by preference.
+ */
+ DataFlavor[] getTransferDataFlavors();
+
+ /**
+ * Returns an object representing the data to be transferred.
+ * @param df the flavor representing the requested type
+ * @param ds the data source of the data to be converted
+ */
+ Object getTransferData(DataFlavor df, DataSource ds)
+ throws UnsupportedFlavorException, IOException;
+
+ /**
+ * Returns an object representing the data in its most preferred form.
+ * @param ds the data source of the data to be converted
+ */
+ Object getContent(DataSource ds)
+ throws IOException;
+
+ /**
+ * Writes the object as a stream of bytes.
+ * @param obj the object to convert
+ * @param mimeType the MIME type of the stream
+ * @param os the byte stream
+ */
+ void writeTo(Object obj, String mimeType, OutputStream os)
+ throws IOException;
+
+}
+
diff --git a/libjava/classpath/javax/activation/DataContentHandlerFactory.java b/libjava/classpath/javax/activation/DataContentHandlerFactory.java
new file mode 100644
index 00000000000..c1f2b78dd16
--- /dev/null
+++ b/libjava/classpath/javax/activation/DataContentHandlerFactory.java
@@ -0,0 +1,56 @@
+/* DataContentHandlerFactory.java -- Factory for creating DataContentHandlers.
+ Copyright (C) 2004 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 javax.activation;
+
+/**
+ * Factory interface for creating data content handlers.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public interface DataContentHandlerFactory
+{
+
+ /**
+ * Returns a new data content handler for the specified MIME type.
+ * @param mimeType the MIME type
+ */
+ DataContentHandler createDataContentHandler(String mimeType);
+
+}
+
diff --git a/libjava/classpath/javax/activation/DataHandler.java b/libjava/classpath/javax/activation/DataHandler.java
new file mode 100644
index 00000000000..de786f96847
--- /dev/null
+++ b/libjava/classpath/javax/activation/DataHandler.java
@@ -0,0 +1,482 @@
+/* DataHandler.java -- Handler for data available in multiple formats.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.net.URL;
+
+/**
+ * Handler for data available in multiple sources and formats.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public class DataHandler
+ implements Transferable
+{
+
+ private static final DataFlavor[] NO_FLAVORS = new DataFlavor[0];
+ private static DataContentHandlerFactory factory = null;
+
+ private final DataSource dataSource;
+ private DataSource objDataSource;
+ private Object object;
+ private String objectMimeType;
+ private CommandMap currentCommandMap;
+ private DataFlavor[] transferFlavors = NO_FLAVORS;
+ private DataContentHandler dataContentHandler;
+ private DataContentHandler factoryDCH;
+ private DataContentHandlerFactory oldFactory;
+ private String shortType;
+
+ /**
+ * Constructor in which the data is read from a data source.
+ * @param ds the data source
+ */
+ public DataHandler(DataSource ds)
+ {
+ dataSource = ds;
+ oldFactory = factory;
+ }
+
+ /**
+ * Constructor using a reified object representation.
+ * @param obj the object representation of the data
+ * @param mimeType the MIME type of the object
+ */
+ public DataHandler(Object obj, String mimeType)
+ {
+ dataSource = null;
+ object = obj;
+ objectMimeType = mimeType;
+ oldFactory = factory;
+ }
+
+ /**
+ * Constructor in which the data is read from a URL.
+ * @param url the URL
+ */
+ public DataHandler(URL url)
+ {
+ dataSource = new URLDataSource(url);
+ oldFactory = factory;
+ }
+
+ /**
+ * Returns the data source from which data is read.
+ */
+ public DataSource getDataSource()
+ {
+ if (dataSource != null)
+ {
+ return dataSource;
+ }
+ if (objDataSource == null)
+ {
+ objDataSource = new DataHandlerDataSource(this);
+ }
+ return objDataSource;
+ }
+
+ /**
+ * Returns the name of the data object if created with a DataSource.
+ */
+ public String getName()
+ {
+ if (dataSource != null)
+ {
+ return dataSource.getName();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the MIME type of the data (with parameters).
+ */
+ public String getContentType()
+ {
+ if (dataSource != null)
+ {
+ return dataSource.getContentType();
+ }
+ return objectMimeType;
+ }
+
+ /**
+ * Returns an input stream from which the data can be read.
+ */
+ public InputStream getInputStream()
+ throws IOException
+ {
+ if (dataSource != null)
+ {
+ return dataSource.getInputStream();
+ }
+ DataContentHandler dch = getDataContentHandler();
+ if (dch == null)
+ {
+ throw new UnsupportedDataTypeException("no DCH for MIME type " +
+ getShortType());
+ }
+ if ((dch instanceof ObjectDataContentHandler) &&
+ ((ObjectDataContentHandler)dch).getDCH() == null)
+ {
+ throw new UnsupportedDataTypeException("no object DCH " +
+ "for MIME type " +
+ getShortType());
+ }
+ PipedOutputStream pos = new PipedOutputStream();
+ DataContentHandlerWriter dchw =
+ new DataContentHandlerWriter(dch, object, objectMimeType, pos);
+ Thread thread = new Thread(dchw, "DataHandler.getInputStream");
+ thread.start();
+ return new PipedInputStream(pos);
+ }
+
+ static class DataContentHandlerWriter
+ implements Runnable
+ {
+
+ DataContentHandler dch;
+ Object object;
+ String mimeType;
+ OutputStream out;
+
+ DataContentHandlerWriter(DataContentHandler dch, Object object,
+ String mimeType, OutputStream out)
+ {
+ this.dch = dch;
+ this.object = object;
+ this.mimeType = mimeType;
+ this.out = out;
+ }
+
+ public void run()
+ {
+ try
+ {
+ dch.writeTo(object, mimeType, out);
+ }
+ catch(IOException e)
+ {
+ }
+ finally
+ {
+ try
+ {
+ out.close();
+ }
+ catch(IOException e)
+ {
+ }
+ }
+ }
+ }
+
+ /**
+ * Writes the data as a byte stream.
+ * @param os the stream to write to
+ */
+ public void writeTo(OutputStream os)
+ throws IOException
+ {
+ if (dataSource != null)
+ {
+ InputStream in = dataSource.getInputStream();
+ byte[] buf = new byte[8192];
+ for (int len = in.read(buf); len != -1; len = in.read(buf))
+ {
+ os.write(buf, 0, len);
+ }
+ in.close();
+ }
+ else
+ {
+ DataContentHandler dch = getDataContentHandler();
+ dch.writeTo(object, objectMimeType, os);
+ }
+ }
+
+ /**
+ * Returns an output stream that can be used to overwrite the underlying
+ * data, if the DataSource constructor was used.
+ */
+ public OutputStream getOutputStream()
+ throws IOException
+ {
+ if (dataSource != null)
+ {
+ return dataSource.getOutputStream();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the data flavors in which this data is available.
+ */
+ public synchronized DataFlavor[] getTransferDataFlavors()
+ {
+ if (factory != oldFactory || transferFlavors == NO_FLAVORS)
+ {
+ DataContentHandler dch = getDataContentHandler();
+ transferFlavors = dch.getTransferDataFlavors();
+ }
+ return transferFlavors;
+ }
+
+ /**
+ * Indicates whether the specified data flavor is supported for this
+ * data.
+ */
+ public boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ DataFlavor[] flavors = getTransferDataFlavors();
+ for (int i = 0; i < flavors.length; i++)
+ {
+ if (flavors[i].equals(flavor))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns an object representing the data to be transferred.
+ * @param flavor the requested data flavor
+ */
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException, IOException
+ {
+ DataContentHandler dch = getDataContentHandler();
+ return dch.getTransferData(flavor, dataSource);
+ }
+
+ /**
+ * Sets the command map to be used by this data handler.
+ * Setting to null uses the default command map.
+ * @param commandMap the command map to use
+ */
+ public synchronized void setCommandMap(CommandMap commandMap)
+ {
+ if (commandMap != currentCommandMap || commandMap == null)
+ {
+ transferFlavors = NO_FLAVORS;
+ dataContentHandler = null;
+ currentCommandMap = commandMap;
+ }
+ }
+
+ /**
+ * Returns the preferred commands for this type of data.
+ */
+ public CommandInfo[] getPreferredCommands()
+ {
+ CommandMap commandMap = getCommandMap();
+ return commandMap.getPreferredCommands(getShortType());
+ }
+
+ /**
+ * Returns the complete list of commands for this type of data.
+ */
+ public CommandInfo[] getAllCommands()
+ {
+ CommandMap commandMap = getCommandMap();
+ return commandMap.getAllCommands(getShortType());
+ }
+
+ /**
+ * Returns the specified command.
+ * @param cmdName the command name
+ */
+ public CommandInfo getCommand(String cmdName)
+ {
+ CommandMap commandMap = getCommandMap();
+ return commandMap.getCommand(getShortType(), cmdName);
+ }
+
+ /**
+ * Returns the data as a reified object.
+ */
+ public Object getContent()
+ throws IOException
+ {
+ DataContentHandler dch = getDataContentHandler();
+ return dch.getContent(getDataSource());
+ }
+
+ /**
+ * Returns the instantiated bean using the specified command.
+ * @param cmdInfo the command to instantiate the bean with
+ */
+ public Object getBean(CommandInfo cmdInfo)
+ {
+ try
+ {
+ return cmdInfo.getCommandObject(this, getClass().getClassLoader());
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace(System.err);
+ return null;
+ }
+ catch (ClassNotFoundException e)
+ {
+ e.printStackTrace(System.err);
+ return null;
+ }
+ }
+
+ /**
+ * Sets the data content handler factory.
+ * If the factory has already been set, throws an Error.
+ * @param newFactory the factory to set
+ */
+ public static synchronized void
+ setDataContentHandlerFactory(DataContentHandlerFactory newFactory)
+ {
+ if (factory != null)
+ {
+ throw new Error("DataContentHandlerFactory already defined");
+ }
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ try
+ {
+ security.checkSetFactory();
+ }
+ catch (SecurityException e)
+ {
+ if (newFactory != null && DataHandler.class.getClassLoader()
+ != newFactory.getClass().getClassLoader())
+ {
+ throw e;
+ }
+ }
+ }
+ factory = newFactory;
+ }
+
+ /*
+ * Returns just the base part of the data's content-type, with no
+ * parameters.
+ */
+ private synchronized String getShortType()
+ {
+ if (shortType == null)
+ {
+ String contentType = getContentType();
+ try
+ {
+ MimeType mimeType = new MimeType(contentType);
+ shortType = mimeType.getBaseType();
+ }
+ catch (MimeTypeParseException e)
+ {
+ shortType = contentType;
+ }
+ }
+ return shortType;
+ }
+
+ /*
+ * Returns the command map for this handler.
+ */
+ private synchronized CommandMap getCommandMap()
+ {
+ if (currentCommandMap != null)
+ {
+ return currentCommandMap;
+ }
+ return CommandMap.getDefaultCommandMap();
+ }
+
+ /*
+ * Returns the DCH for this handler.
+ */
+ private synchronized DataContentHandler getDataContentHandler()
+ {
+ if (factory != oldFactory)
+ {
+ oldFactory = factory;
+ factoryDCH = null;
+ dataContentHandler = null;
+ transferFlavors = NO_FLAVORS;
+ }
+ if (dataContentHandler != null)
+ {
+ return dataContentHandler;
+ }
+ String mimeType = getShortType();
+ if (factoryDCH == null && factory != null)
+ {
+ factoryDCH = factory.createDataContentHandler(mimeType);
+ }
+ if (factoryDCH != null)
+ {
+ dataContentHandler = factoryDCH;
+ }
+ if (dataContentHandler == null)
+ {
+ CommandMap commandMap = getCommandMap();
+ dataContentHandler = commandMap.createDataContentHandler(mimeType);
+ }
+ if (dataSource != null)
+ {
+ dataContentHandler =
+ new DataSourceDataContentHandler(dataContentHandler, dataSource);
+ }
+ else
+ {
+ dataContentHandler =
+ new ObjectDataContentHandler(dataContentHandler, object,
+ objectMimeType);
+ }
+ return dataContentHandler;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/DataHandlerDataSource.java b/libjava/classpath/javax/activation/DataHandlerDataSource.java
new file mode 100644
index 00000000000..8dcd1a7a086
--- /dev/null
+++ b/libjava/classpath/javax/activation/DataHandlerDataSource.java
@@ -0,0 +1,84 @@
+/* DataHandlerDataSource.java -- Data source proxy for a DataHandler.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Data source that is a proxy for a data handler.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+final class DataHandlerDataSource
+ implements DataSource
+{
+
+ final DataHandler dh;
+
+ DataHandlerDataSource(DataHandler dh)
+ {
+ this.dh = dh;
+ }
+
+ public String getContentType()
+ {
+ return dh.getContentType();
+ }
+
+ public InputStream getInputStream()
+ throws IOException
+ {
+ return dh.getInputStream();
+ }
+
+ public String getName()
+ {
+ return dh.getName();
+ }
+
+ public OutputStream getOutputStream()
+ throws IOException
+ {
+ return dh.getOutputStream();
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/DataSource.java b/libjava/classpath/javax/activation/DataSource.java
new file mode 100644
index 00000000000..0d70843677a
--- /dev/null
+++ b/libjava/classpath/javax/activation/DataSource.java
@@ -0,0 +1,76 @@
+/* DataSource.java -- An interface for MIME data storage and retrieval.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * An interface by which MIME data can be retrieved and stored.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public interface DataSource
+{
+
+ /**
+ * Returns an input stream from which the data can be read.
+ */
+ InputStream getInputStream()
+ throws IOException;
+
+ /**
+ * Returns an output stream to which the data can be written.
+ */
+ OutputStream getOutputStream()
+ throws IOException;
+
+ /**
+ * Returns the MIME content type of the data.
+ */
+ String getContentType();
+
+ /**
+ * Returns the underlying name of this object.
+ */
+ String getName();
+
+}
+
diff --git a/libjava/classpath/javax/activation/DataSourceDataContentHandler.java b/libjava/classpath/javax/activation/DataSourceDataContentHandler.java
new file mode 100644
index 00000000000..9706ac19a16
--- /dev/null
+++ b/libjava/classpath/javax/activation/DataSourceDataContentHandler.java
@@ -0,0 +1,126 @@
+/* DataSourceDataContentHolder.java -- DCH using an existing data source.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Data content handler using an existing DCH and a data source.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+class DataSourceDataContentHandler
+ implements DataContentHandler
+{
+
+ private DataSource ds;
+ private DataFlavor[] flavors;
+ private DataContentHandler dch;
+
+ public DataSourceDataContentHandler(DataContentHandler dch, DataSource ds)
+ {
+ this.ds = ds;
+ this.dch = dch;
+ }
+
+ public Object getContent(DataSource ds)
+ throws IOException
+ {
+ if (dch != null)
+ {
+ return dch.getContent(ds);
+ }
+ else
+ {
+ return ds.getInputStream();
+ }
+ }
+
+ public Object getTransferData(DataFlavor flavor, DataSource ds)
+ throws UnsupportedFlavorException, IOException
+ {
+ if (dch != null)
+ {
+ return dch.getTransferData(flavor, ds);
+ }
+ DataFlavor[] tdf = getTransferDataFlavors();
+ if (tdf.length > 0 && flavor.equals(tdf[0]))
+ {
+ return ds.getInputStream();
+ }
+ else
+ {
+ throw new UnsupportedFlavorException(flavor);
+ }
+ }
+
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ if (flavors == null)
+ {
+ if (dch != null)
+ {
+ flavors = dch.getTransferDataFlavors();
+ }
+ else
+ {
+ String mimeType = ds.getContentType();
+ flavors = new DataFlavor[1];
+ flavors[0] = new ActivationDataFlavor(mimeType, mimeType);
+ }
+ }
+ return flavors;
+ }
+
+ public void writeTo(Object obj, String mimeType, OutputStream out)
+ throws IOException
+ {
+ if (dch == null)
+ {
+ throw new UnsupportedDataTypeException("no DCH for content type " +
+ ds.getContentType());
+ }
+ dch.writeTo(obj, mimeType, out);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/FileDataSource.java b/libjava/classpath/javax/activation/FileDataSource.java
new file mode 100644
index 00000000000..6e9035f1361
--- /dev/null
+++ b/libjava/classpath/javax/activation/FileDataSource.java
@@ -0,0 +1,123 @@
+/* FileDataSource.java -- Data source for a File object.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Data source encapsulating a file.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public class FileDataSource
+ implements DataSource
+{
+
+ private final File file;
+ private FileTypeMap typeMap;
+
+ /**
+ * Constructor.
+ * @param file the underlying file to use
+ */
+ public FileDataSource(File file)
+ {
+ this.file = file;
+ }
+
+ /**
+ * Constructor.
+ * @param name the path to the underlying file to use
+ */
+ public FileDataSource(String name)
+ {
+ this(new File(name));
+ }
+
+ public InputStream getInputStream()
+ throws IOException
+ {
+ return new FileInputStream(file);
+ }
+
+ public OutputStream getOutputStream()
+ throws IOException
+ {
+ return new FileOutputStream(file);
+ }
+
+ public String getContentType()
+ {
+ if (typeMap == null)
+ {
+ FileTypeMap dftm = FileTypeMap.getDefaultFileTypeMap();
+ return dftm.getContentType(file);
+ }
+ return typeMap.getContentType(file);
+ }
+
+ public String getName()
+ {
+ return file.getName();
+ }
+
+ /**
+ * Returns the underlying file.
+ */
+ public File getFile()
+ {
+ return file;
+ }
+
+ /**
+ * Sets the file type map to use to determine the content type of the file.
+ * @param map the file type map
+ */
+ public void setFileTypeMap(FileTypeMap map)
+ {
+ typeMap = map;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/FileTypeMap.java b/libjava/classpath/javax/activation/FileTypeMap.java
new file mode 100644
index 00000000000..2ef7805bf49
--- /dev/null
+++ b/libjava/classpath/javax/activation/FileTypeMap.java
@@ -0,0 +1,108 @@
+/* FileTypeMap.java -- Classifies the MIME content of files.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.io.File;
+
+/**
+ * Classifier for the MIME content type of files.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public abstract class FileTypeMap
+{
+
+ /* Class scope */
+
+ private static FileTypeMap defaultMap;
+
+ /**
+ * Returns the system default file type map.
+ * If one has not been set, this returns a MimetypesFileTypeMap.
+ */
+ public static FileTypeMap getDefaultFileTypeMap()
+ {
+ if (defaultMap == null)
+ {
+ defaultMap = new MimetypesFileTypeMap();
+ }
+ return defaultMap;
+ }
+
+ /**
+ * Sets the default file type map.
+ * @param map the new file type map
+ */
+ public static void setDefaultFileTypeMap(FileTypeMap map)
+ {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ try
+ {
+ security.checkSetFactory();
+ }
+ catch (SecurityException e)
+ {
+ if (map != null && FileTypeMap.class.getClassLoader() !=
+ map.getClass().getClassLoader())
+ {
+ throw e;
+ }
+ }
+ }
+ defaultMap = map;
+ }
+
+ /* Instance scope */
+
+ /**
+ * Returns the content type of the specified file.
+ * @param file the file to classify
+ */
+ public abstract String getContentType(File file);
+
+ /**
+ * Returns the content type of the specified file path.
+ * @param filename the path of the file to classify
+ */
+ public abstract String getContentType(String filename);
+
+}
+
diff --git a/libjava/classpath/javax/activation/MailcapCommandMap.java b/libjava/classpath/javax/activation/MailcapCommandMap.java
new file mode 100644
index 00000000000..cca5f04aafe
--- /dev/null
+++ b/libjava/classpath/javax/activation/MailcapCommandMap.java
@@ -0,0 +1,804 @@
+/* MailcapCommandMap.java -- Command map implementation using a mailcap file.
+ Copyright (C) 2004 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 javax.activation;
+
+import gnu.java.lang.CPStringBuilder;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.LinkedHashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Implementation of a command map using a <code>mailcap</code> file (RFC
+ * 1524). Mailcap files are searched for in the following places:
+ * <ol>
+ * <li>Programmatically added entries to this interface</li>
+ * <li>the file <tt>.mailcap</tt> in the user's home directory</li>
+ * <li>the file <i>&lt;java.home&gt;</i><tt>/lib/mailcap</tt></li>
+ * <li>the resource <tt>META-INF/mailcap</tt></li>
+ * <li>the resource <tt>META-INF/mailcap.default</tt> in the JAF
+ * distribution</li>
+ * </ol>
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public class MailcapCommandMap
+ extends CommandMap
+{
+
+ private static final int PROG = 0;
+ private static final int HOME = 1;
+ private static final int SYS = 2;
+ private static final int JAR = 3;
+ private static final int DEF = 4;
+ private static boolean debug = false;
+ private static final int NORMAL = 0;
+ private static final int FALLBACK = 1;
+
+ static
+ {
+ try
+ {
+ String d = System.getProperty("javax.activation.debug");
+ debug = Boolean.valueOf(d).booleanValue();
+ }
+ catch (SecurityException e)
+ {
+ }
+ }
+
+ private Map<String,Map<String,List<String>>>[][] mailcaps;
+
+ /**
+ * Default constructor.
+ */
+ public MailcapCommandMap()
+ {
+ init(null);
+ }
+
+ /**
+ * Constructor specifying a filename.
+ * @param fileName the name of the file to read mailcap entries from
+ */
+ public MailcapCommandMap(String fileName)
+ throws IOException
+ {
+ Reader in = null;
+ try
+ {
+ in = new FileReader(fileName);
+ }
+ catch (IOException e)
+ {
+ }
+ init(in);
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+
+ /**
+ * Constructor specifying an input stream.
+ * @param is the input stream to read mailcap entries from
+ */
+ public MailcapCommandMap(InputStream is)
+ {
+ init(new InputStreamReader(is));
+ }
+
+ private void init(Reader in)
+ {
+ mailcaps = new Map[5][2];
+ for (int i = 0; i < 5; i++)
+ {
+ for (int j = 0; j < 2; j++)
+ {
+ mailcaps[i][j] =
+ new LinkedHashMap<String,Map<String,List<String>>>();
+ }
+ }
+ if (in != null)
+ {
+ if (debug)
+ {
+ System.out.println("MailcapCommandMap: load PROG");
+ }
+ try
+ {
+ parse(PROG, in);
+ }
+ catch (IOException e)
+ {
+ }
+ }
+
+ if (debug)
+ {
+ System.out.println("MailcapCommandMap: load HOME");
+ }
+ try
+ {
+ String home = System.getProperty("user.home");
+ if (home != null)
+ {
+ parseFile(HOME, new CPStringBuilder(home)
+ .append(File.separatorChar)
+ .append(".mailcap")
+ .toString());
+ }
+ }
+ catch (SecurityException e)
+ {
+ }
+
+ if (debug)
+ {
+ System.out.println("MailcapCommandMap: load SYS");
+ }
+ try
+ {
+ parseFile(SYS,
+ new CPStringBuilder(System.getProperty("java.home"))
+ .append(File.separatorChar)
+ .append("lib")
+ .append(File.separatorChar)
+ .append("mailcap")
+ .toString());
+ }
+ catch (SecurityException e)
+ {
+ }
+
+ if (debug)
+ {
+ System.out.println("MailcapCommandMap: load JAR");
+ }
+ List<URL> systemResources = getSystemResources("META-INF/mailcap");
+ int len = systemResources.size();
+ if (len > 0)
+ {
+ for (int i = 0; i < len ; i++)
+ {
+ Reader urlIn = null;
+ URL url = systemResources.get(i);
+ try
+ {
+ if (debug)
+ {
+ System.out.println("\t" + url.toString());
+ }
+ urlIn = new InputStreamReader(url.openStream());
+ parse(JAR, urlIn);
+ }
+ catch (IOException e)
+ {
+ if (debug)
+ {
+ System.out.println(e.getClass().getName() + ": " +
+ e.getMessage());
+ }
+ }
+ finally
+ {
+ if (urlIn != null)
+ {
+ try
+ {
+ urlIn.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ parseResource(JAR, "/META-INF/mailcap");
+ }
+
+ if (debug)
+ {
+ System.out.println("MailcapCommandMap: load DEF");
+ }
+ parseResource(DEF, "/META-INF/mailcap.default");
+ }
+
+ /**
+ * Returns the list of preferred commands for a given MIME type.
+ * @param mimeType the MIME type
+ */
+ public synchronized CommandInfo[] getPreferredCommands(String mimeType)
+ {
+ List<CommandInfo> cmdList = new ArrayList<CommandInfo>();
+ List<String> verbList = new ArrayList<String>();
+ for (int i = 0; i < 2; i++)
+ {
+ for (int j = 0; j < 5; j++)
+ {
+ Map<String,List<String>> map = getCommands(mailcaps[j][i], mimeType);
+ if (map != null)
+ {
+ for (Map.Entry<String,List<String>> entry : map.entrySet())
+ {
+ String verb = entry.getKey();
+ if (!verbList.contains(verb))
+ {
+ List<String> classNames = entry.getValue();
+ String className = classNames.get(0);
+ CommandInfo cmd = new CommandInfo(verb, className);
+ cmdList.add(cmd);
+ verbList.add(verb);
+ }
+ }
+ }
+ }
+ }
+ CommandInfo[] cmds = new CommandInfo[cmdList.size()];
+ cmdList.toArray(cmds);
+ return cmds;
+ }
+
+ /**
+ * Returns all commands for the given MIME type.
+ * @param mimeType the MIME type
+ */
+ public synchronized CommandInfo[] getAllCommands(String mimeType)
+ {
+ List<CommandInfo> cmdList = new ArrayList<CommandInfo>();
+ for (int i = 0; i < 2; i++)
+ {
+ for (int j = 0; j < 5; j++)
+ {
+ Map<String,List<String>> map = getCommands(mailcaps[j][i], mimeType);
+ if (map != null)
+ {
+ for (Map.Entry<String,List<String>> entry : map.entrySet())
+ {
+ String verb = entry.getKey();
+ List<String> classNames = entry.getValue();
+ int len = classNames.size();
+ for (int l = 0; l < len; l++)
+ {
+ String className = classNames.get(l);
+ CommandInfo cmd = new CommandInfo(verb, className);
+ cmdList.add(cmd);
+ }
+ }
+ }
+ }
+ }
+ CommandInfo[] cmds = new CommandInfo[cmdList.size()];
+ cmdList.toArray(cmds);
+ return cmds;
+ }
+
+ /**
+ * Returns the command with the specified name for the given MIME type.
+ * @param mimeType the MIME type
+ * @param cmdName the command verb
+ */
+ public synchronized CommandInfo getCommand(String mimeType,
+ String cmdName)
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ for (int j = 0; j < 5; j++)
+ {
+ Map<String,List<String>> map =
+ getCommands(mailcaps[j][i], mimeType);
+ if (map != null)
+ {
+ List<String> classNames = map.get(cmdName);
+ if (classNames == null)
+ {
+ classNames = map.get("x-java-" + cmdName);
+ }
+ if (classNames != null)
+ {
+ String className = classNames.get(0);
+ return new CommandInfo(cmdName, className);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds entries programmatically to the registry.
+ * @param mailcap a mailcap string
+ */
+ public synchronized void addMailcap(String mailcap)
+ {
+ if (debug)
+ {
+ System.out.println("MailcapCommandMap: add to PROG");
+ }
+ try
+ {
+ parse(PROG, new StringReader(mailcap));
+ }
+ catch (IOException e)
+ {
+ }
+ }
+
+ /**
+ * Returns the DCH for the specified MIME type.
+ * @param mimeType the MIME type
+ */
+ public synchronized DataContentHandler
+ createDataContentHandler(String mimeType)
+ {
+ if (debug)
+ {
+ System.out.println("MailcapCommandMap: " +
+ "createDataContentHandler for " + mimeType);
+ }
+ for (int i = 0; i < 2; i++)
+ {
+ for (int j = 0; j < 5; j++)
+ {
+ if (debug)
+ {
+ System.out.println(" search DB #" + i);
+ }
+ Map<String,List<String>> map = getCommands(mailcaps[j][i], mimeType);
+ if (map != null)
+ {
+ List<String> classNames = map.get("content-handler");
+ if (classNames == null)
+ {
+ classNames = map.get("x-java-content-handler");
+ }
+ if (classNames != null)
+ {
+ String className = classNames.get(0);
+ if (debug)
+ {
+ System.out.println(" In " + nameOf(j) +
+ ", content-handler=" + className);
+ }
+ try
+ {
+ Class<?> clazz = Class.forName(className);
+ return (DataContentHandler)clazz.newInstance();
+ }
+ catch (IllegalAccessException e)
+ {
+ if (debug)
+ {
+ e.printStackTrace();
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ if (debug)
+ {
+ e.printStackTrace();
+ }
+ }
+ catch (InstantiationException e)
+ {
+ if (debug)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get the native commands for the given MIME type.
+ * Returns an array of strings where each string is
+ * an entire mailcap file entry. The application
+ * will need to parse the entry to extract the actual
+ * command as well as any attributes it needs. See
+ * <a href="http://www.ietf.org/rfc/rfc1524.txt">RFC 1524</a>
+ * for details of the mailcap entry syntax. Only mailcap
+ * entries that specify a view command for the specified
+ * MIME type are returned.
+ * @return array of native command entries
+ * @since JAF 1.1
+ */
+ public String[] getNativeCommands(String mimeType)
+ {
+ List<String> acc = new ArrayList<String>();
+ for (int i = 0; i < 2; i++)
+ {
+ for (int j = 0; j < 5; j++)
+ {
+ addNativeCommands(acc, mailcaps[j][i], mimeType);
+ }
+ }
+ String[] ret = new String[acc.size()];
+ acc.toArray(ret);
+ return ret;
+ }
+
+ private void addNativeCommands(List<String> acc,
+ Map<String,Map<String,List<String>>> mailcap,
+ String mimeType)
+ {
+ for (Map.Entry<String,Map<String,List<String>>> mEntry : mailcap.entrySet())
+ {
+ String entryMimeType = mEntry.getKey();
+ if (!entryMimeType.equals(mimeType))
+ {
+ continue;
+ }
+ Map<String,List<String>> commands = mEntry.getValue();
+ String viewCommand = commands.get("view-command").get(0);
+ if (viewCommand == null)
+ {
+ continue;
+ }
+ CPStringBuilder buf = new CPStringBuilder();
+ buf.append(mimeType);
+ buf.append(';');
+ buf.append(' ');
+ buf.append(viewCommand);
+ for (Map.Entry<String,List<String>> cEntry : commands.entrySet())
+ {
+ String verb = cEntry.getKey();
+ List<String> classNames = cEntry.getValue();
+ if (!"view-command".equals(verb))
+ {
+ for (String command : classNames)
+ {
+ buf.append(';');
+ buf.append(' ');
+ buf.append(verb);
+ buf.append('=');
+ buf.append(command);
+ }
+ }
+ }
+ if (buf.length() > 0)
+ {
+ acc.add(buf.toString());
+ }
+ }
+ }
+
+ private static String nameOf(int mailcap)
+ {
+ switch (mailcap)
+ {
+ case PROG:
+ return "PROG";
+ case HOME:
+ return "HOME";
+ case SYS:
+ return "SYS";
+ case JAR:
+ return "JAR";
+ case DEF:
+ return "DEF";
+ default:
+ return "ERR";
+ }
+ }
+
+ private void parseFile(int index, String filename)
+ {
+ Reader in = null;
+ try
+ {
+ if (debug)
+ {
+ System.out.println("\t" + filename);
+ }
+ in = new FileReader(filename);
+ parse(index, in);
+ }
+ catch (IOException e)
+ {
+ if (debug)
+ {
+ System.out.println(e.getClass().getName() + ": " +
+ e.getMessage());
+ }
+ }
+ finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+
+ private void parseResource(int index, String name)
+ {
+ Reader in = null;
+ try
+ {
+ InputStream is = getClass().getResourceAsStream(name);
+ if (is != null)
+ {
+ if (debug)
+ {
+ System.out.println("\t" + name);
+ }
+ in = new InputStreamReader(is);
+ parse(index, in);
+ }
+ }
+ catch (IOException e)
+ {
+ if (debug)
+ {
+ System.out.println(e.getClass().getName() + ": " +
+ e.getMessage());
+ }
+ }
+ finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+
+ private void parse(int index, Reader in)
+ throws IOException
+ {
+ BufferedReader br = new BufferedReader(in);
+ CPStringBuilder buf = null;
+ for (String line = br.readLine(); line != null; line = br.readLine())
+ {
+ line = line.trim();
+ int len = line.length();
+ if (len == 0 || line.charAt(0) == '#')
+ {
+ continue; // Comment
+ }
+ if (line.charAt(len - 1) == '\\')
+ {
+ if (buf == null)
+ {
+ buf = new CPStringBuilder();
+ }
+ buf.append(line.substring(0, len - 1));
+ }
+ else if (buf != null)
+ {
+ buf.append(line);
+ parseEntry(index, buf.toString());
+ buf = null;
+ }
+ else
+ {
+ parseEntry(index, line);
+ }
+ }
+ }
+
+ private void parseEntry(int index, String line)
+ {
+ // Tokenize entry into fields
+ char[] chars = line.toCharArray();
+ int len = chars.length;
+ boolean inQuotedString = false;
+ boolean fallback = false;
+ CPStringBuilder buffer = new CPStringBuilder();
+ List<String> fields = new ArrayList<String>();
+ for (int i = 0; i < len; i++)
+ {
+ char c = chars[i];
+ if (c == '\\')
+ {
+ c = chars[++i]; // qchar
+ }
+ if (c == ';' && !inQuotedString)
+ {
+ String field = buffer.toString().trim();
+ if ("x-java-fallback-entry".equals(field))
+ {
+ fallback = true;
+ }
+ fields.add(field);
+ buffer.setLength(0);
+ }
+ else
+ {
+ if (c == '"')
+ {
+ inQuotedString = !inQuotedString;
+ }
+ buffer.append(c);
+ }
+ }
+ String field = buffer.toString().trim();
+ if ("x-java-fallback-entry".equals(field))
+ {
+ fallback = true;
+ }
+ fields.add(field);
+
+ len = fields.size();
+ if (len < 2)
+ {
+ if (debug)
+ {
+ System.err.println("Invalid mailcap entry: " + line);
+ }
+ return;
+ }
+
+ Map<String,Map<String,List<String>>> mailcap =
+ fallback ? mailcaps[index][FALLBACK] : mailcaps[index][NORMAL];
+ String mimeType = fields.get(0);
+ addField(mailcap, mimeType, "view-command", (String) fields.get(1));
+ for (int i = 2; i < len; i++)
+ {
+ addField(mailcap, mimeType, null, (String) fields.get(i));
+ }
+ }
+
+ private void addField(Map<String,Map<String,List<String>>> mailcap,
+ String mimeType, String verb, String command)
+ {
+ if (verb == null)
+ {
+ int ei = command.indexOf('=');
+ if (ei != -1)
+ {
+ verb = command.substring(0, ei);
+ command = command.substring(ei + 1);
+ }
+ }
+ if (command.length() == 0 || verb == null || verb.length() == 0)
+ {
+ return; // Invalid field or flag
+ }
+
+ Map<String,List<String>> commands = mailcap.get(mimeType);
+ if (commands == null)
+ {
+ commands = new LinkedHashMap<String,List<String>>();
+ mailcap.put(mimeType, commands);
+ }
+ List<String> classNames = commands.get(verb);
+ if (classNames == null)
+ {
+ classNames = new ArrayList<String>();
+ commands.put(verb, classNames);
+ }
+ classNames.add(command);
+ }
+
+ private Map<String,List<String>>
+ getCommands(Map<String,Map<String,List<String>>> mailcap,
+ String mimeType)
+ {
+ int si = mimeType.indexOf('/');
+ String genericMimeType = new CPStringBuilder(mimeType.substring(0, si))
+ .append('/')
+ .append('*')
+ .toString();
+ Map<String,List<String>> specific = mailcap.get(mimeType);
+ Map<String,List<String>> generic = mailcap.get(genericMimeType);
+ if (generic == null)
+ {
+ return specific;
+ }
+ if (specific == null)
+ {
+ return generic;
+ }
+ Map<String,List<String>> combined = new LinkedHashMap<String,List<String>>();
+ combined.putAll(specific);
+ for (String verb : generic.keySet())
+ {
+ List<String> genericClassNames = generic.get(verb);
+ List<String> classNames = combined.get(verb);
+ if (classNames == null)
+ {
+ combined.put(verb, genericClassNames);
+ }
+ else
+ {
+ classNames.addAll(genericClassNames);
+ }
+ }
+ return combined;
+ }
+
+ // -- Utility methods --
+
+ private List<URL> getSystemResources(String name)
+ {
+ List<URL> acc = new ArrayList<URL>();
+ try
+ {
+ for (Enumeration<URL> i = ClassLoader.getSystemResources(name);
+ i.hasMoreElements(); )
+ {
+ acc.add(i.nextElement());
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return acc;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/MimeType.java b/libjava/classpath/javax/activation/MimeType.java
new file mode 100644
index 00000000000..70045d6686b
--- /dev/null
+++ b/libjava/classpath/javax/activation/MimeType.java
@@ -0,0 +1,293 @@
+/* MimeType.java -- A MIME type as defined in RFC2046 and RFC2047.
+ Copyright (C) 2004 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 javax.activation;
+
+import gnu.java.lang.CPStringBuilder;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * A MIME content type, as defined in RFCs 2045 and 2046.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public class MimeType
+ implements Externalizable
+{
+
+ static final String TSPECIALS = "()<>@,;:/[]?=\\\"";
+
+ private String primaryType;
+ private String subType;
+ private MimeTypeParameterList parameters;
+
+ /**
+ * Constructor for an <code>application/*</code> content type.
+ */
+ public MimeType()
+ {
+ primaryType = "application";
+ subType = "*";
+ parameters = new MimeTypeParameterList();
+ }
+
+ /**
+ * Constructor that parses a raw String.
+ * @param rawdata the MIME type string
+ */
+ public MimeType(String rawdata)
+ throws MimeTypeParseException
+ {
+ parse(rawdata);
+ }
+
+ /**
+ * Constructor for a new MIME type with the given primary and sub types
+ * and an empty parameter list.
+ * @param primary the primary type
+ * @param sub the subtype
+ */
+ public MimeType(String primary, String sub)
+ throws MimeTypeParseException
+ {
+ checkValidity(primary, "Primary type is invalid");
+ checkValidity(sub, "Sub type is invalid");
+ primaryType = primary.toLowerCase();
+ subType = sub.toLowerCase();
+ parameters = new MimeTypeParameterList();
+ }
+
+ /**
+ * Returns the primary type.
+ */
+ public String getPrimaryType()
+ {
+ return primaryType;
+ }
+
+ /**
+ * Sets the primary type.
+ * @param primary the new primary type
+ */
+ public void setPrimaryType(String primary)
+ throws MimeTypeParseException
+ {
+ checkValidity(primary, "Primary type is invalid");
+ primaryType = primary.toLowerCase();
+ }
+
+ /**
+ * Returns the subtype.
+ */
+ public String getSubType()
+ {
+ return subType;
+ }
+
+ /**
+ * Sets the subtype.
+ * @param sub the new subtype
+ */
+ public void setSubType(String sub)
+ throws MimeTypeParseException
+ {
+ checkValidity(sub, "Sub type is invalid");
+ subType = sub.toLowerCase();
+ }
+
+ /**
+ * Returns the MIME parameters.
+ */
+ public MimeTypeParameterList getParameters()
+ {
+ return parameters;
+ }
+
+ /**
+ * Returns the parameter value for the specified name.
+ * @param name the parameter name
+ */
+ public String getParameter(String name)
+ {
+ return parameters.get(name);
+ }
+
+ /**
+ * Sets the parameter value for the specified name.
+ * @param name the parameter name
+ * @param value the new value
+ */
+ public void setParameter(String name, String value)
+ {
+ parameters.set(name, value);
+ }
+
+ /**
+ * Removes the parameter value for the specified name.
+ * @param name the parameter name
+ */
+ public void removeParameter(String name)
+ {
+ parameters.remove(name);
+ }
+
+ /**
+ * Returns the complete string representation of this MIME type.
+ */
+ public String toString()
+ {
+ return new CPStringBuilder(primaryType)
+ .append('/')
+ .append(subType)
+ .append(parameters.toString())
+ .toString();
+ }
+
+ /**
+ * Returns the string representation of this MIME type without
+ * parameters.
+ */
+ public String getBaseType()
+ {
+ return new CPStringBuilder(primaryType)
+ .append('/')
+ .append(subType)
+ .toString();
+ }
+
+ /**
+ * Returns true if the primary and subtype of this MIME type are the
+ * same as in the given MIME type.
+ */
+ public boolean match(MimeType type)
+ {
+ String primary2 = type.getPrimaryType();
+ String sub2 = type.getSubType();
+ return primaryType.equals(primary2) && (subType.equals(sub2) ||
+ "*".equals(subType) ||
+ "*".equals(sub2));
+ }
+
+ /**
+ * Returns true if the primary and subtype of this MIME type are the
+ * same as in the given MIME type string.
+ */
+ public boolean match(String rawdata)
+ throws MimeTypeParseException
+ {
+ return match(new MimeType(rawdata));
+ }
+
+ public void writeExternal(ObjectOutput out)
+ throws IOException
+ {
+ out.writeUTF(toString());
+ out.flush();
+ }
+
+ public void readExternal(ObjectInput in)
+ throws IOException, ClassNotFoundException
+ {
+ try
+ {
+ parse(in.readUTF());
+ }
+ catch (MimeTypeParseException e)
+ {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ private void parse(String rawdata)
+ throws MimeTypeParseException
+ {
+ int si = rawdata.indexOf('/');
+ int pi = rawdata.indexOf(';');
+ if (si == -1)
+ {
+ throw new MimeTypeParseException("Unable to find a sub type.");
+ }
+ if (pi == -1)
+ {
+ primaryType = rawdata.substring(0, si).toLowerCase().trim();
+ subType = rawdata.substring(si + 1).toLowerCase().trim();
+ parameters = new MimeTypeParameterList();
+ }
+ else if (si < pi)
+ {
+ primaryType = rawdata.substring(0, si).toLowerCase().trim();
+ subType = rawdata.substring(si + 1, pi).toLowerCase().trim();
+ parameters = new MimeTypeParameterList(rawdata.substring(pi));
+ }
+ else
+ {
+ throw new MimeTypeParseException("Unable to find a sub type.");
+ }
+ checkValidity(primaryType, "Primary type is invalid");
+ checkValidity(subType, "Sub type is invalid");
+ }
+
+ static void checkValidity(String token, String message)
+ throws MimeTypeParseException
+ {
+ int len = token.length();
+ if (len == 0)
+ {
+ throw new MimeTypeParseException(message, token);
+ }
+ for (int i = 0; i < len; i++)
+ {
+ char c = token.charAt(i);
+ if (!isValidChar(c))
+ {
+ throw new MimeTypeParseException(message, token);
+ }
+ }
+ }
+
+ static boolean isValidChar(char c)
+ {
+ return c > ' ' && c <= '~' && TSPECIALS.indexOf(c) == -1;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/MimeTypeParameterList.java b/libjava/classpath/javax/activation/MimeTypeParameterList.java
new file mode 100644
index 00000000000..e15469da88c
--- /dev/null
+++ b/libjava/classpath/javax/activation/MimeTypeParameterList.java
@@ -0,0 +1,336 @@
+/* MimeTypeParameterList.java -- Handle a list of MIME type parameters.
+ Copyright (C) 2004 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 javax.activation;
+
+import gnu.java.lang.CPStringBuilder;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A list of MIME type parameters, as specified in RFCs 2045 and 2046.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public class MimeTypeParameterList
+{
+
+ private final List<String> parameterNames;
+ private final Map<String,String> parameterValues;
+
+ /**
+ * Constructor for an empty parameter list.
+ */
+ public MimeTypeParameterList()
+ {
+ parameterNames = new ArrayList<String>();
+ parameterValues = new HashMap<String,String>();
+ }
+
+ /**
+ * Constructor that parses the specified MIME parameter data.
+ * @param parameterList a MIME parameter list string representation
+ */
+ public MimeTypeParameterList(String parameterList)
+ throws MimeTypeParseException
+ {
+ this();
+ parse(parameterList);
+ }
+
+ /**
+ * Parses the specified MIME parameter data, storing the results in this
+ * object.
+ * @param parameterList a MIME parameter list string representation
+ */
+ protected void parse(String parameterList)
+ throws MimeTypeParseException
+ {
+ if (parameterList == null)
+ {
+ return;
+ }
+ // Tokenize list into parameters
+ char[] chars = parameterList.toCharArray();
+ int len = chars.length;
+ boolean inQuotedString = false;
+ CPStringBuilder buffer = new CPStringBuilder();
+ List<String> params = new ArrayList<String>();
+ for (int i = 0; i < len; i++)
+ {
+ char c = chars[i];
+ if (c == ';' && !inQuotedString)
+ {
+ String param = buffer.toString().trim();
+ if (param.length() > 0)
+ {
+ params.add(param);
+ }
+ buffer.setLength(0);
+ }
+ else
+ {
+ if (c == '"')
+ {
+ inQuotedString = !inQuotedString;
+ }
+ buffer.append(c);
+ }
+ }
+ String param = buffer.toString().trim();
+ if (param.length() > 0)
+ {
+ params.add(param);
+ }
+
+ // Tokenize each parameter into name + value
+ for (Iterator<String> i = params.iterator(); i.hasNext();)
+ {
+ param = i.next();
+ int ei = param.indexOf('=');
+ if (ei == -1)
+ {
+ throw new MimeTypeParseException("Couldn't find the '=' that " +
+ "separates a parameter name " +
+ "from its value.");
+ }
+ String name = param.substring(0, ei).trim();
+ MimeType.checkValidity(name, "Parameter name is invalid");
+ String value = param.substring(ei + 1).trim();
+ len = value.length();
+ if (len > 1 && value.charAt(0) == '"' &&
+ value.charAt(len - 1) == '"')
+ {
+ value = unquote(value);
+ }
+ else
+ {
+ MimeType.checkValidity(name, "Parameter value is invalid");
+ }
+
+ parameterNames.add(name);
+ parameterValues.put(name.toLowerCase(), value);
+ }
+ }
+
+ /**
+ * Returns the number of parameters.
+ */
+ public synchronized int size()
+ {
+ return parameterNames.size();
+ }
+
+ /**
+ * Indicates if there are no parameters.
+ */
+ public synchronized boolean isEmpty()
+ {
+ return parameterNames.isEmpty();
+ }
+
+ /**
+ * Returns the value for the specified parameter name.
+ * @param name the parameter name
+ */
+ public synchronized String get(String name)
+ {
+ name = name.trim();
+ return parameterValues.get(name.toLowerCase());
+ }
+
+ /**
+ * Sets the value for the specified parameter name.
+ * @param name the parameter name
+ * @param value the parameter value
+ */
+ public synchronized void set(String name, String value)
+ {
+ name = name.trim();
+ boolean exists = false;
+ for (String pname : parameterNames)
+ {
+ if (name.equalsIgnoreCase(pname))
+ {
+ exists = true;
+ }
+ }
+ if (!exists)
+ {
+ parameterNames.add(name);
+ }
+ parameterValues.put(name.toLowerCase(), value);
+ }
+
+ /**
+ * Removes the parameter identified by the specified name.
+ * @param name the parameter name
+ */
+ public synchronized void remove(String name)
+ {
+ name = name.trim();
+ for (Iterator<String> i = parameterNames.iterator();i.hasNext();)
+ {
+ String pname = i.next();
+ if (name.equalsIgnoreCase(pname))
+ {
+ i.remove();
+ }
+ }
+ parameterValues.remove(name.toLowerCase());
+ }
+
+ /**
+ * Returns an enumeration of all the parameter names.
+ */
+ // Raw type is forced by public spec.
+ @SuppressWarnings("unchecked")
+ public synchronized Enumeration getNames()
+ {
+ return new IteratorEnumeration(parameterNames.iterator());
+ }
+
+ /**
+ * Returns an RFC 2045-compliant string representation of this parameter
+ * list.
+ */
+ public synchronized String toString()
+ {
+ CPStringBuilder buffer = new CPStringBuilder();
+ for (String name : parameterNames)
+ {
+ String value = parameterValues.get(name.toLowerCase());
+
+ buffer.append(';');
+ buffer.append(' ');
+ buffer.append(name);
+ buffer.append('=');
+ buffer.append(quote(value));
+ }
+ return buffer.toString();
+ }
+
+ private static String quote(String value)
+ {
+ boolean needsQuoting = false;
+ int len = value.length();
+ for (int i = 0; i < len; i++)
+ {
+ if (!MimeType.isValidChar(value.charAt(i)))
+ {
+ needsQuoting = true;
+ break;
+ }
+ }
+
+ if (needsQuoting)
+ {
+ CPStringBuilder buffer = new CPStringBuilder();
+ buffer.append('"');
+ for (int i = 0; i < len; i++)
+ {
+ char c = value.charAt(i);
+ if (c == '\\' || c == '"')
+ {
+ buffer.append('\\');
+ }
+ buffer.append(c);
+ }
+ buffer.append('"');
+ return buffer.toString();
+ }
+ return value;
+ }
+
+ private static String unquote(String value)
+ {
+ int len = value.length();
+ CPStringBuilder buffer = new CPStringBuilder();
+ for (int i = 1; i < len - 1; i++)
+ {
+ char c = value.charAt(i);
+ if (c == '\\')
+ {
+ i++;
+ if (i < len - 1)
+ {
+ c = value.charAt(i);
+ if (c != '\\' && c != '"')
+ {
+ buffer.append('\\');
+ }
+ }
+ }
+ buffer.append(c);
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Enumeration proxy for an Iterator.
+ */
+ static class IteratorEnumeration
+ implements Enumeration<String>
+ {
+
+ final Iterator<String> iterator;
+
+ IteratorEnumeration(Iterator<String> iterator)
+ {
+ this.iterator = iterator;
+ }
+
+ public boolean hasMoreElements()
+ {
+ return iterator.hasNext();
+ }
+
+ public String nextElement()
+ {
+ return iterator.next();
+ }
+
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/MimeTypeParseException.java b/libjava/classpath/javax/activation/MimeTypeParseException.java
new file mode 100644
index 00000000000..b46e244fda6
--- /dev/null
+++ b/libjava/classpath/javax/activation/MimeTypeParseException.java
@@ -0,0 +1,84 @@
+/* MimeTypeParseException.java -- Exception due to invalid MIME type.
+ Copyright (C) 2004 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 javax.activation;
+
+import gnu.java.lang.CPStringBuilder;
+
+/**
+ * Exception thrown to indicate a malformed MIME content type.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public class MimeTypeParseException
+ extends Exception
+{
+
+ /**
+ * Constructs a MimeTypeParseException with no detail message.
+ */
+ public MimeTypeParseException()
+ {
+ }
+
+ /**
+ * MimeTypeParseException with the specified detail message.
+ * @param message the exception message
+ */
+ public MimeTypeParseException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Constructs a MimeTypeParseException with the specified detail message
+ * and token in error.
+ * @param message the exception message
+ * @param token the token in error
+ */
+ MimeTypeParseException(String message, String token)
+ {
+ this(new CPStringBuilder(message)
+ .append(':')
+ .append(' ')
+ .append(token)
+ .toString());
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/MimetypesFileTypeMap.java b/libjava/classpath/javax/activation/MimetypesFileTypeMap.java
new file mode 100644
index 00000000000..d1566fd969c
--- /dev/null
+++ b/libjava/classpath/javax/activation/MimetypesFileTypeMap.java
@@ -0,0 +1,440 @@
+/* MimeTypesFileTypeMap.java -- A file type map using mime.types.
+ Copyright (C) 2004 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 javax.activation;
+
+import gnu.java.lang.CPStringBuilder;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Implementation of FileTypeMap that uses the <tt>mime.types</tt> format.
+ * File entries are searched for in the following locations and order:
+ * <ol>
+ * <li>Programmatically added entries to this instance</li>
+ * <li>The file <tt>.mime.types</tt> in the user's home directory</li>
+ * <li>The file <i>&lt;java.home&gt;</i><tt>/lib/mime.types</tt></li>
+ * <li>The resource <tt>META-INF/mime.types</tt></li>
+ * <li>The resource <tt>META-INF/mimetypes.default</tt> in the JAF
+ * distribution</li>
+ * </ol>
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public class MimetypesFileTypeMap
+ extends FileTypeMap
+{
+
+ private static final int PROG = 0;
+ private static final int HOME = 1;
+ private static final int SYS = 2;
+ private static final int JAR = 3;
+ private static final int DEF = 4;
+ private static final String DEFAULT_MIME_TYPE = "application/octet-stream";
+ private static boolean debug = false;
+ static
+ {
+ try
+ {
+ String d = System.getProperty("javax.activation.debug");
+ debug = Boolean.valueOf(d).booleanValue();
+ }
+ catch (SecurityException e)
+ {
+ }
+ }
+
+ private Map<String,String>[] mimetypes;
+
+ /**
+ * Default constructor.
+ */
+ public MimetypesFileTypeMap()
+ {
+ init(null);
+ }
+
+ /**
+ * Constructor specifying a filename.
+ * @param mimeTypeFileName the name of the file to read mime.types
+ * entries from
+ */
+ public MimetypesFileTypeMap(String mimeTypeFileName)
+ throws IOException
+ {
+ Reader in = null;
+ try
+ {
+ in = new FileReader(mimeTypeFileName);
+ init(in);
+ }
+ finally
+ {
+ if (in != null)
+ {
+ in.close();
+ }
+ }
+ }
+
+ /**
+ * Constructor specifying an input stream.
+ * @param is the input stream to read mime.types entries from
+ */
+ public MimetypesFileTypeMap(InputStream is)
+ {
+ init(new InputStreamReader(is));
+ }
+
+ private void init(Reader in)
+ {
+ mimetypes = new Map[5];
+ for (int i = 0; i < mimetypes.length; i++)
+ {
+ mimetypes[i] = new HashMap<String,String>();
+ }
+ if (in != null)
+ {
+ if (debug)
+ {
+ System.out.println("MimetypesFileTypeMap: load PROG");
+ }
+ try
+ {
+ parse(mimetypes[PROG], in);
+ }
+ catch (IOException e)
+ {
+ }
+ }
+
+ if (debug)
+ {
+ System.out.println("MimetypesFileTypeMap: load HOME");
+ }
+ try
+ {
+ String home = System.getProperty("user.home");
+ if (home != null)
+ {
+ parseFile(mimetypes[HOME], new CPStringBuilder(home)
+ .append(File.separatorChar)
+ .append(".mime.types")
+ .toString());
+ }
+ }
+ catch (SecurityException e)
+ {
+ }
+
+ if (debug)
+ {
+ System.out.println("MimetypesFileTypeMap: load SYS");
+ }
+ try
+ {
+ parseFile(mimetypes[SYS],
+ new CPStringBuilder(System.getProperty("java.home"))
+ .append(File.separatorChar)
+ .append("lib")
+ .append(File.separatorChar)
+ .append("mime.types")
+ .toString());
+ }
+ catch (SecurityException e)
+ {
+ }
+ if (debug)
+ {
+ System.out.println("MimetypesFileTypeMap: load JAR");
+ }
+ List<URL> systemResources = getSystemResources("META-INF/mime.types");
+ int len = systemResources.size();
+ if (len > 0)
+ {
+ for (int i = 0; i < len ; i++)
+ {
+ Reader urlIn = null;
+ URL url = (URL)systemResources.get(i);
+ try
+ {
+ urlIn = new InputStreamReader(url.openStream());
+ parse(mimetypes[JAR], urlIn);
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ if (urlIn != null)
+ {
+ try
+ {
+ urlIn.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ parseResource(mimetypes[JAR], "/META-INF/mime.types");
+ }
+
+ if (debug)
+ {
+ System.out.println("MimetypesFileTypeMap: load DEF");
+ }
+ parseResource(mimetypes[DEF], "/META-INF/mimetypes.default");
+ }
+
+ /**
+ * Adds entries prorammatically to the registry.
+ * @param mime_types a mime.types formatted entries string
+ */
+ public synchronized void addMimeTypes(String mime_types)
+ {
+ if (debug)
+ {
+ System.out.println("MimetypesFileTypeMap: add to PROG");
+ }
+ try
+ {
+ parse(mimetypes[PROG], new StringReader(mime_types));
+ }
+ catch (IOException e)
+ {
+ }
+ }
+
+ /**
+ * Returns the MIME content type of the file.
+ * This calls <code>getContentType(f.getName())</code>.
+ * @param f the file
+ */
+ public String getContentType(File f)
+ {
+ return getContentType(f.getName());
+ }
+
+ /**
+ * Returns the MIME type based on the given filename.
+ * If no entry is found, returns "application/octet-stream".
+ * @param filename the filename
+ */
+ public synchronized String getContentType(String filename)
+ {
+ int di = filename.lastIndexOf('.');
+ if (di < 0)
+ {
+ return DEFAULT_MIME_TYPE;
+ }
+ String tail = filename.substring(di + 1);
+ if (tail.length() < 1)
+ {
+ return DEFAULT_MIME_TYPE;
+ }
+ for (int i = 0; i < mimetypes.length; i++)
+ {
+ String mimeType = (String)mimetypes[i].get(tail);
+ if (mimeType != null)
+ {
+ return mimeType;
+ }
+ }
+ return DEFAULT_MIME_TYPE;
+ }
+
+ private void parseFile(Map<String,String> mimetypes, String filename)
+ {
+ Reader in = null;
+ try
+ {
+ in = new FileReader(filename);
+ parse(mimetypes, in);
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+
+ private void parseResource(Map<String,String> mimetypes, String name)
+ {
+ Reader in = null;
+ try
+ {
+ InputStream is = getClass().getResourceAsStream(name);
+ if (is != null)
+ {
+ in = new InputStreamReader(is);
+ parse(mimetypes, in);
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+
+ private void parse(Map<String,String> mimetypes, Reader in)
+ throws IOException
+ {
+ BufferedReader br = new BufferedReader(in);
+ CPStringBuilder buf = null;
+ for (String line = br.readLine(); line != null; line = br.readLine())
+ {
+ line = line.trim();
+ int len = line.length();
+ if (len == 0 || line.charAt(0) == '#')
+ {
+ continue; // Empty line / comment
+ }
+ if (line.charAt(len - 1) == '\\')
+ {
+ if (buf == null)
+ {
+ buf = new CPStringBuilder();
+ }
+ buf.append(line.substring(0, len - 1));
+ }
+ else if (buf != null)
+ {
+ buf.append(line);
+ parseEntry(mimetypes, buf.toString());
+ buf = null;
+ }
+ else
+ {
+ parseEntry(mimetypes, line);
+ }
+ }
+ }
+
+ private void parseEntry(Map<String,String> mimetypes,
+ String line)
+ {
+ // Tokenize
+ String mimeType = null;
+ char[] chars = line.toCharArray();
+ int len = chars.length;
+ CPStringBuilder buffer = new CPStringBuilder();
+ for (int i = 0; i < len; i++)
+ {
+ char c = chars[i];
+ if (Character.isWhitespace(c))
+ {
+ if (mimeType == null)
+ {
+ mimeType = buffer.toString();
+ }
+ else if (buffer.length() > 0)
+ {
+ mimetypes.put(buffer.toString(), mimeType);
+ }
+ buffer.setLength(0);
+ }
+ else
+ buffer.append(c);
+ }
+ if (buffer.length() > 0)
+ {
+ mimetypes.put(buffer.toString(), mimeType);
+ }
+ }
+
+ // -- Utility methods --
+
+ private List<URL> getSystemResources(String name)
+ {
+ List<URL> acc = new ArrayList<URL>();
+ try
+ {
+ for (Enumeration<URL> i = ClassLoader.getSystemResources(name);
+ i.hasMoreElements(); )
+ acc.add(i.nextElement());
+ }
+ catch (IOException e)
+ {
+ }
+ return acc;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/ObjectDataContentHandler.java b/libjava/classpath/javax/activation/ObjectDataContentHandler.java
new file mode 100644
index 00000000000..5105cb45b2c
--- /dev/null
+++ b/libjava/classpath/javax/activation/ObjectDataContentHandler.java
@@ -0,0 +1,128 @@
+/* ObjectDataContentHandler.java -- Data content handler using an object.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Data content handler that uses an existing DCH and reified object.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+class ObjectDataContentHandler
+ implements DataContentHandler
+{
+
+ private DataContentHandler dch;
+ private Object object;
+ private String mimeType;
+ private DataFlavor[] flavors;
+
+ public ObjectDataContentHandler(DataContentHandler dch, Object object,
+ String mimeType)
+ {
+ this.dch = dch;
+ this.object = object;
+ this.mimeType = mimeType;
+ }
+
+ public Object getContent(DataSource ds)
+ {
+ return object;
+ }
+
+ public DataContentHandler getDCH()
+ {
+ return dch;
+ }
+
+ public Object getTransferData(DataFlavor flavor, DataSource ds)
+ throws UnsupportedFlavorException, IOException
+ {
+ if (dch != null)
+ {
+ return dch.getTransferData(flavor, ds);
+ }
+ if (flavors == null)
+ {
+ getTransferDataFlavors();
+ }
+ if (flavor.equals(flavors[0]))
+ {
+ return object;
+ }
+ throw new UnsupportedFlavorException(flavor);
+ }
+
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ if (flavors == null)
+ {
+ if (dch != null)
+ {
+ flavors = dch.getTransferDataFlavors();
+ }
+ else
+ {
+ flavors = new DataFlavor[1];
+ flavors[0] = new ActivationDataFlavor(object.getClass(),
+ mimeType, mimeType);
+ }
+ }
+ return flavors;
+ }
+
+ public void writeTo(Object object, String mimeType, OutputStream out)
+ throws IOException
+ {
+ if (dch != null)
+ {
+ dch.writeTo(object, mimeType, out);
+ }
+ else
+ {
+ throw new UnsupportedDataTypeException("no object DCH for MIME type " + mimeType);
+ }
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/URLDataSource.java b/libjava/classpath/javax/activation/URLDataSource.java
new file mode 100644
index 00000000000..8b77567aeac
--- /dev/null
+++ b/libjava/classpath/javax/activation/URLDataSource.java
@@ -0,0 +1,138 @@
+/* URLDataSource.java -- Data source for a URL object.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * DataSource implementation that retrieves its data from a URL.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public class URLDataSource
+ implements DataSource
+{
+
+ private final URL url;
+ private URLConnection connection;
+
+ /**
+ * Constructor.
+ * This will not open the connection to the URL.
+ */
+ public URLDataSource(URL url)
+ {
+ this.url = url;
+ }
+
+ /**
+ * Returns the Content-Type header for the URL.
+ * In the case of failure or lack of such a header,
+ * returns "application/octet-stream".
+ */
+ public String getContentType()
+ {
+ try
+ {
+ if (connection == null)
+ {
+ connection = url.openConnection();
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ String contentType = null;
+ if (connection != null)
+ {
+ contentType = connection.getContentType();
+ }
+ if (contentType == null)
+ {
+ contentType = "application/octet-stream";
+ }
+ return contentType;
+ }
+
+ /**
+ * Returns the result of <code>getFile</code> of the underlying URL.
+ */
+ public String getName()
+ {
+ return url.getFile();
+ }
+
+ public InputStream getInputStream()
+ throws IOException
+ {
+ connection = url.openConnection();
+ if (connection != null)
+ {
+ connection.setDoInput(true);
+ return connection.getInputStream();
+ }
+ return null;
+ }
+
+ public OutputStream getOutputStream()
+ throws IOException
+ {
+ connection = url.openConnection();
+ if (connection != null)
+ {
+ connection.setDoOutput(true);
+ return connection.getOutputStream();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the underlying URL.
+ */
+ public URL getURL()
+ {
+ return url;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/UnsupportedDataTypeException.java b/libjava/classpath/javax/activation/UnsupportedDataTypeException.java
new file mode 100644
index 00000000000..09460b06985
--- /dev/null
+++ b/libjava/classpath/javax/activation/UnsupportedDataTypeException.java
@@ -0,0 +1,70 @@
+/* UnsupportedDataTypeException.java -- Thrown when a data type is not supported.
+ Copyright (C) 2004 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 javax.activation;
+
+import java.io.IOException;
+
+/**
+ * Exception indicating that the requested method doesn't support the
+ * specified data type.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @version 1.1
+ */
+public class UnsupportedDataTypeException extends IOException
+{
+
+ /**
+ * Constructs an UnsupportedDataTypeException with no detail message.
+ */
+ public UnsupportedDataTypeException()
+ {
+ }
+
+ /**
+ * Constructs an UnsupportedDataTypeException with the specified detail
+ * message.
+ * @param message the message
+ */
+ public UnsupportedDataTypeException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/activation/package.html b/libjava/classpath/javax/activation/package.html
new file mode 100644
index 00000000000..74027ec328a
--- /dev/null
+++ b/libjava/classpath/javax/activation/package.html
@@ -0,0 +1,44 @@
+<body>
+
+<p>
+The GNU JavaBeans&trade; Activation Framework (JAF) provides a
+<a href="http://www.gnu.org/">Free</a> implementation of the
+JavaBeans&trade; Activation Framework, version 1.1.
+</p>
+
+<p>
+JAF links together beans and internet standards for specifying MIME
+types and how MIME types are processed. It provides a means to associate
+data of a given MIME type with bean actions operating on that data.
+</p>
+
+
+<h4>Important files</h4>
+
+<p>
+Standard <code>mime.types</code> files are parsed by the JAF MIME
+handling classes to work out the MIME types available on the local
+system.
+</p>
+
+<p>
+Standard <code>mailcap</code> files (defined in RFC1524) are parsed by
+mail capability handling classes to work out what beans should be linked
+to what MIME types.
+</p>
+
+<p>
+<small>Neither the authors nor the Free Software Foundation offer
+ANY SUPPORT for this software or imply any warranty.<br>
+Use it at your own risk.
+</small>
+</p>
+
+<p>
+<small>If you can suggest improvements in either the implementation
+code or in the documentation please contact the
+<a href="mailto:classpath@gnu.org">GNU Classpath project</a> developers.
+</small>
+</p>
+
+</body>
diff --git a/libjava/classpath/javax/imageio/ImageIO.java b/libjava/classpath/javax/imageio/ImageIO.java
index a3d967726b9..5f0d71d60a9 100644
--- a/libjava/classpath/javax/imageio/ImageIO.java
+++ b/libjava/classpath/javax/imageio/ImageIO.java
@@ -851,6 +851,7 @@ public final class ImageIO
}
w.write(null, img, null);
+ w.dispose();
output.close();
return true;
}
diff --git a/libjava/classpath/javax/imageio/plugins/jpeg/JPEGHuffmanTable.java b/libjava/classpath/javax/imageio/plugins/jpeg/JPEGHuffmanTable.java
index c0567be7830..378e11fa617 100644
--- a/libjava/classpath/javax/imageio/plugins/jpeg/JPEGHuffmanTable.java
+++ b/libjava/classpath/javax/imageio/plugins/jpeg/JPEGHuffmanTable.java
@@ -38,6 +38,8 @@
package javax.imageio.plugins.jpeg;
+import gnu.java.lang.CPStringBuilder;
+
/**
* The JPEGHuffmanTable class represents a Huffman table read from a
* JPEG image file. The standard JPEG AC and DC chrominance and
@@ -263,7 +265,7 @@ public class JPEGHuffmanTable
*/
public String toString()
{
- StringBuffer buffer = new StringBuffer();
+ CPStringBuilder buffer = new CPStringBuilder();
buffer.append("JPEGHuffmanTable:\nlengths:");
diff --git a/libjava/classpath/javax/imageio/plugins/jpeg/JPEGQTable.java b/libjava/classpath/javax/imageio/plugins/jpeg/JPEGQTable.java
index a94e8b1880d..259d0aa6437 100644
--- a/libjava/classpath/javax/imageio/plugins/jpeg/JPEGQTable.java
+++ b/libjava/classpath/javax/imageio/plugins/jpeg/JPEGQTable.java
@@ -38,6 +38,8 @@
package javax.imageio.plugins.jpeg;
+import gnu.java.lang.CPStringBuilder;
+
/**
* The JPEGQTable class represents a quantization table that can be
* used to encode or decode a JPEG stream. The standard JPEG
@@ -178,7 +180,7 @@ public class JPEGQTable
*/
public String toString()
{
- StringBuffer buffer = new StringBuffer();
+ CPStringBuilder buffer = new CPStringBuilder();
buffer.append("JPEGQTable:\n");
for (int i = 0; i < 8; i++)
diff --git a/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java b/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java
index 71eec41a998..e338f1dbe3d 100644
--- a/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java
+++ b/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.imageio.stream;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
@@ -341,7 +343,7 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
int c = -1;
boolean eol = false;
- StringBuffer buffer = new StringBuffer();
+ CPStringBuilder buffer = new CPStringBuilder();
c = read();
if (c == -1)
diff --git a/libjava/classpath/javax/management/DefaultLoaderRepository.java b/libjava/classpath/javax/management/DefaultLoaderRepository.java
index b905af22ff2..38f7d020652 100644
--- a/libjava/classpath/javax/management/DefaultLoaderRepository.java
+++ b/libjava/classpath/javax/management/DefaultLoaderRepository.java
@@ -77,6 +77,8 @@ import java.util.List;
* @throws ClassNotFoundException if all the class loaders fail
* to load the class.
*/
+ // API issue with lack of <?> on Class
+ @SuppressWarnings("unchecked")
public static Class loadClass(String name)
throws ClassNotFoundException
{
@@ -124,6 +126,8 @@ import java.util.List;
* @throws ClassNotFoundException if all the class loaders fail
* to load the class.
*/
+ // API issue with lack of <?> on Class
+ @SuppressWarnings("unchecked")
public static Class loadClassWithout(ClassLoader exclude, String name)
throws ClassNotFoundException
{
diff --git a/libjava/classpath/javax/management/JMX.java b/libjava/classpath/javax/management/JMX.java
index a435d3e6b77..e5fb2586fc3 100644
--- a/libjava/classpath/javax/management/JMX.java
+++ b/libjava/classpath/javax/management/JMX.java
@@ -324,6 +324,8 @@ public class JMX
* server using the given name.
* @see #newMXBeanProxy(MBeanServerConnection, ObjectName, Class)
*/
+ // Suppress warnings as we know an instance of T will be returned.
+ @SuppressWarnings("unchecked")
public static <T> T newMXBeanProxy(MBeanServerConnection conn,
ObjectName name, Class<T> iface,
boolean bcast)
diff --git a/libjava/classpath/javax/management/MBeanAttributeInfo.java b/libjava/classpath/javax/management/MBeanAttributeInfo.java
index 2e8475ea0eb..85e4e453b0d 100644
--- a/libjava/classpath/javax/management/MBeanAttributeInfo.java
+++ b/libjava/classpath/javax/management/MBeanAttributeInfo.java
@@ -117,7 +117,7 @@ public class MBeanAttributeInfo
{
Type t = setter.getGenericParameterTypes()[0];
if (t instanceof Class)
- attributeType = ((Class) t).getName();
+ attributeType = ((Class<?>) t).getName();
else
attributeType = t.toString();
isRead = false;
@@ -127,7 +127,7 @@ public class MBeanAttributeInfo
{
Type t = getter.getGenericReturnType();
if (t instanceof Class)
- attributeType = ((Class) t).getName();
+ attributeType = ((Class<?>) t).getName();
else
attributeType = t.toString();
isRead = true;
diff --git a/libjava/classpath/javax/management/MBeanConstructorInfo.java b/libjava/classpath/javax/management/MBeanConstructorInfo.java
index 15c8227c246..041f3e904b6 100644
--- a/libjava/classpath/javax/management/MBeanConstructorInfo.java
+++ b/libjava/classpath/javax/management/MBeanConstructorInfo.java
@@ -75,6 +75,8 @@ public class MBeanConstructorInfo
* @param desc a description of the attribute.
* @param cons the constructor.
*/
+ // API issue with lack of <?> on Constructor
+ @SuppressWarnings("unchecked")
public MBeanConstructorInfo(String desc, Constructor cons)
{
super(cons.getName(), desc);
@@ -85,7 +87,7 @@ public class MBeanConstructorInfo
Type t = paramTypes[a];
if (t instanceof Class)
signature[a] = new MBeanParameterInfo(null,
- ((Class) t).getName(),
+ ((Class<?>) t).getName(),
null);
else
signature[a] = new MBeanParameterInfo(null, t.toString(), null);
diff --git a/libjava/classpath/javax/management/MBeanOperationInfo.java b/libjava/classpath/javax/management/MBeanOperationInfo.java
index 6495072e627..03220c15e10 100644
--- a/libjava/classpath/javax/management/MBeanOperationInfo.java
+++ b/libjava/classpath/javax/management/MBeanOperationInfo.java
@@ -121,14 +121,14 @@ public class MBeanOperationInfo
Type t = paramTypes[a];
if (t instanceof Class)
signature[a] = new MBeanParameterInfo(null,
- ((Class) t).getName(),
+ ((Class<?>) t).getName(),
null);
else
signature[a] = new MBeanParameterInfo(null, t.toString(), null);
}
Type retType = method.getGenericReturnType();
if (retType instanceof Class)
- type = ((Class) retType).getName();
+ type = ((Class<?>) retType).getName();
else
type = retType.toString();
if (method.getReturnType() == Void.TYPE)
diff --git a/libjava/classpath/javax/management/MBeanPermission.java b/libjava/classpath/javax/management/MBeanPermission.java
index 1ee0e710433..076ac86f1af 100644
--- a/libjava/classpath/javax/management/MBeanPermission.java
+++ b/libjava/classpath/javax/management/MBeanPermission.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.management;
+import gnu.java.lang.CPStringBuilder;
+
import java.security.Permission;
import java.io.IOException;
@@ -154,19 +156,19 @@ public class MBeanPermission
/**
* The list of actions as an ordered set.
*/
- private transient Set actionSet;
+ private transient Set<String> actionSet;
/**
* The set of valid actions.
*/
- private static final Set validSet;
+ private static final Set<String> validSet;
/**
* Initialise the set of valid actions.
*/
static
{
- validSet = new HashSet();
+ validSet = new HashSet<String>();
validSet.add("addNotificationListener");
validSet.add("getAttribute");
validSet.add("getClassLoader");
@@ -263,8 +265,8 @@ public class MBeanPermission
*/
public String getActions()
{
- Iterator it = actionSet.iterator();
- StringBuilder builder = new StringBuilder();
+ Iterator<String> it = actionSet.iterator();
+ CPStringBuilder builder = new CPStringBuilder();
while (it.hasNext())
{
builder.append(it.next());
@@ -323,10 +325,8 @@ public class MBeanPermission
NameHolder name = new NameHolder(getName());
if (!(name.equals(pName)))
return false;
- Iterator i = mp.getActionSet().iterator();
- while (i.hasNext())
+ for (String nextAction : mp.actionSet)
{
- String nextAction = (String) i.next();
boolean found = actions.contains(nextAction);
if (!found)
if (nextAction.equals("queryNames"))
@@ -502,23 +502,13 @@ public class MBeanPermission
}
/**
- * Returns the set of actions.
- *
- * @return the actions as an ordered set.
- */
- Set getActionSet()
- {
- return actionSet;
- }
-
- /**
* Updates the action set from the current value of
* the actions string.
*/
private void updateActionSet()
{
String[] actionsArray = actions.split(",");
- actionSet = new TreeSet();
+ actionSet = new TreeSet<String>();
for (int a = 0; a < actionsArray.length; ++a)
actionSet.add(actionsArray[a].trim());
}
@@ -548,10 +538,8 @@ public class MBeanPermission
*/
private void checkActions()
{
- Iterator it = actionSet.iterator();
- while (it.hasNext())
+ for (String action : actionSet)
{
- String action = (String) it.next();
if (!(validSet.contains(action)))
throw new IllegalArgumentException("Invalid action "
+ action + " found.");
diff --git a/libjava/classpath/javax/management/MBeanServerDelegate.java b/libjava/classpath/javax/management/MBeanServerDelegate.java
index 9e9d19111a8..c55faa3d069 100644
--- a/libjava/classpath/javax/management/MBeanServerDelegate.java
+++ b/libjava/classpath/javax/management/MBeanServerDelegate.java
@@ -69,7 +69,8 @@ public class MBeanServerDelegate
/**
* The listeners registered with the delegate.
*/
- private final List listeners = new ArrayList();
+ private final List<ListenerData> listeners =
+ new ArrayList<ListenerData>();
/**
* The sequence identifier used by the delegate.
@@ -234,12 +235,11 @@ public class MBeanServerDelegate
public void removeNotificationListener(NotificationListener listener)
throws ListenerNotFoundException
{
- Iterator it = listeners.iterator();
+ Iterator<ListenerData> it = listeners.iterator();
boolean foundOne = false;
while (it.hasNext())
{
- ListenerData data = (ListenerData) it.next();
- if (data.getListener() == listener)
+ if (it.next().getListener() == listener)
{
it.remove();
foundOne = true;
@@ -293,10 +293,8 @@ public class MBeanServerDelegate
{
if (notification.getSequenceNumber() <= 0)
notification.setSequenceNumber(++seqNo);
- Iterator it = listeners.iterator();
- while (it.hasNext())
+ for (ListenerData ldata : listeners)
{
- ListenerData ldata = (ListenerData) it.next();
NotificationFilter filter = ldata.getFilter();
if (filter == null || filter.isNotificationEnabled(notification))
ldata.getListener().handleNotification(notification, ldata.getPassback());
diff --git a/libjava/classpath/javax/management/MBeanServerFactory.java b/libjava/classpath/javax/management/MBeanServerFactory.java
index a8dac948984..d798b0c4517 100644
--- a/libjava/classpath/javax/management/MBeanServerFactory.java
+++ b/libjava/classpath/javax/management/MBeanServerFactory.java
@@ -89,7 +89,8 @@ public class MBeanServerFactory
/**
* The map of registered servers (identifiers to servers).
*/
- private static final Map<Object,MBeanServer> servers = new HashMap();
+ private static final Map<Object,MBeanServer> servers =
+ new HashMap<Object,MBeanServer>();
/**
* Private constructor to prevent instance creation.
@@ -212,7 +213,7 @@ public class MBeanServerFactory
if (sm != null)
sm.checkPermission(new MBeanServerPermission("findMBeanServer"));
if (id == null)
- return new ArrayList(servers.values());
+ return new ArrayList<MBeanServer>(servers.values());
ArrayList<MBeanServer> list = new ArrayList<MBeanServer>();
MBeanServer server = servers.get(id);
if (server != null)
@@ -342,7 +343,7 @@ public class MBeanServerFactory
cl = MBeanServerFactory.class.getClassLoader();
try
{
- Class bClass = Class.forName(builderClass, true, cl);
+ Class<?> bClass = Class.forName(builderClass, true, cl);
builder = (MBeanServerBuilder) bClass.newInstance();
}
catch (ClassNotFoundException e)
diff --git a/libjava/classpath/javax/management/MBeanServerInvocationHandler.java b/libjava/classpath/javax/management/MBeanServerInvocationHandler.java
index 948996764d9..acc8543f11b 100644
--- a/libjava/classpath/javax/management/MBeanServerInvocationHandler.java
+++ b/libjava/classpath/javax/management/MBeanServerInvocationHandler.java
@@ -204,7 +204,7 @@ public class MBeanServerInvocationHandler
throws Throwable
{
String mName = method.getName();
- Class proxyClass = proxy.getClass();
+ Class<?> proxyClass = proxy.getClass();
if (mName.equals("toString"))
{
if (inInterface(mName, proxyClass))
@@ -352,6 +352,8 @@ public class MBeanServerInvocationHandler
* @return a proxy for the specified bean.
* @see JMX#newMBeanProxy(MBeanServerConnection,ObjectName,Class)
*/
+ // Suppress warnings as we know an instance of T will be returned.
+ @SuppressWarnings("unchecked")
public static <T> T newProxyInstance(MBeanServerConnection conn,
ObjectName name, Class<T> iface,
boolean broadcaster)
diff --git a/libjava/classpath/javax/management/MBeanServerPermission.java b/libjava/classpath/javax/management/MBeanServerPermission.java
index e6227814443..045573aba02 100644
--- a/libjava/classpath/javax/management/MBeanServerPermission.java
+++ b/libjava/classpath/javax/management/MBeanServerPermission.java
@@ -280,6 +280,7 @@ public class MBeanServerPermission
* @see #isReadOnly()
* @see #setReadOnly(boolean)
*/
+ @Override
public void add(Permission p)
{
if (isReadOnly())
@@ -305,13 +306,14 @@ public class MBeanServerPermission
String cps = cp[b].trim();
if (cps.equals(nps))
found = true;
- if (np.equals("newMBeanServer")
+ if (nps.equals("newMBeanServer")
&& createms != -1)
found = true;
- if (np.equals("createMBeanServer")
+ if (nps.equals("createMBeanServer")
&& newms != -1)
- finalString.replace("newMBeanServer",
- "createMBeanServer");
+ finalString =
+ finalString.replace("newMBeanServer",
+ "createMBeanServer");
}
if (!found)
finalString += "," + nps;
@@ -327,7 +329,8 @@ public class MBeanServerPermission
*
* @return an enumeration over the collection permission.
*/
- public Enumeration elements()
+ @Override
+ public Enumeration<Permission> elements()
{
return new
MBeanServerPermissionEnumeration(collectionPermission);
@@ -341,7 +344,7 @@ public class MBeanServerPermission
* @since 1.5
*/
private class MBeanServerPermissionEnumeration
- implements Enumeration
+ implements Enumeration<Permission>
{
/**
@@ -381,7 +384,7 @@ public class MBeanServerPermission
*
* @return the next capability.
*/
- public Object nextElement()
+ public Permission nextElement()
{
if (hasMoreElements())
{
@@ -405,6 +408,7 @@ public class MBeanServerPermission
* @param p the permission to check for implication.
* @return true if this permission implies <code>p</code>.
*/
+ @Override
public boolean implies(Permission p)
{
return collectionPermission.implies(p);
diff --git a/libjava/classpath/javax/management/ObjectName.java b/libjava/classpath/javax/management/ObjectName.java
index 1fb51506f04..d3ccd201fbd 100644
--- a/libjava/classpath/javax/management/ObjectName.java
+++ b/libjava/classpath/javax/management/ObjectName.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.management;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.Serializable;
import java.util.Hashtable;
@@ -304,17 +306,14 @@ public class ObjectName
"character.");
char[] keychars = new char[] { '\n', ':', ',', '*', '?', '=' };
char[] valchars = new char[] { '\n', ':', ',', '=' };
- Iterator i = properties.entrySet().iterator();
- while (i.hasNext())
+ for (Map.Entry<String,String> entry : properties.entrySet())
{
- Map.Entry entry = (Map.Entry) i.next();
- String key = (String) entry.getKey();
for (int a = 0; a < keychars.length; ++a)
- if (key.indexOf(keychars[a]) != -1)
+ if (entry.getKey().indexOf(keychars[a]) != -1)
throw new MalformedObjectNameException("A key contains a '" +
keychars[a] + "' " +
"character.");
- String value = (String) entry.getValue();
+ String value = entry.getValue();
int quote = value.indexOf('"');
if (quote == 0)
{
@@ -387,15 +386,13 @@ public class ObjectName
if (isPropertyPattern())
{
- Hashtable oProps = name.getKeyPropertyList();
- Iterator i = properties.entrySet().iterator();
- while (i.hasNext())
+ Hashtable<String,String> oProps = name.getKeyPropertyList();
+ for (Map.Entry<String,String> entry : properties.entrySet())
{
- Map.Entry entry = (Map.Entry) i.next();
- String key = (String) entry.getKey();
+ String key = entry.getKey();
if (!(oProps.containsKey(key)))
return false;
- String val = (String) entry.getValue();
+ String val = entry.getValue();
if (!(val.equals(oProps.get(key))))
return false;
}
@@ -476,11 +473,11 @@ public class ObjectName
*/
public String getCanonicalKeyPropertyListString()
{
- StringBuilder builder = new StringBuilder();
- Iterator i = properties.entrySet().iterator();
+ CPStringBuilder builder = new CPStringBuilder();
+ Iterator<Map.Entry<String,String>> i = properties.entrySet().iterator();
while (i.hasNext())
{
- Map.Entry entry = (Map.Entry) i.next();
+ Map.Entry<String,String> entry = i.next();
builder.append(entry.getKey() + "=" + entry.getValue());
if (i.hasNext())
builder.append(",");
@@ -795,7 +792,7 @@ public class ObjectName
*/
public static String quote(String string)
{
- StringBuilder builder = new StringBuilder();
+ CPStringBuilder builder = new CPStringBuilder();
builder.append('"');
for (int a = 0; a < string.length(); ++a)
{
@@ -863,7 +860,7 @@ public class ObjectName
throws IOException
{
out.defaultWriteObject();
- StringBuffer buffer = new StringBuffer(getDomain());
+ CPStringBuilder buffer = new CPStringBuilder(getDomain());
buffer.append(':');
String properties = getKeyPropertyListString();
buffer.append(properties);
@@ -924,7 +921,7 @@ public class ObjectName
if (q.charAt(q.length() - 1) != '"')
throw new IllegalArgumentException("The string does " +
"not end with a quote.");
- StringBuilder builder = new StringBuilder();
+ CPStringBuilder builder = new CPStringBuilder();
for (int a = 1; a < (q.length() - 1); ++a)
{
char n = q.charAt(a);
diff --git a/libjava/classpath/javax/management/StandardMBean.java b/libjava/classpath/javax/management/StandardMBean.java
index bd59c68ae22..13e95bd396d 100644
--- a/libjava/classpath/javax/management/StandardMBean.java
+++ b/libjava/classpath/javax/management/StandardMBean.java
@@ -569,8 +569,8 @@ public class StandardMBean
if (info != null)
return info;
Method[] methods = iface.getMethods();
- Map attributes = new HashMap();
- List operations = new ArrayList();
+ Map<String,Method[]> attributes = new HashMap<String,Method[]>();
+ List<MBeanOperationInfo> operations = new ArrayList<MBeanOperationInfo>();
for (int a = 0; a < methods.length; ++a)
{
String name = methods[a].getName();
@@ -614,16 +614,14 @@ public class StandardMBean
operations.add(new MBeanOperationInfo(methods[a].getName(),
methods[a]));
}
- List attribs = new ArrayList(attributes.size());
- Iterator it = attributes.entrySet().iterator();
- while (it.hasNext())
+ List<MBeanAttributeInfo> attribs = new ArrayList<MBeanAttributeInfo>(attributes.size());
+ for (Map.Entry<String,Method[]> entry : attributes.entrySet())
{
- Map.Entry entry = (Map.Entry) it.next();
- Method[] amethods = (Method[]) entry.getValue();
+ Method[] amethods = entry.getValue();
try
{
- attribs.add(new MBeanAttributeInfo((String) entry.getKey(),
- (String) entry.getKey(),
+ attribs.add(new MBeanAttributeInfo(entry.getKey(),
+ entry.getKey(),
amethods[0], amethods[1]));
}
catch (IntrospectionException e)
@@ -646,7 +644,7 @@ public class StandardMBean
oldInfo.isWritable(),
oldInfo.isIs());
}
- Constructor[] cons = impl.getClass().getConstructors();
+ Constructor<?>[] cons = impl.getClass().getConstructors();
MBeanConstructorInfo[] cinfo = new MBeanConstructorInfo[cons.length];
for (int a = 0; a < cinfo.length; ++a)
{
@@ -778,10 +776,10 @@ public class StandardMBean
"Invocation of an attribute " +
"method is disallowed.");
ClassLoader loader = getClass().getClassLoader();
- Class[] sigTypes;
+ Class<?>[] sigTypes;
if (signature != null)
{
- sigTypes = new Class[signature.length];
+ sigTypes = new Class<?>[signature.length];
for (int a = 0; a < signature.length; ++a)
try
{
@@ -892,7 +890,7 @@ public class StandardMBean
public AttributeList setAttributes(AttributeList attributes)
{
AttributeList list = new AttributeList(attributes.size());
- Iterator it = attributes.iterator();
+ Iterator<Object> it = attributes.iterator();
while (it.hasNext())
{
try
diff --git a/libjava/classpath/javax/management/openmbean/ArrayType.java b/libjava/classpath/javax/management/openmbean/ArrayType.java
index e6cf5261aaa..1a23f666f10 100644
--- a/libjava/classpath/javax/management/openmbean/ArrayType.java
+++ b/libjava/classpath/javax/management/openmbean/ArrayType.java
@@ -152,7 +152,7 @@ public class ArrayType<T>
throw new IllegalArgumentException("Dimensions must be greater " +
"than or equal to 1.");
if (elementType instanceof ArrayType)
- return dim + ((ArrayType) elementType).getDimension();
+ return dim + ((ArrayType<?>) elementType).getDimension();
return dim;
}
@@ -236,7 +236,7 @@ public class ArrayType<T>
private static final OpenType<?> getElementType(OpenType<?> elemType)
{
if (elemType instanceof ArrayType)
- return ((ArrayType) elemType).getElementOpenType();
+ return ((ArrayType<?>) elemType).getElementOpenType();
return elemType;
}
@@ -257,7 +257,7 @@ public class ArrayType<T>
{
OpenType<?> trueElemType = getElementType(elemType);
if (elemType instanceof ArrayType &&
- ((ArrayType) elemType).isPrimitiveArray())
+ ((ArrayType<?>) elemType).isPrimitiveArray())
return getPrimitiveTypeClass((SimpleType<?>) trueElemType).getName();
return trueElemType.getClassName();
}
@@ -323,7 +323,7 @@ public class ArrayType<T>
dimension = getDimensions(elementType, dim);
this.elementType = getElementType(elementType);
primitiveArray = (elementType instanceof ArrayType &&
- ((ArrayType) elementType).isPrimitiveArray());
+ ((ArrayType<?>) elementType).isPrimitiveArray());
}
/**
@@ -408,7 +408,7 @@ public class ArrayType<T>
{
if (!(obj instanceof ArrayType))
return false;
- ArrayType atype = (ArrayType) obj;
+ ArrayType<?> atype = (ArrayType<?>) obj;
return (atype.getDimension() == dimension &&
atype.getElementOpenType().equals(elementType) &&
atype.isPrimitiveArray() == primitiveArray);
@@ -439,13 +439,14 @@ public class ArrayType<T>
* is not in {@link OpenType#ALLOWED_CLASSNAMES_LIST}.
* @since 1.6
*/
+ @SuppressWarnings("unchecked")
public static <E> ArrayType<E[]> getArrayType(OpenType<E> elementType)
throws OpenDataException
{
ArrayType<E[]> arr = (ArrayType<E[]>) cache.get(elementType);
if (arr != null)
return arr;
- arr = new ArrayType(1, elementType);
+ arr = new ArrayType<E[]>(1, elementType);
cache.put(elementType, arr);
return arr;
}
@@ -484,6 +485,7 @@ public class ArrayType<T>
* array.
* @since 1.6
*/
+ @SuppressWarnings("unchecked")
public static <T> ArrayType<T> getPrimitiveArrayType(Class<T> type)
{
ArrayType<T> arr = (ArrayType<T>) primCache.get(type);
@@ -499,10 +501,9 @@ public class ArrayType<T>
throw new IllegalArgumentException("The given class is " +
"not an array.");
} while (comType.isArray());
- String className = type.getName();
try
{
- arr = new ArrayType(getPrimitiveType(comType), true);
+ arr = new ArrayType<T>(getPrimitiveType(comType), true);
}
catch (OpenDataException e)
{
@@ -512,7 +513,7 @@ public class ArrayType<T>
while (dim > 1)
try
{
- arr = new ArrayType(1, arr);
+ arr = new ArrayType<T>(1, arr);
--dim;
}
catch (OpenDataException e)
@@ -610,12 +611,12 @@ public class ArrayType<T>
{
if (obj == null)
return false;
- Class objClass = obj.getClass();
+ Class<?> objClass = obj.getClass();
if (!(objClass.isArray()))
return false;
if (elementType instanceof SimpleType)
return getClassName().equals(objClass.getName());
- Class elementClass = null;
+ Class<?> elementClass = null;
try
{
elementClass = Class.forName(getClassName());
diff --git a/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java b/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java
index d4c9d450c38..6bce2672d4f 100644
--- a/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java
+++ b/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java
@@ -154,7 +154,7 @@ public class CompositeDataSupport
throw new IllegalArgumentException("The values array is null.");
if (names.length != values.length)
throw new IllegalArgumentException("The sizes of the arrays differ.");
- Set typeKeys = type.keySet();
+ Set<String> typeKeys = type.keySet();
if (typeKeys.size() != names.length)
throw new OpenDataException("The number of field names does not match " +
"the type description.");
@@ -227,10 +227,8 @@ public class CompositeDataSupport
CompositeData data = (CompositeData) obj;
if (!(data.getCompositeType().equals(compositeType)))
return false;
- Iterator it = contents.keySet().iterator();
- while (it.hasNext())
+ for (String key : contents.keySet())
{
- String key = (String) it.next();
if (!(data.containsKey(key)))
return false;
if (!(data.get(key).equals(contents.get(key))))
@@ -308,9 +306,8 @@ public class CompositeDataSupport
public int hashCode()
{
int code = compositeType.hashCode();
- Iterator it = values().iterator();
- while (it.hasNext())
- code += it.next().hashCode();
+ for (Object o : contents.values())
+ code += o.hashCode();
return code;
}
diff --git a/libjava/classpath/javax/management/openmbean/CompositeType.java b/libjava/classpath/javax/management/openmbean/CompositeType.java
index 1a213f607c9..3244c6457c1 100644
--- a/libjava/classpath/javax/management/openmbean/CompositeType.java
+++ b/libjava/classpath/javax/management/openmbean/CompositeType.java
@@ -118,7 +118,7 @@ public class CompositeType
|| names.length != types.length)
throw new IllegalArgumentException("Arrays must be non-empty " +
"and of equal size.");
- nameToDescription = new TreeMap();
+ nameToDescription = new TreeMap<String,String>();
for (int a = 0; a < names.length; ++a)
{
if (names[a] == null)
@@ -243,10 +243,8 @@ public class CompositeType
if (hashCode == null)
{
int elementTotal = 0;
- Iterator it = nameToType.entrySet().iterator();
- while (it.hasNext())
+ for (Map.Entry<String,OpenType<?>> entry : nameToType.entrySet())
{
- Map.Entry entry = (Map.Entry) it.next();
elementTotal += (entry.getKey().hashCode() +
entry.getValue().hashCode());
}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
index 22667aadf7d..6da2e95e689 100644
--- a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
@@ -77,12 +77,12 @@ public class OpenMBeanAttributeInfoSupport
/**
* The minimum value of the attribute (may be <code>null</code>).
*/
- private Comparable<Object> minValue;
+ private Comparable<?> minValue;
/**
* The maximum value of the attribute (may be <code>null</code>).
*/
- private Comparable<Object> maxValue;
+ private Comparable<?> maxValue;
/**
* The hash code of this instance.
@@ -203,6 +203,7 @@ public class OpenMBeanAttributeInfoSupport
* the empty string.
* @throws OpenDataException if any condition in the list above is broken.
*/
+ @SuppressWarnings("unchecked")
public <T> OpenMBeanAttributeInfoSupport(String name, String desc, OpenType<T> type,
boolean isReadable, boolean isWritable,
boolean isIs, T defaultValue,
@@ -224,23 +225,23 @@ public class OpenMBeanAttributeInfoSupport
type instanceof TabularType))
throw new OpenDataException("Default values are not applicable for " +
"array or tabular types.");
- if (minValue != null && maxValue != null
- && minValue.compareTo(maxValue) > 0)
+ if (minimumValue != null && maximumValue != null
+ && minimumValue.compareTo((T) maximumValue) > 0)
throw new OpenDataException("The minimum value is greater than the " +
"maximum.");
- if (minValue != null && defaultValue != null
- && minValue.compareTo(defaultValue) > 0)
+ if (minimumValue != null && defaultValue != null
+ && minimumValue.compareTo(defaultValue) > 0)
throw new OpenDataException("The minimum value is greater than the " +
"default.");
- if (defaultValue != null && maxValue != null
- && maxValue.compareTo(defaultValue) < 0)
+ if (defaultValue != null && maximumValue != null
+ && maximumValue.compareTo(defaultValue) < 0)
throw new OpenDataException("The default value is greater than the " +
"maximum.");
openType = type;
this.defaultValue = defaultValue;
- minValue = (Comparable<Object>) minimumValue;
- maxValue = (Comparable<Object>) maximumValue;
+ minValue = minimumValue;
+ maxValue = maximumValue;
}
/**
@@ -300,7 +301,7 @@ public class OpenMBeanAttributeInfoSupport
"array or tabular types.");
if (legalValues != null && legalValues.length > 0)
{
- Set lv = new HashSet(legalValues.length);
+ Set<T> lv = new HashSet<T>(legalValues.length);
for (int a = 0; a < legalValues.length; ++a)
{
if (legalValues[a] != null &&
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java
index 5f8d55b8377..d67ff76a0f3 100644
--- a/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java
@@ -151,10 +151,10 @@ public class OpenMBeanInfoSupport
if (hashCode == null)
hashCode =
Integer.valueOf(getClassName().hashCode() +
- new HashSet(Arrays.asList(getAttributes())).hashCode() +
- new HashSet(Arrays.asList(getConstructors())).hashCode() +
- new HashSet(Arrays.asList(getNotifications())).hashCode() +
- new HashSet(Arrays.asList(getOperations())).hashCode());
+ new HashSet<MBeanAttributeInfo>(Arrays.asList(getAttributes())).hashCode() +
+ new HashSet<MBeanConstructorInfo>(Arrays.asList(getConstructors())).hashCode() +
+ new HashSet<MBeanNotificationInfo>(Arrays.asList(getNotifications())).hashCode() +
+ new HashSet<MBeanOperationInfo>(Arrays.asList(getOperations())).hashCode());
return hashCode.intValue();
}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
index 7fad2a13161..5f86bf4af96 100644
--- a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
@@ -78,12 +78,12 @@ public class OpenMBeanParameterInfoSupport
/**
* The minimum value of the parameter (may be <code>null</code>).
*/
- private Comparable<Object> minValue;
+ private Comparable<?> minValue;
/**
* The maximum value of the parameter (may be <code>null</code>).
*/
- private Comparable<Object> maxValue;
+ private Comparable<?> maxValue;
/**
* The hash code of this instance.
@@ -190,6 +190,7 @@ public class OpenMBeanParameterInfoSupport
* the empty string.
* @throws OpenDataException if any condition in the list above is broken.
*/
+ @SuppressWarnings("unchecked")
public <T> OpenMBeanParameterInfoSupport(String name, String desc, OpenType<T> type,
T defaultValue, Comparable<T> minimumValue,
Comparable<T> maximumValue)
@@ -209,22 +210,22 @@ public class OpenMBeanParameterInfoSupport
type instanceof TabularType))
throw new OpenDataException("Default values are not applicable for " +
"array or tabular types.");
- if (minValue != null && maxValue != null
- && minValue.compareTo(maxValue) > 0)
+ if (minimumValue != null && maximumValue != null
+ && minimumValue.compareTo((T) maximumValue) > 0)
throw new OpenDataException("The minimum value is greater than the " +
"maximum.");
- if (minValue != null && defaultValue != null
- && minValue.compareTo(defaultValue) > 0)
+ if (minimumValue != null && defaultValue != null
+ && minimumValue.compareTo(defaultValue) > 0)
throw new OpenDataException("The minimum value is greater than the " +
"default.");
- if (defaultValue != null && maxValue != null
- && maxValue.compareTo(defaultValue) < 0)
+ if (defaultValue != null && maximumValue != null
+ && maximumValue.compareTo(defaultValue) < 0)
throw new OpenDataException("The default value is greater than the " +
"maximum.");
this.defaultValue = defaultValue;
- minValue = (Comparable<Object>) minimumValue;
- maxValue = (Comparable<Object>) maximumValue;
+ minValue = minimumValue;
+ maxValue = maximumValue;
}
/**
@@ -279,7 +280,7 @@ public class OpenMBeanParameterInfoSupport
"array or tabular types.");
if (legalValues != null && legalValues.length > 0)
{
- Set lv = new HashSet(legalValues.length);
+ Set<T> lv = new HashSet<T>(legalValues.length);
for (int a = 0; a < legalValues.length; ++a)
{
if (legalValues[a] != null &&
diff --git a/libjava/classpath/javax/management/openmbean/SimpleType.java b/libjava/classpath/javax/management/openmbean/SimpleType.java
index fb3b1bc28b7..ef05e9dfe4f 100644
--- a/libjava/classpath/javax/management/openmbean/SimpleType.java
+++ b/libjava/classpath/javax/management/openmbean/SimpleType.java
@@ -232,7 +232,7 @@ public final class SimpleType<T>
{
if (!(obj instanceof SimpleType))
return false;
- SimpleType sType = (SimpleType) obj;
+ SimpleType<?> sType = (SimpleType<?>) obj;
return sType.getClassName().equals(getClassName());
}
diff --git a/libjava/classpath/javax/management/openmbean/TabularDataSupport.java b/libjava/classpath/javax/management/openmbean/TabularDataSupport.java
index 1d340e86f59..8557f5f2464 100644
--- a/libjava/classpath/javax/management/openmbean/TabularDataSupport.java
+++ b/libjava/classpath/javax/management/openmbean/TabularDataSupport.java
@@ -68,7 +68,7 @@ public class TabularDataSupport
*
* @serial the map of rows to column values.
*/
- private Map<Object,Object> dataMap;
+ private HashMap<Object,Object> dataMap;
/**
* The tabular type which represents this tabular data instance.
@@ -141,14 +141,10 @@ public class TabularDataSupport
throw new InvalidOpenTypeException("The type of the given value " +
"does not match the row type " +
"of this instance.");
- List indexNames = tabularType.getIndexNames();
- List matchingIndicies = new ArrayList(indexNames.size());
- Iterator it = indexNames.iterator();
- while (it.hasNext())
- {
- String name = (String) it.next();
- matchingIndicies.add(val.get(name));
- }
+ List<String> indexNames = tabularType.getIndexNames();
+ List<String> matchingIndicies = new ArrayList<String>(indexNames.size());
+ for (String name : indexNames)
+ matchingIndicies.add(val.get(name).toString());
return matchingIndicies.toArray();
}
@@ -167,13 +163,14 @@ public class TabularDataSupport
*
* @return a shallow clone of this {@link TabularDataSupport}.
*/
+ @SuppressWarnings("unchecked")
public Object clone()
{
TabularDataSupport clone = null;
try
{
clone = (TabularDataSupport) super.clone();
- clone.setMap((HashMap) ((HashMap) dataMap).clone());
+ clone.setMap((HashMap<Object,Object>) dataMap.clone());
}
catch (CloneNotSupportedException e)
{
@@ -390,11 +387,11 @@ public class TabularDataSupport
*/
private boolean isKeyValid(Object[] key)
{
- Iterator it = tabularType.getIndexNames().iterator();
+ Iterator<String> it = tabularType.getIndexNames().iterator();
CompositeType rowType = tabularType.getRowType();
for (int a = 0; it.hasNext(); ++a)
{
- OpenType type = rowType.getType((String) it.next());
+ OpenType<?> type = rowType.getType(it.next());
if (!(type.isValue(key[a])))
return false;
}
@@ -496,7 +493,7 @@ public class TabularDataSupport
{
if (vals == null || vals.length == 0)
return;
- Map mapToAdd = new HashMap(vals.length);
+ Map<Object,Object> mapToAdd = new HashMap<Object,Object>(vals.length);
for (int a = 0; a < vals.length; ++a)
{
Object[] key = calculateIndex(vals[a]);
@@ -539,9 +536,9 @@ public class TabularDataSupport
{
if (m == null || m.size() == 0)
return;
- Collection vals = m.values();
+ Collection<?> vals = m.values();
CompositeData[] data = new CompositeData[vals.size()];
- Iterator it = vals.iterator();
+ Iterator<?> it = vals.iterator();
for (int a = 0; it.hasNext(); ++a)
{
data[a] = (CompositeData) it.next();
@@ -591,12 +588,12 @@ public class TabularDataSupport
}
/**
- * Package-private method to set the internal {@link java.util.Map}
+ * Private method to set the internal {@link java.util.Map}
* instance (used in cloning).
*
* @param map the new map used.
*/
- void setMap(Map map)
+ private void setMap(HashMap<Object,Object> map)
{
dataMap = map;
}
diff --git a/libjava/classpath/javax/management/openmbean/TabularType.java b/libjava/classpath/javax/management/openmbean/TabularType.java
index 9a0881e0f92..5a861d061bd 100644
--- a/libjava/classpath/javax/management/openmbean/TabularType.java
+++ b/libjava/classpath/javax/management/openmbean/TabularType.java
@@ -206,9 +206,8 @@ public class TabularType
if (hashCode == null)
{
int elementTotal = 0;
- Iterator it = indexNames.iterator();
- while (it.hasNext())
- elementTotal += it.next().hashCode();
+ for (String s : indexNames)
+ elementTotal += s.hashCode();
hashCode = Integer.valueOf(elementTotal
+ getTypeName().hashCode()
+ rowType.hashCode());
diff --git a/libjava/classpath/javax/management/remote/rmi/RMIConnection.java b/libjava/classpath/javax/management/remote/rmi/RMIConnection.java
index 38fb544fe45..430f1c7dc97 100644
--- a/libjava/classpath/javax/management/remote/rmi/RMIConnection.java
+++ b/libjava/classpath/javax/management/remote/rmi/RMIConnection.java
@@ -152,6 +152,7 @@ public interface RMIConnection
* NotificationFilter,
* Object)
*/
+ @SuppressWarnings("unchecked")
void addNotificationListener(ObjectName name, ObjectName listener,
MarshalledObject filter, MarshalledObject passback,
Subject delegationSubject)
@@ -223,6 +224,7 @@ public interface RMIConnection
* NotificationFilter,
* Object)
*/
+ @SuppressWarnings("unchecked")
Integer[] addNotificationListeners(ObjectName[] names, MarshalledObject[] filters,
Subject[] delegationSubjects)
throws InstanceNotFoundException, IOException;
@@ -296,6 +298,7 @@ public interface RMIConnection
* @throws IOException if an I/O error occurred in communicating with
* the bean server.
*/
+ @SuppressWarnings("unchecked")
ObjectInstance createMBean(String className, ObjectName name,
MarshalledObject params, String[] sig,
Subject delegationSubject)
@@ -364,6 +367,7 @@ public interface RMIConnection
* @throws IOException if an I/O error occurred in communicating with
* the bean server.
*/
+ @SuppressWarnings("unchecked")
ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName, MarshalledObject params,
String[] sig, Subject delegationSubject)
@@ -763,6 +767,7 @@ public interface RMIConnection
* the bean server.
* @see DynamicMBean#invoke(String, Object[], String[])
*/
+ @SuppressWarnings("unchecked")
Object invoke(ObjectName bean, String name, MarshalledObject params,
String[] sig, Subject delegationSubject)
throws InstanceNotFoundException, MBeanException,
@@ -866,6 +871,7 @@ public interface RMIConnection
* @throws SecurityException if the client or delegated subject (if any) does
* not have permission to invoke this operation.
*/
+ @SuppressWarnings("unchecked")
Set<ObjectInstance> queryMBeans(ObjectName name, MarshalledObject query,
Subject delegationSubject)
throws IOException;
@@ -908,6 +914,7 @@ public interface RMIConnection
* @throws IOException if an I/O error occurred in communicating with
* the bean server.
*/
+ @SuppressWarnings("unchecked")
Set<ObjectName> queryNames(ObjectName name, MarshalledObject query,
Subject delegationSubject)
throws IOException;
@@ -953,6 +960,7 @@ public interface RMIConnection
* NotificationFilter,
* Object)
*/
+ @SuppressWarnings("unchecked")
void removeNotificationListener(ObjectName name,
ObjectName listener,
MarshalledObject filter,
@@ -1072,6 +1080,7 @@ public interface RMIConnection
* @see #getAttribute(ObjectName, String, Subject)
* @see javax.management.DynamicMBean#setAttribute(Attribute)
*/
+ @SuppressWarnings("unchecked")
void setAttribute(ObjectName name, MarshalledObject attribute,
Subject delegationSubject)
throws InstanceNotFoundException, AttributeNotFoundException,
@@ -1112,6 +1121,7 @@ public interface RMIConnection
* @see #getAttributes(ObjectName, String[])
* @see DynamicMBean#setAttributes(AttributeList)
*/
+ @SuppressWarnings("unchecked")
AttributeList setAttributes(ObjectName name, MarshalledObject attributes,
Subject delegationSubject)
throws InstanceNotFoundException, ReflectionException,
diff --git a/libjava/classpath/javax/naming/BinaryRefAddr.java b/libjava/classpath/javax/naming/BinaryRefAddr.java
index 0b813abc352..923c48e2368 100644
--- a/libjava/classpath/javax/naming/BinaryRefAddr.java
+++ b/libjava/classpath/javax/naming/BinaryRefAddr.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.naming;
+import gnu.java.lang.CPStringBuilder;
+
import java.util.Arrays;
/**
@@ -139,7 +141,7 @@ public class BinaryRefAddr extends RefAddr
*/
public String toString()
{
- StringBuffer sb = new StringBuffer("[RefAddr type: ");
+ CPStringBuilder sb = new CPStringBuilder("[RefAddr type: ");
sb.append(getType());
sb.append(" content: 0x");
byte[] b = (byte[]) getContent();
diff --git a/libjava/classpath/javax/naming/CompositeName.java b/libjava/classpath/javax/naming/CompositeName.java
index 7227f9d78e4..4593bae631a 100644
--- a/libjava/classpath/javax/naming/CompositeName.java
+++ b/libjava/classpath/javax/naming/CompositeName.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.naming;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -85,7 +87,7 @@ public class CompositeName implements Name, Cloneable, Serializable
final char no_quote = 'x'; // Use 'x' to mean no quoting.
char quote = no_quote;
boolean escaped = false;
- StringBuffer new_element = new StringBuffer ();
+ StringBuilder new_element = new StringBuilder ();
for (int i = 0; i < n.length (); ++i)
{
char c = n.charAt (i);
@@ -294,7 +296,7 @@ public class CompositeName implements Name, Cloneable, Serializable
public String toString ()
{
- StringBuffer result = new StringBuffer ();
+ CPStringBuilder result = new CPStringBuilder ();
for (int i = 0; i < elts.size (); ++i)
{
// For simplicity we choose to always quote using escapes and
diff --git a/libjava/classpath/javax/naming/CompoundName.java b/libjava/classpath/javax/naming/CompoundName.java
index f345d3efd50..26b44c16fdb 100644
--- a/libjava/classpath/javax/naming/CompoundName.java
+++ b/libjava/classpath/javax/naming/CompoundName.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.naming;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -95,7 +97,7 @@ public class CompoundName implements Name, Cloneable, Serializable
mySyntax = syntax;
initializeSyntax ();
- StringBuffer new_element = new StringBuffer ();
+ StringBuilder new_element = new StringBuilder ();
int i = 0;
// QUOTE==null means no quoting right now. When it is set it is
// the value of the closing quote.
@@ -376,7 +378,7 @@ public class CompoundName implements Name, Cloneable, Serializable
public String toString ()
{
- StringBuffer result = new StringBuffer ();
+ CPStringBuilder result = new CPStringBuilder ();
int size = elts.size ();
for (int i = 0; i < size; ++i)
{
diff --git a/libjava/classpath/javax/naming/NamingException.java b/libjava/classpath/javax/naming/NamingException.java
index dbe1e3792a7..7a5c35eb57b 100644
--- a/libjava/classpath/javax/naming/NamingException.java
+++ b/libjava/classpath/javax/naming/NamingException.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.naming;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -237,7 +239,7 @@ public class NamingException extends Exception
*/
public String toString(boolean objectInfo)
{
- StringBuffer sb = new StringBuffer(super.toString());
+ CPStringBuilder sb = new CPStringBuilder(super.toString());
Throwable cause = getRootCause();
if (cause != null)
{
diff --git a/libjava/classpath/javax/naming/spi/NamingManager.java b/libjava/classpath/javax/naming/spi/NamingManager.java
index 3dfba0f668d..cc8d46fa497 100644
--- a/libjava/classpath/javax/naming/spi/NamingManager.java
+++ b/libjava/classpath/javax/naming/spi/NamingManager.java
@@ -41,6 +41,8 @@ package javax.naming.spi;
import gnu.classpath.VMStackWalker;
+import gnu.java.lang.CPStringBuilder;
+
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.StringTokenizer;
@@ -197,7 +199,7 @@ public class NamingManager
// The final default location, as specified in the documentation.
String finalPrefix = "com.sun.jndi.url";
- StringBuffer allPrefixes = new StringBuffer();
+ CPStringBuilder allPrefixes = new CPStringBuilder();
String prefixes;
if (environment != null)
diff --git a/libjava/classpath/javax/security/auth/x500/X500Principal.java b/libjava/classpath/javax/security/auth/x500/X500Principal.java
index d78b0d3eec4..0a1e8c66518 100644
--- a/libjava/classpath/javax/security/auth/x500/X500Principal.java
+++ b/libjava/classpath/javax/security/auth/x500/X500Principal.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.security.auth.x500;
+import gnu.java.lang.CPStringBuilder;
+
import gnu.java.security.OID;
import gnu.java.security.der.DER;
import gnu.java.security.der.DERReader;
@@ -200,7 +202,7 @@ public final class X500Principal implements Principal, Serializable
boolean canon = CANONICAL.equalsIgnoreCase (format);
if (! (rfc2253 || rfc1779 || canon))
throw new IllegalArgumentException ("unsupported format " + format);
- StringBuffer str = new StringBuffer();
+ CPStringBuilder str = new CPStringBuilder();
for (Iterator it = components.iterator(); it.hasNext(); )
{
Map m = (Map) it.next();
@@ -323,7 +325,7 @@ public final class X500Principal implements Principal, Serializable
private String readAttributeType(Reader in) throws IOException
{
- StringBuffer buf = new StringBuffer();
+ CPStringBuilder buf = new CPStringBuilder();
int ch;
while ((ch = in.read()) != '=')
{
@@ -345,7 +347,7 @@ public final class X500Principal implements Principal, Serializable
private String readAttributeValue(Reader in) throws IOException
{
- StringBuffer buf = new StringBuffer();
+ CPStringBuilder buf = new CPStringBuilder();
int ch = in.read();
if (ch == '#')
{
@@ -518,7 +520,7 @@ public final class X500Principal implements Principal, Serializable
private static String compressWS(String str)
{
- StringBuffer buf = new StringBuffer();
+ CPStringBuilder buf = new CPStringBuilder();
char lastChar = 0;
for (int i = 0; i < str.length(); i++)
{
diff --git a/libjava/classpath/javax/security/sasl/SaslException.java b/libjava/classpath/javax/security/sasl/SaslException.java
index 89764bb18f0..f4407e761e6 100644
--- a/libjava/classpath/javax/security/sasl/SaslException.java
+++ b/libjava/classpath/javax/security/sasl/SaslException.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.security.sasl;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -178,7 +180,7 @@ public class SaslException extends IOException implements Serializable
*/
public String toString()
{
- StringBuffer sb = new StringBuffer(this.getClass().getName())
+ CPStringBuilder sb = new CPStringBuilder(this.getClass().getName())
.append(": ").append(super.toString());
if (_exception != null)
sb.append("; caused by: ").append(_exception.toString());
diff --git a/libjava/classpath/javax/sound/sampled/AudioFormat.java b/libjava/classpath/javax/sound/sampled/AudioFormat.java
index 7b6ebc4b03b..1f31c9929d1 100644
--- a/libjava/classpath/javax/sound/sampled/AudioFormat.java
+++ b/libjava/classpath/javax/sound/sampled/AudioFormat.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.sound.sampled;
+import gnu.java.lang.CPStringBuilder;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -329,7 +331,7 @@ public class AudioFormat
*/
public String toString()
{
- StringBuffer result = new StringBuffer();
+ CPStringBuilder result = new CPStringBuilder();
// usually at least encoding should be somewhat specified
result.append(encoding);
diff --git a/libjava/classpath/javax/sound/sampled/CompoundControl.java b/libjava/classpath/javax/sound/sampled/CompoundControl.java
index 057bdfd7248..556c805ad3b 100644
--- a/libjava/classpath/javax/sound/sampled/CompoundControl.java
+++ b/libjava/classpath/javax/sound/sampled/CompoundControl.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.sound.sampled;
+import gnu.java.lang.CPStringBuilder;
+
/**
* A compound control provides control over several other controls.
* @since 1.3
@@ -88,7 +90,7 @@ public abstract class CompoundControl extends Control
*/
public String toString()
{
- StringBuffer result = new StringBuffer();
+ CPStringBuilder result = new CPStringBuilder();
result.append(super.toString());
result.append(": ");
for (int i = 0; i < memberControls.length; ++i)
diff --git a/libjava/classpath/javax/sound/sampled/DataLine.java b/libjava/classpath/javax/sound/sampled/DataLine.java
index b7cb70e4931..4482c9885db 100644
--- a/libjava/classpath/javax/sound/sampled/DataLine.java
+++ b/libjava/classpath/javax/sound/sampled/DataLine.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.sound.sampled;
+import gnu.java.lang.CPStringBuilder;
+
/**
* The DataLine interface adds data-related functionality to the Line
* interface. For example, it adds methods to start and stop the data
@@ -180,7 +182,7 @@ public interface DataLine extends Line
*/
public String toString()
{
- StringBuffer result = new StringBuffer();
+ CPStringBuilder result = new CPStringBuilder();
result.append("formats: [");
for (int i = 0; i < formats.length; ++i)
{
diff --git a/libjava/classpath/javax/swing/AbstractButton.java b/libjava/classpath/javax/swing/AbstractButton.java
index cb0f458b89f..8764f6f8c3d 100644
--- a/libjava/classpath/javax/swing/AbstractButton.java
+++ b/libjava/classpath/javax/swing/AbstractButton.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
@@ -2445,7 +2447,7 @@ public abstract class AbstractButton extends JComponent
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer();
+ CPStringBuilder sb = new CPStringBuilder();
sb.append(super.paramString());
sb.append(",defaultIcon=");
if (getIcon() != null)
diff --git a/libjava/classpath/javax/swing/JButton.java b/libjava/classpath/javax/swing/JButton.java
index 878cfa68397..705a8638105 100644
--- a/libjava/classpath/javax/swing/JButton.java
+++ b/libjava/classpath/javax/swing/JButton.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
@@ -225,7 +227,7 @@ public class JButton extends AbstractButton
String superParam = super.paramString();
// 41 is the maximum number of chars which may be needed.
- StringBuffer sb = new StringBuffer(41);
+ CPStringBuilder sb = new CPStringBuilder(41);
sb.append(",defaultButton=").append(isDefaultButton());
sb.append(",defaultCapable=").append(defaultCapable);
diff --git a/libjava/classpath/javax/swing/JComboBox.java b/libjava/classpath/javax/swing/JComboBox.java
index fa6941cf977..74ff315eab7 100644
--- a/libjava/classpath/javax/swing/JComboBox.java
+++ b/libjava/classpath/javax/swing/JComboBox.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.ItemSelectable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -1104,7 +1106,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
protected String paramString()
{
String superParamStr = super.paramString();
- StringBuffer sb = new StringBuffer();
+ CPStringBuilder sb = new CPStringBuilder();
sb.append(",isEditable=").append(isEditable());
sb.append(",lightWeightPopupEnabled=").append(isLightWeightPopupEnabled());
sb.append(",maximumRowCount=").append(getMaximumRowCount());
diff --git a/libjava/classpath/javax/swing/JComponent.java b/libjava/classpath/javax/swing/JComponent.java
index a22a92e3b06..f71217867bc 100644
--- a/libjava/classpath/javax/swing/JComponent.java
+++ b/libjava/classpath/javax/swing/JComponent.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.applet.Applet;
import java.awt.AWTEvent;
import java.awt.Color;
@@ -2405,7 +2407,7 @@ public abstract class JComponent extends Container implements Serializable
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer();
+ CPStringBuilder sb = new CPStringBuilder();
sb.append(super.paramString());
sb.append(",alignmentX=").append(getAlignmentX());
sb.append(",alignmentY=").append(getAlignmentY());
diff --git a/libjava/classpath/javax/swing/JDesktopPane.java b/libjava/classpath/javax/swing/JDesktopPane.java
index 454870ea6fc..b068a2998a5 100644
--- a/libjava/classpath/javax/swing/JDesktopPane.java
+++ b/libjava/classpath/javax/swing/JDesktopPane.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Component;
import java.beans.PropertyVetoException;
@@ -306,7 +308,7 @@ public class JDesktopPane extends JLayeredPane implements Accessible
protected String paramString()
{
String superParamStr = super.paramString();
- StringBuffer sb = new StringBuffer();
+ CPStringBuilder sb = new CPStringBuilder();
sb.append(",isOptimizedDrawingPossible=");
sb.append(isOptimizedDrawingEnabled());
sb.append(",desktopManager=");
diff --git a/libjava/classpath/javax/swing/JFileChooser.java b/libjava/classpath/javax/swing/JFileChooser.java
index a508b8fcb20..b7615a58d0e 100644
--- a/libjava/classpath/javax/swing/JFileChooser.java
+++ b/libjava/classpath/javax/swing/JFileChooser.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Component;
import java.awt.Frame;
import java.awt.GraphicsEnvironment;
@@ -1543,7 +1545,7 @@ public class JFileChooser extends JComponent implements Accessible
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer(super.paramString());
+ CPStringBuilder sb = new CPStringBuilder(super.paramString());
sb.append(",approveButtonText=");
if (approveButtonText != null)
sb.append(approveButtonText);
diff --git a/libjava/classpath/javax/swing/JFrame.java b/libjava/classpath/javax/swing/JFrame.java
index e54d453b8df..0c956b3969e 100644
--- a/libjava/classpath/javax/swing/JFrame.java
+++ b/libjava/classpath/javax/swing/JFrame.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Component;
@@ -341,7 +343,7 @@ public class JFrame extends Frame
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer(super.paramString());
+ CPStringBuilder sb = new CPStringBuilder(super.paramString());
sb.append(",defaultCloseOperation=");
sb.append(SwingUtilities.convertWindowConstantToString(
getDefaultCloseOperation()));
diff --git a/libjava/classpath/javax/swing/JLabel.java b/libjava/classpath/javax/swing/JLabel.java
index 721287b21df..2bbd1ee5f8c 100644
--- a/libjava/classpath/javax/swing/JLabel.java
+++ b/libjava/classpath/javax/swing/JLabel.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Component;
import java.awt.Font;
import java.awt.FontMetrics;
@@ -555,7 +557,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer(super.paramString());
+ CPStringBuilder sb = new CPStringBuilder(super.paramString());
sb.append(",defaultIcon=");
if (icon != null)
sb.append(icon);
diff --git a/libjava/classpath/javax/swing/JList.java b/libjava/classpath/javax/swing/JList.java
index ff1b239217a..bd744064c39 100644
--- a/libjava/classpath/javax/swing/JList.java
+++ b/libjava/classpath/javax/swing/JList.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Color;
import java.awt.Component;
import java.awt.ComponentOrientation;
@@ -2481,7 +2483,7 @@ public class JList extends JComponent implements Accessible, Scrollable
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer(super.paramString());
+ CPStringBuilder sb = new CPStringBuilder(super.paramString());
sb.append(",fixedCellHeight=").append(getFixedCellHeight());
sb.append(",fixedCellWidth=").append(getFixedCellWidth());
sb.append(",selectionBackground=");
diff --git a/libjava/classpath/javax/swing/JMenuBar.java b/libjava/classpath/javax/swing/JMenuBar.java
index 73b409e42db..030fc4cb87d 100644
--- a/libjava/classpath/javax/swing/JMenuBar.java
+++ b/libjava/classpath/javax/swing/JMenuBar.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
@@ -481,7 +483,7 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer();
+ CPStringBuilder sb = new CPStringBuilder();
sb.append(super.paramString());
sb.append(",margin=");
if (getMargin() != null)
diff --git a/libjava/classpath/javax/swing/JPopupMenu.java b/libjava/classpath/javax/swing/JPopupMenu.java
index 1ae8adad02a..ac1a9ebf253 100644
--- a/libjava/classpath/javax/swing/JPopupMenu.java
+++ b/libjava/classpath/javax/swing/JPopupMenu.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
@@ -767,7 +769,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer();
+ CPStringBuilder sb = new CPStringBuilder();
sb.append(super.paramString());
sb.append(",label=");
if (getLabel() != null)
diff --git a/libjava/classpath/javax/swing/JProgressBar.java b/libjava/classpath/javax/swing/JProgressBar.java
index ed2d0088d06..b20b02a0606 100644
--- a/libjava/classpath/javax/swing/JProgressBar.java
+++ b/libjava/classpath/javax/swing/JProgressBar.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Graphics;
import java.beans.PropertyChangeEvent;
@@ -786,7 +788,7 @@ public class JProgressBar extends JComponent implements SwingConstants,
protected String paramString()
{
String superParamStr = super.paramString();
- StringBuffer sb = new StringBuffer();
+ CPStringBuilder sb = new CPStringBuilder();
sb.append(",orientation=");
if (orientation == HORIZONTAL)
sb.append("HORIZONTAL");
diff --git a/libjava/classpath/javax/swing/JScrollBar.java b/libjava/classpath/javax/swing/JScrollBar.java
index f55feb3f22a..371bb60c65e 100644
--- a/libjava/classpath/javax/swing/JScrollBar.java
+++ b/libjava/classpath/javax/swing/JScrollBar.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Adjustable;
import java.awt.Dimension;
import java.awt.event.AdjustmentEvent;
@@ -671,7 +673,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer(super.paramString());
+ CPStringBuilder sb = new CPStringBuilder(super.paramString());
sb.append(",blockIncrement=").append(blockIncrement);
sb.append(",orientation=");
if (this.orientation == JScrollBar.HORIZONTAL)
diff --git a/libjava/classpath/javax/swing/JSlider.java b/libjava/classpath/javax/swing/JSlider.java
index 948a9629b4c..979707a7264 100644
--- a/libjava/classpath/javax/swing/JSlider.java
+++ b/libjava/classpath/javax/swing/JSlider.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.MenuContainer;
import java.awt.image.ImageObserver;
import java.beans.PropertyChangeEvent;
@@ -1104,7 +1106,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
protected String paramString()
{
String superParamStr = super.paramString();
- StringBuffer sb = new StringBuffer();
+ CPStringBuilder sb = new CPStringBuilder();
sb.append(",isInverted=").append(getInverted());
sb.append(",majorTickSpacing=").append(getMajorTickSpacing());
sb.append(",minorTickSpacing=").append(getMinorTickSpacing());
diff --git a/libjava/classpath/javax/swing/JSplitPane.java b/libjava/classpath/javax/swing/JSplitPane.java
index fcdc1c04128..5b6ec158e6d 100644
--- a/libjava/classpath/javax/swing/JSplitPane.java
+++ b/libjava/classpath/javax/swing/JSplitPane.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Component;
import java.awt.Graphics;
import java.beans.PropertyChangeEvent;
@@ -597,7 +599,7 @@ public class JSplitPane extends JComponent implements Accessible
{
// FIXME: the next line can be restored once PR27208 is fixed
String superParamStr = ""; //super.paramString();
- StringBuffer sb = new StringBuffer();
+ CPStringBuilder sb = new CPStringBuilder();
sb.append(",continuousLayout=").append(isContinuousLayout());
sb.append(",dividerSize=").append(getDividerSize());
sb.append(",lastDividerLocation=").append(getLastDividerLocation());
diff --git a/libjava/classpath/javax/swing/JTabbedPane.java b/libjava/classpath/javax/swing/JTabbedPane.java
index c7244bf2b71..79521be3fec 100644
--- a/libjava/classpath/javax/swing/JTabbedPane.java
+++ b/libjava/classpath/javax/swing/JTabbedPane.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Color;
import java.awt.Component;
import java.awt.Point;
@@ -1692,7 +1694,7 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer(super.paramString());
+ CPStringBuilder sb = new CPStringBuilder(super.paramString());
sb.append(",tabPlacement=");
if (tabPlacement == TOP)
sb.append("TOP");
diff --git a/libjava/classpath/javax/swing/JToolBar.java b/libjava/classpath/javax/swing/JToolBar.java
index fe4d2ae2046..33ebcfcaf89 100644
--- a/libjava/classpath/javax/swing/JToolBar.java
+++ b/libjava/classpath/javax/swing/JToolBar.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
@@ -766,7 +768,7 @@ public class JToolBar extends JComponent implements SwingConstants, Accessible
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer(super.paramString());
+ CPStringBuilder sb = new CPStringBuilder(super.paramString());
sb.append(",floatable=").append(floatable);
sb.append(",margin=");
if (margin != null)
diff --git a/libjava/classpath/javax/swing/JToolTip.java b/libjava/classpath/javax/swing/JToolTip.java
index 16bdd2d7e73..f59ec95fba4 100644
--- a/libjava/classpath/javax/swing/JToolTip.java
+++ b/libjava/classpath/javax/swing/JToolTip.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.AWTEvent;
import java.beans.PropertyChangeEvent;
@@ -179,7 +181,7 @@ public class JToolTip extends JComponent implements Accessible
*/
protected String paramString()
{
- StringBuffer sb = new StringBuffer(super.paramString());
+ CPStringBuilder sb = new CPStringBuilder(super.paramString());
sb.append(",tiptext=");
if (text != null)
sb.append(text);
diff --git a/libjava/classpath/javax/swing/UIManager.java b/libjava/classpath/javax/swing/UIManager.java
index 3b1b3f72b38..0369b6514ae 100644
--- a/libjava/classpath/javax/swing/UIManager.java
+++ b/libjava/classpath/javax/swing/UIManager.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
@@ -107,7 +109,7 @@ public class UIManager implements Serializable
*/
public String toString()
{
- StringBuffer s = new StringBuffer();
+ CPStringBuilder s = new CPStringBuilder();
s.append(getClass().getName());
s.append('[');
s.append(getName());
diff --git a/libjava/classpath/javax/swing/event/EventListenerList.java b/libjava/classpath/javax/swing/event/EventListenerList.java
index 1568039f0ff..8c76f7f87e6 100644
--- a/libjava/classpath/javax/swing/event/EventListenerList.java
+++ b/libjava/classpath/javax/swing/event/EventListenerList.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing.event;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -295,7 +297,7 @@ public class EventListenerList
*/
public String toString()
{
- StringBuffer buf = new StringBuffer("EventListenerList: ");
+ CPStringBuilder buf = new CPStringBuilder("EventListenerList: ");
buf.append(listenerList.length / 2);
buf.append(" listeners: ");
for (int i = 0; i < listenerList.length; i += 2)
diff --git a/libjava/classpath/javax/swing/table/AbstractTableModel.java b/libjava/classpath/javax/swing/table/AbstractTableModel.java
index 66b6a0743b6..743e5d4dc21 100644
--- a/libjava/classpath/javax/swing/table/AbstractTableModel.java
+++ b/libjava/classpath/javax/swing/table/AbstractTableModel.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.table;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.Serializable;
import java.util.EventListener;
@@ -80,7 +82,7 @@ public abstract class AbstractTableModel implements TableModel, Serializable
*/
public String getColumnName(int columnIndex)
{
- StringBuffer buffer = new StringBuffer();
+ CPStringBuilder buffer = new CPStringBuilder();
while (columnIndex >= 0)
{
buffer.insert(0, (char) ('A' + columnIndex % 26));
diff --git a/libjava/classpath/javax/swing/text/AbstractDocument.java b/libjava/classpath/javax/swing/text/AbstractDocument.java
index 72178f840f3..29b20b321fb 100644
--- a/libjava/classpath/javax/swing/text/AbstractDocument.java
+++ b/libjava/classpath/javax/swing/text/AbstractDocument.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.text;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.font.TextAttribute;
import java.io.PrintStream;
import java.io.Serializable;
@@ -2013,7 +2015,7 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public void dump(PrintStream stream, int indent)
{
- StringBuffer b = new StringBuffer();
+ CPStringBuilder b = new CPStringBuilder();
for (int i = 0; i < indent; ++i)
b.append(' ');
b.append('<');
diff --git a/libjava/classpath/javax/swing/text/DefaultEditorKit.java b/libjava/classpath/javax/swing/text/DefaultEditorKit.java
index aa69deca545..0d999a38096 100644
--- a/libjava/classpath/javax/swing/text/DefaultEditorKit.java
+++ b/libjava/classpath/javax/swing/text/DefaultEditorKit.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.text;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
@@ -1634,7 +1636,7 @@ public class DefaultEditorKit extends EditorKit
BufferedReader reader = new BufferedReader(in);
String line;
- StringBuffer content = new StringBuffer();
+ CPStringBuilder content = new CPStringBuilder();
while ((line = reader.readLine()) != null)
{
diff --git a/libjava/classpath/javax/swing/text/DefaultStyledDocument.java b/libjava/classpath/javax/swing/text/DefaultStyledDocument.java
index 341579e3df8..8c70a8a3bfd 100644
--- a/libjava/classpath/javax/swing/text/DefaultStyledDocument.java
+++ b/libjava/classpath/javax/swing/text/DefaultStyledDocument.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.text;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.Color;
import java.awt.Font;
import java.io.Serializable;
@@ -374,7 +376,7 @@ public class DefaultStyledDocument extends AbstractDocument implements
*/
public String toString()
{
- StringBuilder b = new StringBuilder();
+ CPStringBuilder b = new CPStringBuilder();
switch (type)
{
case StartTagType:
@@ -2420,7 +2422,7 @@ public class DefaultStyledDocument extends AbstractDocument implements
writeLock();
// First we collect the content to be inserted.
- StringBuffer contentBuffer = new StringBuffer();
+ CPStringBuilder contentBuffer = new CPStringBuilder();
for (int i = 0; i < data.length; i++)
{
// Collect all inserts into one so we can get the correct
diff --git a/libjava/classpath/javax/swing/text/JTextComponent.java b/libjava/classpath/javax/swing/text/JTextComponent.java
index 8e70fe2bb2b..24035e35ac2 100644
--- a/libjava/classpath/javax/swing/text/JTextComponent.java
+++ b/libjava/classpath/javax/swing/text/JTextComponent.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.text;
+import gnu.java.lang.CPStringBuilder;
+
import java.awt.AWTEvent;
import java.awt.Color;
import java.awt.Container;
@@ -2016,7 +2018,7 @@ public abstract class JTextComponent extends JComponent
d.putProperty(Document.StreamDescriptionProperty, streamDescription);
}
- StringBuffer b = new StringBuffer();
+ CPStringBuilder b = new CPStringBuilder();
int c;
// Read till -1 (EOF).
diff --git a/libjava/classpath/javax/swing/text/MaskFormatter.java b/libjava/classpath/javax/swing/text/MaskFormatter.java
index 581cceb617d..4ebf65b9332 100644
--- a/libjava/classpath/javax/swing/text/MaskFormatter.java
+++ b/libjava/classpath/javax/swing/text/MaskFormatter.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.text;
+import gnu.java.lang.CPStringBuilder;
+
import java.text.ParseException;
import javax.swing.JFormattedTextField;
@@ -311,7 +313,7 @@ public class MaskFormatter extends DefaultFormatter
private String convertStringToValue(String value)
throws ParseException
{
- StringBuffer result = new StringBuffer();
+ CPStringBuilder result = new CPStringBuilder();
char valueChar;
boolean isPlaceHolder;
@@ -447,7 +449,7 @@ public class MaskFormatter extends DefaultFormatter
private String convertValueToString(String value)
throws ParseException
{
- StringBuffer result = new StringBuffer();
+ CPStringBuilder result = new CPStringBuilder();
char valueChar;
boolean isPlaceHolder;
diff --git a/libjava/classpath/javax/swing/text/TabSet.java b/libjava/classpath/javax/swing/text/TabSet.java
index 0f2c8c7c1ee..c08a650fb11 100644
--- a/libjava/classpath/javax/swing/text/TabSet.java
+++ b/libjava/classpath/javax/swing/text/TabSet.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing.text;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.Serializable;
/**
@@ -194,7 +196,7 @@ public class TabSet implements Serializable
*/
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ CPStringBuilder sb = new CPStringBuilder();
sb.append("[ ");
for (int i = 0; i < tabs.length; ++i)
{
diff --git a/libjava/classpath/javax/swing/text/html/CSSParser.java b/libjava/classpath/javax/swing/text/html/CSSParser.java
index 54a16bcc599..d49ac3a6fc9 100644
--- a/libjava/classpath/javax/swing/text/html/CSSParser.java
+++ b/libjava/classpath/javax/swing/text/html/CSSParser.java
@@ -163,11 +163,6 @@ class CSSParser
private int pushedChar;
/**
- * Temporary place to hold identifiers.
- */
- private StringBuffer unitBuffer;
-
- /**
* Used to indicate blocks.
*/
private int[] unitStack;
@@ -212,7 +207,6 @@ class CSSParser
*/
CSSParser()
{
- unitBuffer = new StringBuffer();
tokenBuffer = new char[10];
}
diff --git a/libjava/classpath/javax/swing/text/html/HTMLWriter.java b/libjava/classpath/javax/swing/text/html/HTMLWriter.java
index 44119c73286..6cc23df9aab 100644
--- a/libjava/classpath/javax/swing/text/html/HTMLWriter.java
+++ b/libjava/classpath/javax/swing/text/html/HTMLWriter.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing.text.html;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.IOException;
import java.io.Writer;
@@ -574,7 +576,7 @@ public class HTMLWriter
protected void output(char[] chars, int off, int len)
throws IOException
{
- StringBuffer strBuffer = new StringBuffer();
+ CPStringBuilder strBuffer = new CPStringBuilder();
for (int i = 0; i < chars.length; i++)
{
@@ -1081,4 +1083,4 @@ public class HTMLWriter
return ret_str;
} // private String escapeCharHtmlEntity(char param_char)
-} // public class HTMLWriter extends AbstractWriter \ No newline at end of file
+} // public class HTMLWriter extends AbstractWriter
diff --git a/libjava/classpath/javax/swing/text/html/StyleSheet.java b/libjava/classpath/javax/swing/text/html/StyleSheet.java
index 01f19fd7bdd..08578c80fad 100644
--- a/libjava/classpath/javax/swing/text/html/StyleSheet.java
+++ b/libjava/classpath/javax/swing/text/html/StyleSheet.java
@@ -182,7 +182,7 @@ public class StyleSheet extends StyleContext
*/
private class CSSStyle
extends SimpleAttributeSet
- implements Style, Comparable
+ implements Style, Comparable<CSSStyle>
{
static final int PREC_UA = 0;
@@ -229,9 +229,8 @@ public class StyleSheet extends StyleContext
* Sorts the rule according to the style's precedence and the
* selectors specificity.
*/
- public int compareTo(Object o)
+ public int compareTo(CSSStyle other)
{
- CSSStyle other = (CSSStyle) o;
return other.precedence + other.selector.getSpecificity()
- precedence - selector.getSpecificity();
}
@@ -247,18 +246,18 @@ public class StyleSheet extends StyleContext
/**
* The linked style sheets stored.
*/
- private ArrayList linked;
+ private ArrayList<StyleSheet> linked;
/**
* Maps element names (selectors) to AttributSet (the corresponding style
* information).
*/
- ArrayList css = new ArrayList();
+ ArrayList<CSSStyle> css = new ArrayList<CSSStyle>();
/**
* Maps selectors to their resolved styles.
*/
- private HashMap resolvedStyles;
+ private HashMap<String,Style> resolvedStyles;
/**
* Constructs a StyleSheet.
@@ -267,7 +266,7 @@ public class StyleSheet extends StyleContext
{
super();
baseFontSize = 4; // Default font size from CSS
- resolvedStyles = new HashMap();
+ resolvedStyles = new HashMap<String,Style>();
}
/**
@@ -283,7 +282,7 @@ public class StyleSheet extends StyleContext
{
// Create list of the element and all of its parents, starting
// with the bottommost element.
- ArrayList path = new ArrayList();
+ ArrayList<Element> path = new ArrayList<Element>();
Element el;
AttributeSet atts;
for (el = e; el != null; el = el.getParentElement())
@@ -295,7 +294,7 @@ public class StyleSheet extends StyleContext
// We append the actual element after this loop.
for (int i = count - 1; i > 0; i--)
{
- el = (Element) path.get(i);
+ el = path.get(i);
atts = el.getAttributes();
Object name = atts.getAttribute(StyleConstants.NameAttribute);
selector.append(name.toString());
@@ -322,7 +321,7 @@ public class StyleSheet extends StyleContext
selector.append(' ');
}
selector.append(t.toString());
- el = (Element) path.get(0);
+ el = path.get(0);
atts = el.getAttributes();
// For leaf elements, we have to fetch the tag specific attributes.
if (el.isLeaf())
@@ -372,7 +371,7 @@ public class StyleSheet extends StyleContext
*/
private Style getResolvedStyle(String selector, List path, HTML.Tag tag)
{
- Style style = (Style) resolvedStyles.get(selector);
+ Style style = resolvedStyles.get(selector);
if (style == null)
style = resolveStyle(selector, path, tag);
return style;
@@ -439,11 +438,9 @@ public class StyleSheet extends StyleContext
{
// FIXME: This style resolver is not correct. But it works good enough for
// the default.css.
- int count = tags.length;
- ArrayList styles = new ArrayList();
- for (Iterator i = css.iterator(); i.hasNext();)
+ ArrayList<CSSStyle> styles = new ArrayList<CSSStyle>();
+ for (CSSStyle style : css)
{
- CSSStyle style = (CSSStyle) i.next();
if (style.selector.matches(tags, attributes))
styles.add(style);
}
@@ -453,10 +450,10 @@ public class StyleSheet extends StyleContext
{
for (int i = linked.size() - 1; i >= 0; i--)
{
- StyleSheet ss = (StyleSheet) linked.get(i);
+ StyleSheet ss = linked.get(i);
for (int j = ss.css.size() - 1; j >= 0; j--)
{
- CSSStyle style = (CSSStyle) ss.css.get(j);
+ CSSStyle style = ss.css.get(j);
if (style.selector.matches(tags, attributes))
styles.add(style);
}
@@ -615,7 +612,7 @@ public class StyleSheet extends StyleContext
if (linked != null)
{
linkedSS = new StyleSheet[linked.size()];
- linkedSS = (StyleSheet[]) linked.toArray(linkedSS);
+ linkedSS = linked.toArray(linkedSS);
}
else
{
@@ -1074,7 +1071,7 @@ public class StyleSheet extends StyleContext
*/
public void setBaseFontSize(String size)
{
- size.trim();
+ size = size.trim();
int temp = 0;
try
{
@@ -1446,8 +1443,8 @@ public class StyleSheet extends StyleContext
*/
private Map attributeSetToMap(AttributeSet atts)
{
- HashMap map = new HashMap();
- Enumeration keys = atts.getAttributeNames();
+ HashMap<String,String> map = new HashMap<String,String>();
+ Enumeration<?> keys = atts.getAttributeNames();
while (keys.hasMoreElements())
{
Object key = keys.nextElement();
diff --git a/libjava/classpath/javax/swing/text/html/ViewAttributeSet.java b/libjava/classpath/javax/swing/text/html/ViewAttributeSet.java
index 25db89fc405..8838646d5f5 100644
--- a/libjava/classpath/javax/swing/text/html/ViewAttributeSet.java
+++ b/libjava/classpath/javax/swing/text/html/ViewAttributeSet.java
@@ -83,7 +83,7 @@ class ViewAttributeSet
{
styleSheet = ss;
view = v;
- ArrayList atts = new ArrayList();
+ ArrayList<AttributeSet> atts = new ArrayList<AttributeSet>();
Element el = v.getElement();
AttributeSet elAtts = el.getAttributes();
@@ -93,7 +93,7 @@ class ViewAttributeSet
if (el.isLeaf())
{
- Enumeration n = elAtts.getAttributeNames();
+ Enumeration<?> n = elAtts.getAttributeNames();
while (n.hasMoreElements())
{
Object key = n.nextElement();
@@ -115,7 +115,7 @@ class ViewAttributeSet
}
AttributeSet[] atts1 = new AttributeSet[atts.size()];
- atts1 = (AttributeSet[]) atts.toArray(atts1);
+ atts1 = atts.toArray(atts1);
init(atts1);
}
diff --git a/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java b/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
index a1afe781324..34a70c19b59 100644
--- a/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
+++ b/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
@@ -68,7 +68,7 @@ public class DefaultMutableTreeNode
* children.
*/
public static final Enumeration<TreeNode> EMPTY_ENUMERATION =
- EmptyEnumeration.getInstance();
+ new EmptyEnumeration<TreeNode>();
/**
* The parent of this node (possibly <code>null</code>).
diff --git a/libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java b/libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java
index 2bb0d0045a6..b2806f2728b 100644
--- a/libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java
+++ b/libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.tree;
+import gnu.java.lang.CPStringBuilder;
+
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -224,7 +226,7 @@ public class DefaultTreeSelectionModel
return "[selection empty]";
else
{
- StringBuffer b = new StringBuffer("selected rows: [");
+ CPStringBuilder b = new CPStringBuilder("selected rows: [");
for (int i = 0; i < selection.length; i++)
{
b.append(getRow(selection[i]));
diff --git a/libjava/classpath/javax/tools/FileObject.java b/libjava/classpath/javax/tools/FileObject.java
index 56ecaba6d28..a1d65c64250 100644
--- a/libjava/classpath/javax/tools/FileObject.java
+++ b/libjava/classpath/javax/tools/FileObject.java
@@ -60,7 +60,7 @@ public interface FileObject
*
* @return a URI that represents this file object
*/
- URI toURI();
+ URI toUri();
/**
* Returns a name for this file object. The exact name is implementation
@@ -99,6 +99,8 @@ public interface FileObject
/**
* Opens this file for reading and returns a reader.
*
+ * @param ignoreEncodingErrors <code>true</code> when encoding errors should be ignored
+ * <code>false</code> otherwise
* @return a reader for reading this file object
*
* @throws IOException if an I/O error occurs
@@ -107,7 +109,7 @@ public interface FileObject
* @throws UnsupportedOperationException if this kind of file does not allow
* character reading
*/
- Reader openReader() throws IOException;
+ Reader openReader(boolean ignoreEncodingErrors) throws IOException;
/**
* Returns the character content of the file, if available. Any byte
diff --git a/libjava/classpath/javax/xml/datatype/DatatypeFactory.java b/libjava/classpath/javax/xml/datatype/DatatypeFactory.java
index 06f465c353e..386d5b85286 100644
--- a/libjava/classpath/javax/xml/datatype/DatatypeFactory.java
+++ b/libjava/classpath/javax/xml/datatype/DatatypeFactory.java
@@ -44,7 +44,7 @@ import java.math.BigInteger;
import java.util.GregorianCalendar;
import java.util.Iterator;
import java.util.Properties;
-import gnu.classpath.ServiceFactory;
+import java.util.ServiceLoader;
/**
* Factory class to create new datatype objects mapping XML to and from Java
@@ -97,11 +97,11 @@ public abstract class DatatypeFactory
return (DatatypeFactory) Class.forName(className).newInstance();
}
// 3. services
- Iterator i = ServiceFactory.lookupProviders(DatatypeFactory.class);
+ Iterator<DatatypeFactory> i = ServiceLoader.load(DatatypeFactory.class).iterator();
if (i.hasNext())
- return (DatatypeFactory) i.next();
+ return i.next();
// 4. fallback
- Class t = Class.forName(DATATYPEFACTORY_IMPLEMENTATION_CLASS);
+ Class<?> t = Class.forName(DATATYPEFACTORY_IMPLEMENTATION_CLASS);
return (DatatypeFactory) t.newInstance();
}
catch (Exception e)
diff --git a/libjava/classpath/javax/xml/namespace/NamespaceContext.java b/libjava/classpath/javax/xml/namespace/NamespaceContext.java
index 1bcb85006c1..b9722a47a53 100644
--- a/libjava/classpath/javax/xml/namespace/NamespaceContext.java
+++ b/libjava/classpath/javax/xml/namespace/NamespaceContext.java
@@ -61,6 +61,7 @@ public interface NamespaceContext
/**
* Returns all the prefixes currently bound to the given namespace URI.
*/
+ @SuppressWarnings("unchecked")
public Iterator getPrefixes(String namespaceURI);
}
diff --git a/libjava/classpath/javax/xml/namespace/QName.java b/libjava/classpath/javax/xml/namespace/QName.java
index 18dee79bbff..3c756237895 100644
--- a/libjava/classpath/javax/xml/namespace/QName.java
+++ b/libjava/classpath/javax/xml/namespace/QName.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.xml.namespace;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.Serializable;
import javax.xml.XMLConstants;
@@ -126,7 +128,7 @@ public class QName implements Serializable
{
if (qName == null)
{
- StringBuffer buf = new StringBuffer();
+ CPStringBuilder buf = new CPStringBuilder();
if (namespaceURI.length() > 0)
{
buf.append('{');
diff --git a/libjava/classpath/javax/xml/parsers/DocumentBuilderFactory.java b/libjava/classpath/javax/xml/parsers/DocumentBuilderFactory.java
index 9312e65e06d..a1350c54920 100644
--- a/libjava/classpath/javax/xml/parsers/DocumentBuilderFactory.java
+++ b/libjava/classpath/javax/xml/parsers/DocumentBuilderFactory.java
@@ -99,7 +99,7 @@ public abstract class DocumentBuilderFactory
{
try
{
- Class t = (loader != null) ? loader.loadClass(className) :
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
Class.forName(className);
return (DocumentBuilderFactory) t.newInstance();
}
diff --git a/libjava/classpath/javax/xml/parsers/SAXParserFactory.java b/libjava/classpath/javax/xml/parsers/SAXParserFactory.java
index 549fe4b5409..9f8f7bafee9 100644
--- a/libjava/classpath/javax/xml/parsers/SAXParserFactory.java
+++ b/libjava/classpath/javax/xml/parsers/SAXParserFactory.java
@@ -99,7 +99,7 @@ public abstract class SAXParserFactory
{
try
{
- Class t = (loader != null) ? loader.loadClass(className) :
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
Class.forName(className);
return (SAXParserFactory) t.newInstance();
}
diff --git a/libjava/classpath/javax/xml/stream/XMLEventFactory.java b/libjava/classpath/javax/xml/stream/XMLEventFactory.java
index cb850baaec8..30e160793b9 100644
--- a/libjava/classpath/javax/xml/stream/XMLEventFactory.java
+++ b/libjava/classpath/javax/xml/stream/XMLEventFactory.java
@@ -116,7 +116,7 @@ public abstract class XMLEventFactory
{
try
{
- Class t = (loader != null) ? loader.loadClass(className) :
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
Class.forName(className);
return (XMLEventFactory) t.newInstance();
}
@@ -217,6 +217,7 @@ public abstract class XMLEventFactory
/**
* Create a start-element event.
*/
+ @SuppressWarnings("unchecked")
public abstract StartElement createStartElement(QName name,
Iterator attributes,
Iterator namespaces);
@@ -231,6 +232,7 @@ public abstract class XMLEventFactory
/**
* Create a start-element event.
*/
+ @SuppressWarnings("unchecked")
public abstract StartElement createStartElement(String prefix,
String namespaceUri,
String localName,
@@ -240,6 +242,7 @@ public abstract class XMLEventFactory
/**
* Create a start-element event.
*/
+ @SuppressWarnings("unchecked")
public abstract StartElement createStartElement(String prefix,
String namespaceUri,
String localName,
@@ -250,6 +253,7 @@ public abstract class XMLEventFactory
/**
* Create an end-element event.
*/
+ @SuppressWarnings("unchecked")
public abstract EndElement createEndElement(QName name,
Iterator namespaces);
@@ -263,6 +267,7 @@ public abstract class XMLEventFactory
/**
* Create an end-element event.
*/
+ @SuppressWarnings("unchecked")
public abstract EndElement createEndElement(String prefix,
String namespaceUri,
String localName,
diff --git a/libjava/classpath/javax/xml/stream/XMLEventReader.java b/libjava/classpath/javax/xml/stream/XMLEventReader.java
index 35ad5696eda..ee0354f94f3 100644
--- a/libjava/classpath/javax/xml/stream/XMLEventReader.java
+++ b/libjava/classpath/javax/xml/stream/XMLEventReader.java
@@ -43,6 +43,7 @@ import javax.xml.stream.events.XMLEvent;
/**
* An XML parser.
*/
+@SuppressWarnings("unchecked")
public interface XMLEventReader
extends Iterator
{
diff --git a/libjava/classpath/javax/xml/stream/XMLInputFactory.java b/libjava/classpath/javax/xml/stream/XMLInputFactory.java
index f88451e54bf..437bf83b5ec 100644
--- a/libjava/classpath/javax/xml/stream/XMLInputFactory.java
+++ b/libjava/classpath/javax/xml/stream/XMLInputFactory.java
@@ -229,7 +229,7 @@ public abstract class XMLInputFactory
{
try
{
- Class t = (loader != null) ? loader.loadClass(className) :
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
Class.forName(className);
return (XMLInputFactory) t.newInstance();
}
diff --git a/libjava/classpath/javax/xml/stream/XMLOutputFactory.java b/libjava/classpath/javax/xml/stream/XMLOutputFactory.java
index e4c9dd40d46..908f84f262a 100644
--- a/libjava/classpath/javax/xml/stream/XMLOutputFactory.java
+++ b/libjava/classpath/javax/xml/stream/XMLOutputFactory.java
@@ -116,7 +116,7 @@ public abstract class XMLOutputFactory
{
try
{
- Class t = (loader != null) ? loader.loadClass(className) :
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
Class.forName(className);
return (XMLOutputFactory) t.newInstance();
}
diff --git a/libjava/classpath/javax/xml/stream/events/DTD.java b/libjava/classpath/javax/xml/stream/events/DTD.java
index 6c7bcc4ced0..943572ef32f 100644
--- a/libjava/classpath/javax/xml/stream/events/DTD.java
+++ b/libjava/classpath/javax/xml/stream/events/DTD.java
@@ -60,11 +60,13 @@ public interface DTD
/**
* Returns the notations declared in the DTD.
*/
+ @SuppressWarnings("unchecked")
List getNotations();
/**
* Returns the entities declared in the DTD.
*/
+ @SuppressWarnings("unchecked")
List getEntities();
}
diff --git a/libjava/classpath/javax/xml/stream/events/EndElement.java b/libjava/classpath/javax/xml/stream/events/EndElement.java
index 86a2e1617e4..3bde8f8ad9e 100644
--- a/libjava/classpath/javax/xml/stream/events/EndElement.java
+++ b/libjava/classpath/javax/xml/stream/events/EndElement.java
@@ -55,6 +55,7 @@ public interface EndElement
/**
* Returns the namespaces that have gone out of scope.
*/
+ @SuppressWarnings("unchecked")
Iterator getNamespaces();
}
diff --git a/libjava/classpath/javax/xml/stream/events/StartElement.java b/libjava/classpath/javax/xml/stream/events/StartElement.java
index a35b3b4121f..0916368c92b 100644
--- a/libjava/classpath/javax/xml/stream/events/StartElement.java
+++ b/libjava/classpath/javax/xml/stream/events/StartElement.java
@@ -56,11 +56,13 @@ public interface StartElement
/**
* Returns the attributes declared on this element.
*/
+ @SuppressWarnings("unchecked")
Iterator getAttributes();
/**
* Returns the namespaces declared on this element.
*/
+ @SuppressWarnings("unchecked")
Iterator getNamespaces();
/**
diff --git a/libjava/classpath/javax/xml/transform/TransformerException.java b/libjava/classpath/javax/xml/transform/TransformerException.java
index 3d97eda1bbb..7a0b5ad9888 100644
--- a/libjava/classpath/javax/xml/transform/TransformerException.java
+++ b/libjava/classpath/javax/xml/transform/TransformerException.java
@@ -34,8 +34,11 @@ 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 javax.xml.transform;
+import gnu.java.lang.CPStringBuilder;
+
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -179,7 +182,7 @@ public class TransformerException
String systemId = locator.getSystemId();
int lineNumber = locator.getLineNumber();
int columnNumber = locator.getColumnNumber();
- StringBuffer buffer = new StringBuffer ();
+ CPStringBuilder buffer = new CPStringBuilder ();
if (publicId != null)
{
buffer.append ("publicId=");
diff --git a/libjava/classpath/javax/xml/transform/TransformerFactory.java b/libjava/classpath/javax/xml/transform/TransformerFactory.java
index e3c895361a2..e3e6c0cbdc3 100644
--- a/libjava/classpath/javax/xml/transform/TransformerFactory.java
+++ b/libjava/classpath/javax/xml/transform/TransformerFactory.java
@@ -89,7 +89,7 @@ public abstract class TransformerFactory
{
try
{
- Class t = (loader != null) ? loader.loadClass(className) :
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
Class.forName(className);
return (TransformerFactory) t.newInstance();
}
@@ -107,7 +107,7 @@ public abstract class TransformerFactory
while (className == null && count < 3);
try
{
- Class t =
+ Class<?> t =
Class.forName("gnu.xml.transform.TransformerFactoryImpl");
return (TransformerFactory) t.newInstance();
}
diff --git a/libjava/classpath/javax/xml/validation/SchemaFactory.java b/libjava/classpath/javax/xml/validation/SchemaFactory.java
index 0c24104445b..0b83b6f4d4d 100644
--- a/libjava/classpath/javax/xml/validation/SchemaFactory.java
+++ b/libjava/classpath/javax/xml/validation/SchemaFactory.java
@@ -89,7 +89,7 @@ public abstract class SchemaFactory
{
try
{
- Class t = (loader != null) ? loader.loadClass(className) :
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
Class.forName(className);
return (SchemaFactory) t.newInstance();
}
@@ -118,7 +118,7 @@ public abstract class SchemaFactory
for (String line = r.readLine(); line != null;
line = r.readLine())
{
- Class t = (loader != null) ? loader.loadClass(className) :
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
Class.forName(className);
SchemaFactory ret = (SchemaFactory) t.newInstance();
if (ret.isSchemaLanguageSupported(schemaLanguage))
diff --git a/libjava/classpath/javax/xml/xpath/XPathFactory.java b/libjava/classpath/javax/xml/xpath/XPathFactory.java
index e87475f13d4..76a88a10cec 100644
--- a/libjava/classpath/javax/xml/xpath/XPathFactory.java
+++ b/libjava/classpath/javax/xml/xpath/XPathFactory.java
@@ -117,7 +117,7 @@ public abstract class XPathFactory
{
try
{
- Class t = (loader != null) ? loader.loadClass(className) :
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
Class.forName(className);
XPathFactory ret = (XPathFactory) t.newInstance();
if (ret.isObjectModelSupported(uri))
diff --git a/libjava/classpath/javax/xml/xpath/XPathFunction.java b/libjava/classpath/javax/xml/xpath/XPathFunction.java
index c7ea733141f..dbda11bfe6c 100644
--- a/libjava/classpath/javax/xml/xpath/XPathFunction.java
+++ b/libjava/classpath/javax/xml/xpath/XPathFunction.java
@@ -52,6 +52,7 @@ public interface XPathFunction
* Evaluate the function with the specified arguments.
* @param args the list of arguments
*/
+ @SuppressWarnings("unchecked")
Object evaluate(List args)
throws XPathFunctionException;
OpenPOWER on IntegriCloud