Home | History | Annotate | Download | only in text
      1 /* GENERATED SOURCE. DO NOT MODIFY. */
      2 /*
      3  *******************************************************************************
      4  * Copyright (C) 2000-2009, International Business Machines Corporation and    *
      5  * others. All Rights Reserved.                                                *
      6  *******************************************************************************
      7  */
      8 /* Written by Simon Montagu, Matitiahu Allouche
      9  * (ported from C code written by Markus W. Scherer)
     10  */
     11 
     12 package android.icu.text;
     13 
     14 /**
     15  * Overrides default Bidi class values with custom ones.
     16  *
     17  * <p>The override mechanism requires to define a subclass of
     18  * <code>BidiClassifier</code> which overrides the <code>classifier</code>
     19  * method to assign customized Bidi classes.</p>
     20  *
     21  * <p>This may be useful for assigning Bidi classes to PUA characters, or
     22  * for special application needs. For instance, an application may want to
     23  * handle all spaces like L or R characters (according to the base direction)
     24  * when creating the visual ordering of logical lines which are part of a report
     25  * organized in columns: there should not be interaction between adjacent
     26  * cells.</p>
     27  *
     28  * <p>To start using this customized
     29  * classifier with a Bidi object, it must be specified by calling the
     30  * <code>Bidi.setCustomClassifier</code> method; after that, the method
     31  * <code>classify</code> of the custom <code>BidiClassifier</code> will be
     32  * called by the UBA implementation any time the class of a character is
     33  * to be determined.</p>
     34  *
     35  * @see Bidi#setCustomClassifier
     36  * @hide Only a subset of ICU is exposed in Android
     37  */
     38 
     39 public /*abstract*/ class BidiClassifier {
     40 
     41     /**
     42      * This object can be used for any purpose by the caller to pass
     43      * information to the BidiClassifier methods, and by the BidiClassifier
     44      * methods themselves.<br>
     45      * For instance, this object can be used to save a reference to
     46      * a previous custom BidiClassifier while setting a new one, so as to
     47      * allow chaining between them.
     48      */
     49     protected Object context;
     50 
     51     /**
     52      * @param context Context for this classifier instance.
     53      *                May be null.
     54      */
     55     public BidiClassifier(Object context) {
     56         this.context = context;
     57     }
     58 
     59     /**
     60      * Sets classifier context, which can be used either by a caller or
     61      * callee for various purposes.
     62      *
     63      * @param context Context for this classifier instance.
     64      *                May be null.
     65      */
     66     public void setContext(Object context) {
     67         this.context = context;
     68     }
     69 
     70     /**
     71      * Returns the current classifier context.
     72      */
     73     public Object getContext() {
     74         return this.context;
     75     }
     76 
     77     /**
     78      * Gets customized Bidi class for the code point <code>c</code>.
     79      * <p>
     80      * Default implementation, to be overridden.
     81      *
     82      * @param c Code point to be classified.
     83      * @return An integer representing directional property / Bidi class for the
     84      *         given code point <code>c</code>, or CLASS_DEFAULT to signify
     85      *         that there is no need to override the standard Bidi class for
     86      *         the given code point.
     87      * @see Bidi#CLASS_DEFAULT
     88      */
     89     public int classify(int c) {
     90         return Bidi.CLASS_DEFAULT;
     91     }
     92 }
     93