< prev index next >

src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/Translator.java

Print this page




 104      * passed in already implements interface {@code Accessible}, {@code getAccessible}
 105      * merely returns the object.
 106      *
 107      * @param o an Object; if a null is passed in a null is returned
 108      * @return an {@code Object}, possibly the {@code Object} passed in, that
 109      *     implements the {@code Accessible} interface for the {@code Object}
 110      *     which was passed in
 111      */
 112     public static Accessible getAccessible(Object o) {
 113         Accessible a = null;
 114 
 115         if (o == null) {
 116             return null;
 117         }
 118         if (o instanceof Accessible) {
 119             a = (Accessible)o;
 120         } else {
 121             Class<?> translatorClass = getTranslatorClass(o.getClass());
 122             if (translatorClass != null) {
 123                 try {

 124                     Translator t = (Translator)translatorClass.newInstance();
 125                     t.setSource(o);
 126                     a = t;
 127                 } catch (Exception e) {
 128                 }
 129             }
 130         }
 131         if (a == null) {
 132             a = new Translator(o);
 133         }
 134         return a;
 135     }
 136 
 137     /**
 138      * Create a new {@code Translator}.  You must call the {@link #setSource setSource}
 139      * method to set the object to be translated after calling this constructor.
 140      */
 141     public Translator() {
 142     }
 143 




 104      * passed in already implements interface {@code Accessible}, {@code getAccessible}
 105      * merely returns the object.
 106      *
 107      * @param o an Object; if a null is passed in a null is returned
 108      * @return an {@code Object}, possibly the {@code Object} passed in, that
 109      *     implements the {@code Accessible} interface for the {@code Object}
 110      *     which was passed in
 111      */
 112     public static Accessible getAccessible(Object o) {
 113         Accessible a = null;
 114 
 115         if (o == null) {
 116             return null;
 117         }
 118         if (o instanceof Accessible) {
 119             a = (Accessible)o;
 120         } else {
 121             Class<?> translatorClass = getTranslatorClass(o.getClass());
 122             if (translatorClass != null) {
 123                 try {
 124                     @SuppressWarnings("deprecation")
 125                     Translator t = (Translator)translatorClass.newInstance();
 126                     t.setSource(o);
 127                     a = t;
 128                 } catch (Exception e) {
 129                 }
 130             }
 131         }
 132         if (a == null) {
 133             a = new Translator(o);
 134         }
 135         return a;
 136     }
 137 
 138     /**
 139      * Create a new {@code Translator}.  You must call the {@link #setSource setSource}
 140      * method to set the object to be translated after calling this constructor.
 141      */
 142     public Translator() {
 143     }
 144 


< prev index next >