FileDocCategorySizeDatePackage
PatternEntry.javaAPI DocJava SE 5 API9615Fri Aug 26 14:57:20 BST 2005java.text

PatternEntry

public class PatternEntry extends Object
Utility class for normalizing and merging patterns for collation. This is to be used with MergeCollation for adding patterns to an existing rule table.
see
MergeCollation
version
1.25 12/19/03
author
Mark Davis, Helena Shih

Fields Summary
static final int
RESET
static final int
UNSET
int
strength
String
chars
String
extension
Constructors Summary
PatternEntry(int strength, StringBuffer chars, StringBuffer extension)

        this.strength = strength;
        this.chars = chars.toString();
        this.extension = (extension.length() > 0) ? extension.toString()
                                                  : "";
    
Methods Summary
voidaddToBuffer(java.lang.StringBuffer toAddTo, boolean showExtension, boolean showWhiteSpace, java.text.PatternEntry lastEntry)

        if (showWhiteSpace && toAddTo.length() > 0)
            if (strength == Collator.PRIMARY || lastEntry != null)
                toAddTo.append('\n");
            else
                toAddTo.append(' ");
        if (lastEntry != null) {
            toAddTo.append('&");
            if (showWhiteSpace)
                toAddTo.append(' ");
            lastEntry.appendQuotedChars(toAddTo);
            appendQuotedExtension(toAddTo);
            if (showWhiteSpace)
                toAddTo.append(' ");
        }
        switch (strength) {
        case Collator.IDENTICAL: toAddTo.append('="); break;
        case Collator.TERTIARY:  toAddTo.append(',"); break;
        case Collator.SECONDARY: toAddTo.append(';"); break;
        case Collator.PRIMARY:   toAddTo.append('<"); break;
        case RESET: toAddTo.append('&"); break;
        case UNSET: toAddTo.append('?"); break;
        }
        if (showWhiteSpace)
            toAddTo.append(' ");
        appendQuoted(chars,toAddTo);
        if (showExtension && extension.length() != 0) {
            toAddTo.append('/");
            appendQuoted(extension,toAddTo);
        }
    
static voidappendQuoted(java.lang.String chars, java.lang.StringBuffer toAddTo)

        boolean inQuote = false;
        char ch = chars.charAt(0);
        if (Character.isSpaceChar(ch)) {
            inQuote = true;
            toAddTo.append('\'");
        } else {
          if (PatternEntry.isSpecialChar(ch)) {
                inQuote = true;
                toAddTo.append('\'");
            } else {
                switch (ch) {
                    case 0x0010: case '\f": case '\r":
                    case '\t": case '\n":  case '@":
                    inQuote = true;
                    toAddTo.append('\'");
                    break;
                case '\'":
                    inQuote = true;
                    toAddTo.append('\'");
                    break;
                default:
                    if (inQuote) {
                        inQuote = false; toAddTo.append('\'");
                    }
                    break;
                }
           }
        }
        toAddTo.append(chars);
        if (inQuote)
            toAddTo.append('\'");
    
public voidappendQuotedChars(java.lang.StringBuffer toAddTo)
Gets the current chars, quoted

        appendQuoted(chars,toAddTo);
    
public voidappendQuotedExtension(java.lang.StringBuffer toAddTo)
Gets the current extension, quoted

        appendQuoted(extension,toAddTo);
    
public booleanequals(java.lang.Object obj)
WARNING this is used for searching in a Vector. Because Vector.indexOf doesn't take a comparator, this method is ill-defined and ignores strength.

        if (obj == null) return false;
        PatternEntry other = (PatternEntry) obj;
        boolean result = chars.equals(other.chars);
        return result;
    
final java.lang.StringgetChars()
Gets the core characters of the entry.

        return chars;
    
final java.lang.StringgetExtension()
Gets the expanding characters of the entry.

        return extension;
    
final intgetStrength()
Gets the strength of the entry.

        return strength;
    
public inthashCode()

        return chars.hashCode();
    
static booleanisSpecialChar(char ch)

        
    
        
        
        return ((ch == '\u0020") ||
		((ch <= '\u002F") && (ch >= '\u0022")) ||
                ((ch <= '\u003F") && (ch >= '\u003A")) ||
                ((ch <= '\u0060") && (ch >= '\u005B")) ||
                ((ch <= '\u007E") && (ch >= '\u007B")));
    
public java.lang.StringtoString()
For debugging.

        StringBuffer result = new StringBuffer();
        addToBuffer(result, true, false, null);
        return result.toString();