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