org.jhotdraw.samples.svg.io
Class SVGInputFormat

java.lang.Object
  extended by org.jhotdraw.samples.svg.io.SVGInputFormat
All Implemented Interfaces:
InputFormat
Direct Known Subclasses:
SVGZInputFormat

public class SVGInputFormat
extends java.lang.Object
implements InputFormat

SVGInputFormat. This format is aimed to comply to the Scalable Vector Graphics (SVG) Tiny 1.2 Specification supporting the SVG-static feature string. http://www.w3.org/TR/SVGMobile12/

Design pattern:
Name: Abstract Factory.
Role: Client.
Partners: SVGFigureFactory as Abstract Factory.

Version:
$Id: SVGInputFormat.java 564 2009-10-10 10:21:01Z rawcoder $
Author:
Werner Randelshofer

Nested Class Summary
private static class SVGInputFormat.Viewport
          Each SVG element establishes a new Viewport.
 
Field Summary
private static boolean DEBUG
          Set this to true, to getChild debug output on if (DEBUG) System.out.
private  IXMLElement document
          Holds the document that is currently being read.
private  java.util.HashMap<IXMLElement,java.lang.Object> elementObjects
          Maps to all drawing objects from the XML elements they were created from.
private  SVGFigureFactory factory
          The SVGFigure factory is used to create Figure's for the drawing.
private  java.util.LinkedList<Figure> figures
          Holds the figures that are currently being read.
private  FontFormatter fontFormatter
          FontFormatter for parsing font family names.
private  java.util.HashMap<java.lang.String,IXMLElement> identifiedElements
          Maps to all XML elements that are identified by an xml:id.
private  StyleManager styleManager
          Holds the style manager used for applying cascading style sheet CSS rules to the document.
private static java.util.HashSet<java.lang.String> supportedFeatures
           
private  StreamPosTokenizer toPathTokenizer
          Tokenizer for parsing SVG path expressions.
private  java.net.URL url
          URL pointing to the SVG input file.
private  java.util.Stack<SVGInputFormat.Viewport> viewportStack
          Each SVG element creates a new Viewport that we store here.
 
Constructor Summary
SVGInputFormat()
          Creates a new instance.
SVGInputFormat(SVGFigureFactory factory)
           
 
Method Summary
private  void flattenStyles(IXMLElement elem)
          Flattens all CSS styles.
 javax.swing.filechooser.FileFilter getFileFilter()
          Return a FileFilter that can be used to identify files which can be read with this input format.
 javax.swing.JComponent getInputFormatAccessory()
          Return a JFileChooser accessory that can be used to customize the input format.
private  void identifyElements(IXMLElement elem)
          Puts all elments with an "id" or an "xml:id" attribute into the hashtable identifiedElements.
private  void initStorageContext(IXMLElement root)
           
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
          Returns true, if this InputFormat can readFigures TransferData using the specified DataFlavor.
 void read(java.io.File file, Drawing drawing)
          Reads figures from a file and replaces the children of the drawing with them.
 void read(java.io.File file, Drawing drawing, boolean replace)
          Reads figures from a file and adds them to the specified drawing.
 void read(java.io.InputStream in, Drawing drawing, boolean replace)
          This is the main reading method.
 void read(java.awt.datatransfer.Transferable t, Drawing drawing, boolean replace)
          Reads figures from the specified Transferable and adds them to the specified drawing.
 void read(java.net.URL url, Drawing drawing, boolean replace)
           
private  Figure readAElement(IXMLElement elem)
          Reads an SVG "a" element.
private  java.lang.String readAttribute(IXMLElement elem, java.lang.String attributeName, java.lang.String defaultValue)
          Reads an attribute that is not inherited, unless its value is "inherit".
private  Figure readCircleElement(IXMLElement elem)
          Reads an SVG "circle" element.
private  void readCoreAttributes(IXMLElement elem, java.util.HashMap<AttributeKey,java.lang.Object> a)
           
private  void readDefsElement(IXMLElement elem)
          Reads an SVG "defs" element.
private  Figure readElement(IXMLElement elem)
          Reads an SVG element of any kind.
private  Figure readEllipseElement(IXMLElement elem)
          Reads an SVG "ellipse" element.
private  void readFontAttributes(IXMLElement elem, java.util.Map<AttributeKey,java.lang.Object> a)
           
private  Figure readGElement(IXMLElement elem)
          Reads an SVG "g" element.
private  void readGraphicsAttributes(IXMLElement elem, Figure f)
           
private  Figure readImageElement(IXMLElement elem)
          Reads an SVG "image" element.
private  java.lang.String readInheritAttribute(IXMLElement elem, java.lang.String attributeName, java.lang.String defaultValue)
          Reads an attribute that is inherited.
private  java.lang.String readInheritColorAttribute(IXMLElement elem, java.lang.String attributeName, java.lang.String defaultValue)
          Reads a color attribute that is inherited.
private  double readInheritFontSizeAttribute(IXMLElement elem, java.lang.String attributeName, java.lang.String defaultValue)
          Reads a font size attribute that is inherited.
private  void readLinearGradientElement(IXMLElement elem)
          Reads an SVG "linearGradient" element.
private  void readLineAttributes(IXMLElement elem, java.util.HashMap<AttributeKey,java.lang.Object> a)
          Reads line and polyline attributes.
private  Figure readLineElement(IXMLElement elem)
          Reads an SVG "line" element.
private  void readOpacityAttribute(IXMLElement elem, java.util.Map<AttributeKey,java.lang.Object> a)
           
private  Figure readPathElement(IXMLElement elem)
          Reads an SVG "path" element.
private  Figure readPolygonElement(IXMLElement elem)
          Reads an SVG "polygon" element.
private  Figure readPolylineElement(IXMLElement elem)
          Reads an SVG "polyline" element.
private  void readRadialGradientElement(IXMLElement elem)
          Reads an SVG "radialGradient" element.
private  Figure readRectElement(IXMLElement elem)
          Reads an SVG "rect" element.
private  void readShapeAttributes(IXMLElement elem, java.util.HashMap<AttributeKey,java.lang.Object> a)
          Reads shape attributes.
private  void readSolidColorElement(IXMLElement elem)
           
private  Figure readSVGElement(IXMLElement elem)
          Reads an SVG "svg" element.
private  Figure readSwitchElement(IXMLElement elem)
          Evaluates an SVG "switch" element.
private  Figure readTextAreaElement(IXMLElement elem)
          Reads an SVG "textArea" element.
private  void readTextAttributes(IXMLElement elem, java.util.Map<AttributeKey,java.lang.Object> a)
           
private  Figure readTextElement(IXMLElement elem)
          Reads an SVG "text" element.
private  void readTextFlowAttributes(IXMLElement elem, java.util.HashMap<AttributeKey,java.lang.Object> a)
           
private  void readTransformAttribute(IXMLElement elem, java.util.HashMap<AttributeKey,java.lang.Object> a)
           
private  void readTSpanElement(IXMLElement elem, javax.swing.text.DefaultStyledDocument doc)
          Reads an SVG "tspan" element.
private  Figure readUseElement(IXMLElement elem)
          Reads an SVG "use" element.
private  void readUseShapeAttributes(IXMLElement elem, java.util.HashMap<AttributeKey,java.lang.Object> a)
           
private  void readViewportAttributes(IXMLElement elem, java.util.HashMap<AttributeKey,java.lang.Object> a)
           
private  java.awt.Color toColor(IXMLElement elem, java.lang.String value)
          Reads a color style attribute.
static java.lang.String[] toCommaSeparatedArray(java.lang.String str)
          Returns a value as a String array.
private  double toDouble(IXMLElement elem, java.lang.String value)
          Reads a double attribute.
private  double toDouble(IXMLElement elem, java.lang.String value, double defaultValue, double min, double max)
          Reads a double attribute.
private  double toHeight(IXMLElement elem, java.lang.String str)
          Returns a value as a height.
private  double toLength(IXMLElement elem, java.lang.String str, double percentFactor)
          Returns a value as a length.
private  double toNumber(IXMLElement elem, java.lang.String str)
          Returns a value as a number.
private  java.lang.Object toPaint(IXMLElement elem, java.lang.String value)
          Reads a paint style attribute.
private  BezierPath[] toPath(IXMLElement elem, java.lang.String str)
          Returns a value as a BezierPath array.
private  java.awt.geom.Point2D.Double[] toPoints(IXMLElement elem, java.lang.String str)
          Returns a value as a Point2D.Double array.
static java.lang.String[] toQuotedAndCommaSeparatedArray(java.lang.String str)
          Returns a value as a String array.
private  java.lang.String toText(IXMLElement elem, java.lang.String value)
          Reads a text attribute.
static java.awt.geom.AffineTransform toTransform(IXMLElement elem, java.lang.String str)
           
private  double toWidth(IXMLElement elem, java.lang.String str)
          Returns a value as a width.
static java.lang.String[] toWSOrCommaSeparatedArray(java.lang.String str)
          Returns a value as a String array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
Set this to true, to getChild debug output on if (DEBUG) System.out.

See Also:
Constant Field Values

factory

private SVGFigureFactory factory
The SVGFigure factory is used to create Figure's for the drawing.


url

private java.net.URL url
URL pointing to the SVG input file. This is used as a base URL for resources that are referenced from the SVG file.


identifiedElements

private java.util.HashMap<java.lang.String,IXMLElement> identifiedElements
Maps to all XML elements that are identified by an xml:id.


elementObjects

private java.util.HashMap<IXMLElement,java.lang.Object> elementObjects
Maps to all drawing objects from the XML elements they were created from.


toPathTokenizer

private StreamPosTokenizer toPathTokenizer
Tokenizer for parsing SVG path expressions.


fontFormatter

private FontFormatter fontFormatter
FontFormatter for parsing font family names.


viewportStack

private java.util.Stack<SVGInputFormat.Viewport> viewportStack
Each SVG element creates a new Viewport that we store here.


styleManager

private StyleManager styleManager
Holds the style manager used for applying cascading style sheet CSS rules to the document.


figures

private java.util.LinkedList<Figure> figures
Holds the figures that are currently being read.


document

private IXMLElement document
Holds the document that is currently being read.


supportedFeatures

private static final java.util.HashSet<java.lang.String> supportedFeatures
Constructor Detail

SVGInputFormat

public SVGInputFormat()
Creates a new instance.


SVGInputFormat

public SVGInputFormat(SVGFigureFactory factory)
Method Detail

read

public void read(java.io.File file,
                 Drawing drawing)
          throws java.io.IOException
Description copied from interface: InputFormat
Reads figures from a file and replaces the children of the drawing with them.

This is a convenience method for calling read(File,Drawing,true).

Specified by:
read in interface InputFormat
Parameters:
file - The file.
drawing - The drawing.
Throws:
java.io.IOException

read

public void read(java.io.InputStream in,
                 Drawing drawing,
                 boolean replace)
          throws java.io.IOException
This is the main reading method.

Specified by:
read in interface InputFormat
Parameters:
in - The input stream.
drawing - The drawing to which this method adds figures.
replace - Whether attributes on the drawing object should by changed by this method. Set this to false, when reading individual images from the clipboard.
Throws:
java.io.IOException

initStorageContext

private void initStorageContext(IXMLElement root)

flattenStyles

private void flattenStyles(IXMLElement elem)
                    throws java.io.IOException
Flattens all CSS styles. Styles defined in a "style" attribute and in CSS rules are converted into attributes with the same name.

Throws:
java.io.IOException

readElement

private Figure readElement(IXMLElement elem)
                    throws java.io.IOException
Reads an SVG element of any kind.

Returns:
Returns the Figure, if the SVG element represents a Figure. Returns null in all other cases.
Throws:
java.io.IOException

readDefsElement

private void readDefsElement(IXMLElement elem)
                      throws java.io.IOException
Reads an SVG "defs" element.

Throws:
java.io.IOException

readGElement

private Figure readGElement(IXMLElement elem)
                     throws java.io.IOException
Reads an SVG "g" element.

Throws:
java.io.IOException

readAElement

private Figure readAElement(IXMLElement elem)
                     throws java.io.IOException
Reads an SVG "a" element.

Throws:
java.io.IOException

readSVGElement

private Figure readSVGElement(IXMLElement elem)
                       throws java.io.IOException
Reads an SVG "svg" element.

Throws:
java.io.IOException

readRectElement

private Figure readRectElement(IXMLElement elem)
                        throws java.io.IOException
Reads an SVG "rect" element.

Throws:
java.io.IOException

readCircleElement

private Figure readCircleElement(IXMLElement elem)
                          throws java.io.IOException
Reads an SVG "circle" element.

Throws:
java.io.IOException

readEllipseElement

private Figure readEllipseElement(IXMLElement elem)
                           throws java.io.IOException
Reads an SVG "ellipse" element.

Throws:
java.io.IOException

readImageElement

private Figure readImageElement(IXMLElement elem)
                         throws java.io.IOException
Reads an SVG "image" element.

Throws:
java.io.IOException

readLineElement

private Figure readLineElement(IXMLElement elem)
                        throws java.io.IOException
Reads an SVG "line" element.

Throws:
java.io.IOException

readPolylineElement

private Figure readPolylineElement(IXMLElement elem)
                            throws java.io.IOException
Reads an SVG "polyline" element.

Throws:
java.io.IOException

readPolygonElement

private Figure readPolygonElement(IXMLElement elem)
                           throws java.io.IOException
Reads an SVG "polygon" element.

Throws:
java.io.IOException

readPathElement

private Figure readPathElement(IXMLElement elem)
                        throws java.io.IOException
Reads an SVG "path" element.

Throws:
java.io.IOException

readTextElement

private Figure readTextElement(IXMLElement elem)
                        throws java.io.IOException
Reads an SVG "text" element.

Throws:
java.io.IOException

readTextAreaElement

private Figure readTextAreaElement(IXMLElement elem)
                            throws java.io.IOException
Reads an SVG "textArea" element.

Throws:
java.io.IOException

readTSpanElement

private void readTSpanElement(IXMLElement elem,
                              javax.swing.text.DefaultStyledDocument doc)
                       throws java.io.IOException
Reads an SVG "tspan" element.

Throws:
java.io.IOException

readSwitchElement

private Figure readSwitchElement(IXMLElement elem)
                          throws java.io.IOException
Evaluates an SVG "switch" element.

Throws:
java.io.IOException

readUseElement

private Figure readUseElement(IXMLElement elem)
                       throws java.io.IOException
Reads an SVG "use" element.

Throws:
java.io.IOException

readInheritAttribute

private java.lang.String readInheritAttribute(IXMLElement elem,
                                              java.lang.String attributeName,
                                              java.lang.String defaultValue)
Reads an attribute that is inherited.


readInheritColorAttribute

private java.lang.String readInheritColorAttribute(IXMLElement elem,
                                                   java.lang.String attributeName,
                                                   java.lang.String defaultValue)
Reads a color attribute that is inherited. This is similar to readInheritAttribute, but takes care of the "currentColor" magic attribute value.


readInheritFontSizeAttribute

private double readInheritFontSizeAttribute(IXMLElement elem,
                                            java.lang.String attributeName,
                                            java.lang.String defaultValue)
                                     throws java.io.IOException
Reads a font size attribute that is inherited. As specified by http://www.w3.org/TR/SVGMobile12/text.html#FontPropertiesUsedBySVG http://www.w3.org/TR/2006/CR-xsl11-20060220/#font-getChildCount

Throws:
java.io.IOException

readAttribute

private java.lang.String readAttribute(IXMLElement elem,
                                       java.lang.String attributeName,
                                       java.lang.String defaultValue)
Reads an attribute that is not inherited, unless its value is "inherit".


toWidth

private double toWidth(IXMLElement elem,
                       java.lang.String str)
                throws java.io.IOException
Returns a value as a width. http://www.w3.org/TR/SVGMobile12/types.html#DataTypeLength

Throws:
java.io.IOException

toHeight

private double toHeight(IXMLElement elem,
                        java.lang.String str)
                 throws java.io.IOException
Returns a value as a height. http://www.w3.org/TR/SVGMobile12/types.html#DataTypeLength

Throws:
java.io.IOException

toNumber

private double toNumber(IXMLElement elem,
                        java.lang.String str)
                 throws java.io.IOException
Returns a value as a number. http://www.w3.org/TR/SVGMobile12/types.html#DataTypeNumber

Throws:
java.io.IOException

toLength

private double toLength(IXMLElement elem,
                        java.lang.String str,
                        double percentFactor)
                 throws java.io.IOException
Returns a value as a length. http://www.w3.org/TR/SVGMobile12/types.html#DataTypeLength

Throws:
java.io.IOException

toCommaSeparatedArray

public static java.lang.String[] toCommaSeparatedArray(java.lang.String str)
                                                throws java.io.IOException
Returns a value as a String array. The values are separated by commas with optional white space.

Throws:
java.io.IOException

toWSOrCommaSeparatedArray

public static java.lang.String[] toWSOrCommaSeparatedArray(java.lang.String str)
                                                    throws java.io.IOException
Returns a value as a String array. The values are separated by whitespace or by commas with optional white space.

Throws:
java.io.IOException

toQuotedAndCommaSeparatedArray

public static java.lang.String[] toQuotedAndCommaSeparatedArray(java.lang.String str)
                                                         throws java.io.IOException
Returns a value as a String array. The values are separated by commas with optional quotes and white space.

Throws:
java.io.IOException

toPoints

private java.awt.geom.Point2D.Double[] toPoints(IXMLElement elem,
                                                java.lang.String str)
                                         throws java.io.IOException
Returns a value as a Point2D.Double array. as specified in http://www.w3.org/TR/SVGMobile12/shapes.html#PointsBNF

Throws:
java.io.IOException

toPath

private BezierPath[] toPath(IXMLElement elem,
                            java.lang.String str)
                     throws java.io.IOException
Returns a value as a BezierPath array. as specified in http://www.w3.org/TR/SVGMobile12/paths.html#PathDataBNF Also supports elliptical arc commands 'a' and 'A' as specified in http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands

Throws:
java.io.IOException

readCoreAttributes

private void readCoreAttributes(IXMLElement elem,
                                java.util.HashMap<AttributeKey,java.lang.Object> a)
                         throws java.io.IOException
Throws:
java.io.IOException

identifyElements

private void identifyElements(IXMLElement elem)
Puts all elments with an "id" or an "xml:id" attribute into the hashtable identifiedElements.


readOpacityAttribute

private void readOpacityAttribute(IXMLElement elem,
                                  java.util.Map<AttributeKey,java.lang.Object> a)
                           throws java.io.IOException
Throws:
java.io.IOException

readTextAttributes

private void readTextAttributes(IXMLElement elem,
                                java.util.Map<AttributeKey,java.lang.Object> a)
                         throws java.io.IOException
Throws:
java.io.IOException

readTextFlowAttributes

private void readTextFlowAttributes(IXMLElement elem,
                                    java.util.HashMap<AttributeKey,java.lang.Object> a)
                             throws java.io.IOException
Throws:
java.io.IOException

readTransformAttribute

private void readTransformAttribute(IXMLElement elem,
                                    java.util.HashMap<AttributeKey,java.lang.Object> a)
                             throws java.io.IOException
Throws:
java.io.IOException

readSolidColorElement

private void readSolidColorElement(IXMLElement elem)
                            throws java.io.IOException
Throws:
java.io.IOException

readShapeAttributes

private void readShapeAttributes(IXMLElement elem,
                                 java.util.HashMap<AttributeKey,java.lang.Object> a)
                          throws java.io.IOException
Reads shape attributes.

Throws:
java.io.IOException

readUseShapeAttributes

private void readUseShapeAttributes(IXMLElement elem,
                                    java.util.HashMap<AttributeKey,java.lang.Object> a)
                             throws java.io.IOException
Throws:
java.io.IOException

readLineAttributes

private void readLineAttributes(IXMLElement elem,
                                java.util.HashMap<AttributeKey,java.lang.Object> a)
                         throws java.io.IOException
Reads line and polyline attributes.

Throws:
java.io.IOException

readViewportAttributes

private void readViewportAttributes(IXMLElement elem,
                                    java.util.HashMap<AttributeKey,java.lang.Object> a)
                             throws java.io.IOException
Throws:
java.io.IOException

readGraphicsAttributes

private void readGraphicsAttributes(IXMLElement elem,
                                    Figure f)
                             throws java.io.IOException
Throws:
java.io.IOException

readLinearGradientElement

private void readLinearGradientElement(IXMLElement elem)
                                throws java.io.IOException
Reads an SVG "linearGradient" element.

Throws:
java.io.IOException

readRadialGradientElement

private void readRadialGradientElement(IXMLElement elem)
                                throws java.io.IOException
Reads an SVG "radialGradient" element.

Throws:
java.io.IOException

readFontAttributes

private void readFontAttributes(IXMLElement elem,
                                java.util.Map<AttributeKey,java.lang.Object> a)
                         throws java.io.IOException
Throws:
java.io.IOException

toPaint

private java.lang.Object toPaint(IXMLElement elem,
                                 java.lang.String value)
                          throws java.io.IOException
Reads a paint style attribute. This can be a Color or a Gradient or null. XXX - Doesn't support url(...) colors yet.

Throws:
java.io.IOException

toColor

private java.awt.Color toColor(IXMLElement elem,
                               java.lang.String value)
                        throws java.io.IOException
Reads a color style attribute. This can be a Color or null. FIXME - Doesn't support url(...) colors yet.

Throws:
java.io.IOException

toDouble

private double toDouble(IXMLElement elem,
                        java.lang.String value)
                 throws java.io.IOException
Reads a double attribute.

Throws:
java.io.IOException

toDouble

private double toDouble(IXMLElement elem,
                        java.lang.String value,
                        double defaultValue,
                        double min,
                        double max)
                 throws java.io.IOException
Reads a double attribute.

Throws:
java.io.IOException

toText

private java.lang.String toText(IXMLElement elem,
                                java.lang.String value)
                         throws java.io.IOException
Reads a text attribute. This method takes the "xml:space" attribute into account. http://www.w3.org/TR/SVGMobile12/text.html#WhiteSpace

Throws:
java.io.IOException

toTransform

public static java.awt.geom.AffineTransform toTransform(IXMLElement elem,
                                                        java.lang.String str)
                                                 throws java.io.IOException
Throws:
java.io.IOException

getFileFilter

public javax.swing.filechooser.FileFilter getFileFilter()
Description copied from interface: InputFormat
Return a FileFilter that can be used to identify files which can be read with this input format. Typically, each input format has its own recognizable file naming convention.

Specified by:
getFileFilter in interface InputFormat
Returns:
FileFilter to be used with a javax.swing.JFileChooser

getInputFormatAccessory

public javax.swing.JComponent getInputFormatAccessory()
Description copied from interface: InputFormat
Return a JFileChooser accessory that can be used to customize the input format.

Specified by:
getInputFormatAccessory in interface InputFormat
Returns:
A JFileChooser accessory to be used with a javax.swing.JFileChooser Returns null, if no accessory is provided for this format.

read

public void read(java.io.File file,
                 Drawing drawing,
                 boolean replace)
          throws java.io.IOException
Description copied from interface: InputFormat
Reads figures from a file and adds them to the specified drawing.

Specified by:
read in interface InputFormat
Parameters:
file - The file.
drawing - The drawing.
replace - Set this to true, if the contents of the file replaces the contents of the drawing (for example, when loading a drawing from a file). Set this to false, to add the contents of the file to the drawing (for example, when the file has been dropped into the drawing view).
Throws:
java.io.IOException

read

public void read(java.net.URL url,
                 Drawing drawing,
                 boolean replace)
          throws java.io.IOException
Throws:
java.io.IOException

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Description copied from interface: InputFormat
Returns true, if this InputFormat can readFigures TransferData using the specified DataFlavor.

Specified by:
isDataFlavorSupported in interface InputFormat
Parameters:
flavor - A DataFlavor.

read

public void read(java.awt.datatransfer.Transferable t,
                 Drawing drawing,
                 boolean replace)
          throws java.awt.datatransfer.UnsupportedFlavorException,
                 java.io.IOException
Description copied from interface: InputFormat
Reads figures from the specified Transferable and adds them to the specified drawing.

Specified by:
read in interface InputFormat
Parameters:
t - The Transferable.
drawing - The drawing.
replace - Set this to true, if the contents of the transferable replaces the contents of the drawing (for example, when loading a drawing from a transferable). Set this to false, to add the contents of the transferable to the drawing (for example, when the transferable has been dropped or pasted into the drawing view).
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException