/[classpath]/classpath/java/awt/datatransfer/SystemFlavorMap.java
ViewVC logotype

Diff of /classpath/java/awt/datatransfer/SystemFlavorMap.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by roehrijn, Wed Nov 30 00:59:57 2005 UTC revision 1.10 by roehrijn, Wed Nov 30 01:46:47 2005 UTC
# Line 62  public final class SystemFlavorMap imple Line 62  public final class SystemFlavorMap imple
62    private static final Map systemFlavorMaps = new WeakHashMap();    private static final Map systemFlavorMaps = new WeakHashMap();
63        
64    /**    /**
65       * Constant which is used to prefix encode Java MIME types.
66       */
67      private static final String GNU_JAVA_MIME_PREFIX = "gnu.java:";
68      
69      /**
70     * This map maps native <code>String</code>s to lists of     * This map maps native <code>String</code>s to lists of
71     * <code>DataFlavor</code>s     * <code>DataFlavor</code>s
72     */     */
# Line 72  public final class SystemFlavorMap imple Line 77  public final class SystemFlavorMap imple
77     * <code>String</code>s     * <code>String</code>s
78     */     */
79    private HashMap flavorToNativeMap = new HashMap();    private HashMap flavorToNativeMap = new HashMap();
80      
81    /**    /**
82     * Private constructor.     * Private constructor.
83     */     */
# Line 141  public final class SystemFlavorMap imple Line 146  public final class SystemFlavorMap imple
146    }    }
147    
148    /**    /**
149     * Returns the native type name for the given java mime type.     * Encodes a MIME type for use as a <code>String</code> native. The format
150       * of an encoded representation of a MIME type is implementation-dependent.
151       * The only restrictions are:
152       * <ul>
153       * <li>The encoded representation is <code>null</code> if and only if the
154       * MIME type <code>String</code> is <code>null</code>.</li>
155       * <li>The encoded representations for two non-<code>null</code> MIME type
156       * <code>String</code>s are equal if and only if these <code>String</code>s
157       * are equal according to <code>String.equals(Object)</code>.</li>
158       * </ul>
159       * <p>
160       * The present implementation of this method returns the specified MIME
161       * type <code>String</code> prefixed with <code>gnu.java:</code>.
162       *
163       * @param mime the MIME type to encode
164       * @return the encoded <code>String</code>, or <code>null</code> if
165       *         mimeType is <code>null</code>
166     */     */
167    public static String encodeJavaMIMEType (String mime)    public static String encodeJavaMIMEType (String mime)
168    {    {
169      return null;      if (mime != null)
170          return GNU_JAVA_MIME_PREFIX + mime;
171        else
172          return null;
173    }    }
174    
175    /**    /**
176     * Returns the native type name for the given data flavor.     * Encodes a <code>DataFlavor</code> for use as a <code>String</code>
177       * native. The format of an encoded <code>DataFlavor</code> is
178       * implementation-dependent. The only restrictions are:
179       * <ul>
180       * <li>The encoded representation is <code>null</code> if and only if the
181       * specified <code>DataFlavor</code> is <code>null</code> or its MIME type
182       * <code>String</code> is <code>null</code>.</li>
183       * <li>The encoded representations for two non-<code>null</code>
184       * <code>DataFlavor</code>s with non-<code>null</code> MIME type
185       * <code>String</code>s are equal if and only if the MIME type
186       * <code>String</code>s of these <code>DataFlavor</code>s are equal
187       * according to <code>String.equals(Object)</code>.</li>
188       * </ul>
189       * <p>
190       * The present implementation of this method returns the MIME type
191       * <code>String</code> of the specified <code>DataFlavor</code> prefixed
192       * with <code>gnu.java:</code>.
193       *
194       * @param df the <code>DataFlavor</code> to encode
195       * @return the encoded <code>String</code>, or <code>null</code> if
196       *         flav is <code>null</code> or has a <code>null</code> MIME type
197     */     */
198    public static String encodeDataFlavor (DataFlavor df)    public static String encodeDataFlavor (DataFlavor df)
199    {    {
200      return null;      if (df != null)
201          {
202            return encodeJavaMIMEType(df.getMimeType());
203          }
204        else
205          return null;
206    }    }
207    
208    /**    /**
209     * Returns true if the native type name can be represented as     * Returns true if the native type name can be represented as
210     * a java mime type.     * a java mime type. Returns <code>false</code> if parameter is
211       * <code>null</code>.
212     */     */
213    public static boolean isJavaMIMEType (String name)    public static boolean isJavaMIMEType (String name)
214    {    {
215      return false;      return (name != null && name.startsWith(GNU_JAVA_MIME_PREFIX));
216    }    }
217    
218    /**    /**
219     * Returns the java mime type for the given the native type name.     * Decodes a <code>String</code> native for use as a Java MIME type.
220       *
221       * @param name the <code>String</code> to decode
222       * @return the decoded Java MIME type, or <code>null</code> if nat
223       *         is not an encoded <code>String</code> native
224     */     */
225    public static String decodeJavaMIMEType (String name)    public static String decodeJavaMIMEType (String name)
226    {    {
227      return null;      if (isJavaMIMEType(name))
228          {
229            return name.substring(GNU_JAVA_MIME_PREFIX.length());
230          }
231        else
232          return null;
233    }    }
234    
235    /**    /**
# Line 188  public final class SystemFlavorMap imple Line 247  public final class SystemFlavorMap imple
247        return null;        return null;
248    }    }
249    
250      /**
251       * Returns a List of <code>DataFlavors</code> to which the specified
252       * <code>String</code> native can be translated by the data transfer
253       * subsystem. The <code>List</code> will be sorted from best
254       * <code>DataFlavor</code> to worst. That is, the first <code>DataFlavor
255       * </code> will best reflect data in the specified native to a Java
256       * application.
257       * <p>
258       * If the specified native is previously unknown to the data transfer
259       * subsystem, and that native has been properly encoded, then invoking
260       * this method will establish a mapping in both directions between the
261       * specified native and a DataFlavor whose MIME type is a decoded
262       * version of the native.
263       */
264    public List getFlavorsForNative (String nat)    public List getFlavorsForNative (String nat)
265    {    {
266      throw new Error ("Not implemented");      throw new Error ("Not implemented");

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26