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