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