2 *******************************************************************************
\r
3 * Copyright (C) 2000-2009, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 *******************************************************************************
\r
7 /* Written by Simon Montagu, Matitiahu Allouche
\r
8 * (ported from C code written by Markus W. Scherer)
\r
11 package com.ibm.icu.text;
\r
14 * Overrides default Bidi class values with custom ones.
\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
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
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
34 * @see Bidi#setCustomClassifier
\r
38 public /*abstract*/ class BidiClassifier {
\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
49 protected Object context;
\r
52 * @param context Context for this classifier instance.
\r
56 public BidiClassifier(Object context) {
\r
57 this.context = context;
\r
61 * Sets classifier context, which can be used either by a caller or
\r
62 * callee for various purposes.
\r
64 * @param context Context for this classifier instance.
\r
68 public void setContext(Object context) {
\r
69 this.context = context;
\r
73 * Returns the current classifier context.
\r
76 public Object getContext() {
\r
77 return this.context;
\r
81 * Gets customized Bidi class for the code point <code>c</code>.
\r
83 * Default implementation, to be overridden.
\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
93 public int classify(int c) {
\r
94 return Bidi.CLASS_DEFAULT;
\r