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