< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java

Print this page




2627                 if (richText == null) {
2628                     return null;
2629                 }
2630 
2631                 try {
2632                     DataFlavor[] flavors = new DataFlavor[3];
2633                     flavors[0] = new DataFlavor(mimeType + ";class=java.lang.String");
2634                     flavors[1] = new DataFlavor(mimeType + ";class=java.io.Reader");
2635                     flavors[2] = new DataFlavor(mimeType + ";class=java.io.InputStream;charset=unicode");
2636                     return flavors;
2637                 } catch (ClassNotFoundException cle) {
2638                     // fall through to unsupported (should not happen)
2639                 }
2640 
2641                 return null;
2642             }
2643 
2644             /**
2645              * The only richer format supported is the file list flavor
2646              */

2647             protected Object getRicherData(DataFlavor flavor) throws UnsupportedFlavorException {
2648                 if (richText == null) {
2649                     return null;
2650                 }
2651 
2652                 if (String.class.equals(flavor.getRepresentationClass())) {
2653                     return richText;
2654                 } else if (Reader.class.equals(flavor.getRepresentationClass())) {
2655                     return new StringReader(richText);
2656                 } else if (InputStream.class.equals(flavor.getRepresentationClass())) {
2657                     return new StringBufferInputStream(richText);
2658                 }
2659                 throw new UnsupportedFlavorException(flavor);
2660             }
2661 
2662             Position p0;
2663             Position p1;
2664             String mimeType;
2665             String richText;
2666             JTextComponent c;


2627                 if (richText == null) {
2628                     return null;
2629                 }
2630 
2631                 try {
2632                     DataFlavor[] flavors = new DataFlavor[3];
2633                     flavors[0] = new DataFlavor(mimeType + ";class=java.lang.String");
2634                     flavors[1] = new DataFlavor(mimeType + ";class=java.io.Reader");
2635                     flavors[2] = new DataFlavor(mimeType + ";class=java.io.InputStream;charset=unicode");
2636                     return flavors;
2637                 } catch (ClassNotFoundException cle) {
2638                     // fall through to unsupported (should not happen)
2639                 }
2640 
2641                 return null;
2642             }
2643 
2644             /**
2645              * The only richer format supported is the file list flavor
2646              */
2647             @SuppressWarnings("deprecation")
2648             protected Object getRicherData(DataFlavor flavor) throws UnsupportedFlavorException {
2649                 if (richText == null) {
2650                     return null;
2651                 }
2652 
2653                 if (String.class.equals(flavor.getRepresentationClass())) {
2654                     return richText;
2655                 } else if (Reader.class.equals(flavor.getRepresentationClass())) {
2656                     return new StringReader(richText);
2657                 } else if (InputStream.class.equals(flavor.getRepresentationClass())) {
2658                     return new StringBufferInputStream(richText);
2659                 }
2660                 throw new UnsupportedFlavorException(flavor);
2661             }
2662 
2663             Position p0;
2664             Position p1;
2665             String mimeType;
2666             String richText;
2667             JTextComponent c;
< prev index next >