40 |
|
|
41 |
import java.util.HashMap; |
import java.util.HashMap; |
42 |
import java.util.Map; |
import java.util.Map; |
43 |
|
import java.util.List; |
44 |
|
|
45 |
/** |
/** |
46 |
* This class maps between native platform type names and DataFlavors. |
* This class maps between native platform type names and DataFlavors. |
48 |
* XXX - The current implementation does no mapping at all. |
* XXX - The current implementation does no mapping at all. |
49 |
* |
* |
50 |
* @author Mark Wielaard (mark@klomp.org) |
* @author Mark Wielaard (mark@klomp.org) |
|
*/ |
|
|
public final class SystemFlavorMap implements FlavorMap |
|
|
{ |
|
|
|
|
|
/** |
|
|
* The default (instance) flavor map. |
|
|
*/ |
|
|
private static FlavorMap defaultFlavorMap; |
|
|
|
|
|
/** |
|
|
* Private constructor. |
|
|
*/ |
|
|
private SystemFlavorMap() |
|
|
{ |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Maps the specified <code>DataFlavor</code> objects to the native |
|
|
* data type name. The returned <code>Map</code> has keys that are |
|
|
* the data flavors and values that are strings. The returned map |
|
|
* may be modified. This can be useful for implementing nested mappings. |
|
|
* |
|
|
* @param flavors An array of data flavors to map |
|
|
* or null for all data flavors. |
|
51 |
* |
* |
52 |
* @return A <code>Map</code> of native data types to data flavors. |
* @since 1.2 |
|
*/ |
|
|
public Map |
|
|
getNativesForFlavors(DataFlavor[] flavors) |
|
|
{ |
|
|
return(new HashMap()); |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Maps the specified native type names to <code>DataFlavor</code>'s. |
|
|
* The returned <code>Map</code> has keys that are strings and values |
|
|
* that are <code>DataFlavor</code>'s. The returned map may be |
|
|
* modified. This can be useful for implementing nested mappings. |
|
|
* |
|
|
* @param natives An array of native types to map |
|
|
* or null for all native types. |
|
|
* |
|
|
* @return A <code>Map</code> of data flavors to native type names. |
|
|
*/ |
|
|
public Map |
|
|
getFlavorsForNatives(String[] natives) |
|
|
{ |
|
|
return(new HashMap()); |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Returns the default (instance) (System)FlavorMap. |
|
|
*/ |
|
|
public static FlavorMap |
|
|
getDefaultFlavorMap() |
|
|
{ |
|
|
if (defaultFlavorMap == null) |
|
|
defaultFlavorMap = new SystemFlavorMap(); |
|
|
|
|
|
return(defaultFlavorMap); |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Returns the native type name for the given java mime type. |
|
|
*/ |
|
|
public static String |
|
|
encodeJavaMIMEType(String mime) |
|
|
{ |
|
|
return null; |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Returns the native type name for the given data flavor. |
|
|
*/ |
|
|
public static String |
|
|
encodeDataFlavor(DataFlavor df) |
|
|
{ |
|
|
return null; |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Returns true if the native type name can be represented as |
|
|
* a java mime type. |
|
|
*/ |
|
|
public static boolean |
|
|
isJavaMIMEType(String name) |
|
|
{ |
|
|
return(false); |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Returns the java mime type for the given the native type name. |
|
53 |
*/ |
*/ |
54 |
public static String |
public final class SystemFlavorMap implements FlavorMap, FlavorTable |
|
decodeJavaMIMEType(String name) |
|
55 |
{ |
{ |
56 |
return null; |
/** |
57 |
} |
* The default (instance) flavor map. |
58 |
|
*/ |
59 |
/*************************************************************************/ |
private static FlavorMap defaultFlavorMap; |
60 |
|
|
61 |
/** |
/** |
62 |
* Returns the data flavor given the native type name |
* Private constructor. |
63 |
* or null when no such data flavor exists. |
*/ |
64 |
*/ |
private SystemFlavorMap () |
65 |
public static DataFlavor |
{ |
66 |
decodeDataFlavor(String name) throws ClassNotFoundException |
} |
67 |
{ |
|
68 |
String javaMIMEType = decodeJavaMIMEType(name); |
/** |
69 |
if (javaMIMEType != null) |
* Maps the specified <code>DataFlavor</code> objects to the native |
70 |
return(new DataFlavor(javaMIMEType)); |
* data type name. The returned <code>Map</code> has keys that are |
71 |
else |
* the data flavors and values that are strings. The returned map |
72 |
return(null); |
* may be modified. This can be useful for implementing nested mappings. |
73 |
} |
* |
74 |
|
* @param flavors An array of data flavors to map |
75 |
|
* or null for all data flavors. |
76 |
|
* |
77 |
|
* @return A <code>Map</code> of native data types to data flavors. |
78 |
|
*/ |
79 |
|
public Map getNativesForFlavors (DataFlavor[] flavors) |
80 |
|
{ |
81 |
|
return new HashMap(); |
82 |
|
} |
83 |
|
|
84 |
|
/** |
85 |
|
* Maps the specified native type names to <code>DataFlavor</code>'s. |
86 |
|
* The returned <code>Map</code> has keys that are strings and values |
87 |
|
* that are <code>DataFlavor</code>'s. The returned map may be |
88 |
|
* modified. This can be useful for implementing nested mappings. |
89 |
|
* |
90 |
|
* @param natives An array of native types to map |
91 |
|
* or null for all native types. |
92 |
|
* |
93 |
|
* @return A <code>Map</code> of data flavors to native type names. |
94 |
|
*/ |
95 |
|
public Map getFlavorsForNatives (String[] natives) |
96 |
|
{ |
97 |
|
return new HashMap(); |
98 |
|
} |
99 |
|
|
100 |
|
/** |
101 |
|
* Returns the default (instance) (System)FlavorMap. |
102 |
|
*/ |
103 |
|
public static FlavorMap getDefaultFlavorMap () |
104 |
|
{ |
105 |
|
if (defaultFlavorMap == null) |
106 |
|
defaultFlavorMap = new SystemFlavorMap (); |
107 |
|
|
108 |
|
return defaultFlavorMap; |
109 |
|
} |
110 |
|
|
111 |
|
/** |
112 |
|
* Returns the native type name for the given java mime type. |
113 |
|
*/ |
114 |
|
public static String encodeJavaMIMEType (String mime) |
115 |
|
{ |
116 |
|
return null; |
117 |
|
} |
118 |
|
|
119 |
|
/** |
120 |
|
* Returns the native type name for the given data flavor. |
121 |
|
*/ |
122 |
|
public static String encodeDataFlavor (DataFlavor df) |
123 |
|
{ |
124 |
|
return null; |
125 |
|
} |
126 |
|
|
127 |
|
/** |
128 |
|
* Returns true if the native type name can be represented as |
129 |
|
* a java mime type. |
130 |
|
*/ |
131 |
|
public static boolean isJavaMIMEType (String name) |
132 |
|
{ |
133 |
|
return false; |
134 |
|
} |
135 |
|
|
136 |
|
/** |
137 |
|
* Returns the java mime type for the given the native type name. |
138 |
|
*/ |
139 |
|
public static String decodeJavaMIMEType (String name) |
140 |
|
{ |
141 |
|
return null; |
142 |
|
} |
143 |
|
|
144 |
|
/** |
145 |
|
* Returns the data flavor given the native type name |
146 |
|
* or null when no such data flavor exists. |
147 |
|
*/ |
148 |
|
public static DataFlavor decodeDataFlavor (String name) |
149 |
|
throws ClassNotFoundException |
150 |
|
{ |
151 |
|
String javaMIMEType = decodeJavaMIMEType (name); |
152 |
|
|
153 |
|
if (javaMIMEType != null) |
154 |
|
return new DataFlavor (javaMIMEType); |
155 |
|
else |
156 |
|
return null; |
157 |
|
} |
158 |
|
|
159 |
|
public List getFlavorsForNative (String nat) |
160 |
|
{ |
161 |
|
throw new Error ("Not implemented"); |
162 |
|
} |
163 |
|
|
164 |
|
public List getNativesForFlavor (DataFlavor flav) |
165 |
|
{ |
166 |
|
throw new Error ("Not implemented"); |
167 |
|
} |
168 |
|
|
169 |
} // class SystemFlavorMap |
} // class SystemFlavorMap |
|
|
|