134 public synchronized Transferable getContents(Object requestor) { 135 if (contents != null) { 136 return contents; 137 } 138 return new ClipboardTransferable(this); 139 } 140 141 142 /** 143 * @return the contents of this clipboard if it has been set from the same 144 * AppContext as it is currently retrieved or null otherwise 145 * @since 1.5 146 */ 147 protected synchronized Transferable getContextContents() { 148 AppContext context = AppContext.getAppContext(); 149 return (context == contentsContext) ? contents : null; 150 } 151 152 153 /** 154 * @see java.awt.Clipboard#getAvailableDataFlavors 155 * @since 1.5 156 */ 157 public DataFlavor[] getAvailableDataFlavors() { 158 Transferable cntnts = getContextContents(); 159 if (cntnts != null) { 160 return cntnts.getTransferDataFlavors(); 161 } 162 163 long[] formats = getClipboardFormatsOpenClose(); 164 165 return DataTransferer.getInstance(). 166 getFlavorsForFormatsAsArray(formats, getDefaultFlavorTable()); 167 } 168 169 /** 170 * @see java.awt.Clipboard#isDataFlavorAvailable 171 * @since 1.5 172 */ 173 public boolean isDataFlavorAvailable(DataFlavor flavor) { 174 if (flavor == null) { 175 throw new NullPointerException("flavor"); 176 } 177 178 Transferable cntnts = getContextContents(); 179 if (cntnts != null) { 180 return cntnts.isDataFlavorSupported(flavor); 181 } 182 183 long[] formats = getClipboardFormatsOpenClose(); 184 185 return formatArrayAsDataFlavorSet(formats).contains(flavor); 186 } 187 188 /** 189 * @see java.awt.Clipboard#getData 190 * @since 1.5 191 */ 192 public Object getData(DataFlavor flavor) 193 throws UnsupportedFlavorException, IOException { 194 if (flavor == null) { 195 throw new NullPointerException("flavor"); 196 } 197 198 Transferable cntnts = getContextContents(); 199 if (cntnts != null) { 200 return cntnts.getTransferData(flavor); 201 } 202 203 long format = 0; 204 byte[] data = null; 205 Transferable localeTransferable = null; 206 207 try { 208 openClipboard(null); 209 | 134 public synchronized Transferable getContents(Object requestor) { 135 if (contents != null) { 136 return contents; 137 } 138 return new ClipboardTransferable(this); 139 } 140 141 142 /** 143 * @return the contents of this clipboard if it has been set from the same 144 * AppContext as it is currently retrieved or null otherwise 145 * @since 1.5 146 */ 147 protected synchronized Transferable getContextContents() { 148 AppContext context = AppContext.getAppContext(); 149 return (context == contentsContext) ? contents : null; 150 } 151 152 153 /** 154 * @see java.awt.datatransfer.Clipboard#getAvailableDataFlavors 155 * @since 1.5 156 */ 157 public DataFlavor[] getAvailableDataFlavors() { 158 Transferable cntnts = getContextContents(); 159 if (cntnts != null) { 160 return cntnts.getTransferDataFlavors(); 161 } 162 163 long[] formats = getClipboardFormatsOpenClose(); 164 165 return DataTransferer.getInstance(). 166 getFlavorsForFormatsAsArray(formats, getDefaultFlavorTable()); 167 } 168 169 /** 170 * @see java.awt.datatransfer.Clipboard#isDataFlavorAvailable 171 * @since 1.5 172 */ 173 public boolean isDataFlavorAvailable(DataFlavor flavor) { 174 if (flavor == null) { 175 throw new NullPointerException("flavor"); 176 } 177 178 Transferable cntnts = getContextContents(); 179 if (cntnts != null) { 180 return cntnts.isDataFlavorSupported(flavor); 181 } 182 183 long[] formats = getClipboardFormatsOpenClose(); 184 185 return formatArrayAsDataFlavorSet(formats).contains(flavor); 186 } 187 188 /** 189 * @see java.awt.datatransfer.Clipboard#getData 190 * @since 1.5 191 */ 192 public Object getData(DataFlavor flavor) 193 throws UnsupportedFlavorException, IOException { 194 if (flavor == null) { 195 throw new NullPointerException("flavor"); 196 } 197 198 Transferable cntnts = getContextContents(); 199 if (cntnts != null) { 200 return cntnts.getTransferData(flavor); 201 } 202 203 long format = 0; 204 byte[] data = null; 205 Transferable localeTransferable = null; 206 207 try { 208 openClipboard(null); 209 |