java.text.AttributedCharacterIterator.Attribute

Here are the examples of the java api class java.text.AttributedCharacterIterator.Attribute taken from open source projects.

1. ReadResolve#doSerializationCycle()

Project: openjdk
File: ReadResolve.java
static Attribute doSerializationCycle(Attribute attribute) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(attribute);
    oos.flush();
    byte[] data = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    ObjectInputStream ois = new ObjectInputStream(bais);
    Attribute result = (Attribute) ois.readObject();
    return result;
}

2. ReadResolve#main()

Project: openjdk
File: ReadResolve.java
public static void main(String[] args) throws Exception {
    testSerializationCycle(Attribute.LANGUAGE);
    testSerializationCycle(TextAttribute.INPUT_METHOD_HIGHLIGHT);
    boolean gotException = false;
    Attribute result = null;
    try {
        result = doSerializationCycle(FakeAttribute.LANGUAGE);
    } catch (Throwable e) {
        gotException = true;
    }
    if (!gotException) {
        throw new RuntimeException("Attribute should throw an exception when given a fake \"language\" attribute. Deserialized object: " + result);
    }
}

3. ReadResolve#testSerializationCycle()

Project: openjdk
File: ReadResolve.java
static void testSerializationCycle(Attribute attribute) throws Exception {
    Attribute result = doSerializationCycle(attribute);
    if (result != attribute) {
        throw new RuntimeException("attribute changed identity during serialization/deserialization");
    }
}

4. Font#getAvailableAttributes()

Project: openjdk
File: Font.java
/**
     * Returns the keys of all the attributes supported by this
     * {@code Font}.  These attributes can be used to derive other
     * fonts.
     * @return an array containing the keys of all the attributes
     *          supported by this {@code Font}.
     * @since 1.2
     */
public Attribute[] getAvailableAttributes() {
    // FONT is not supported by Font
    Attribute attributes[] = { TextAttribute.FAMILY, TextAttribute.WEIGHT, TextAttribute.WIDTH, TextAttribute.POSTURE, TextAttribute.SIZE, TextAttribute.TRANSFORM, TextAttribute.SUPERSCRIPT, TextAttribute.CHAR_REPLACEMENT, TextAttribute.FOREGROUND, TextAttribute.BACKGROUND, TextAttribute.UNDERLINE, TextAttribute.STRIKETHROUGH, TextAttribute.RUN_DIRECTION, TextAttribute.BIDI_EMBEDDING, TextAttribute.JUSTIFICATION, TextAttribute.INPUT_METHOD_HIGHLIGHT, TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.SWAP_COLORS, TextAttribute.NUMERIC_SHAPING, TextAttribute.KERNING, TextAttribute.LIGATURES, TextAttribute.TRACKING };
    return attributes;
}

5. Font#getAvailableAttributes()

Project: jdk7u-jdk
File: Font.java
/**
     * Returns the keys of all the attributes supported by this
     * <code>Font</code>.  These attributes can be used to derive other
     * fonts.
     * @return an array containing the keys of all the attributes
     *          supported by this <code>Font</code>.
     * @since 1.2
     */
public Attribute[] getAvailableAttributes() {
    // FONT is not supported by Font
    Attribute attributes[] = { TextAttribute.FAMILY, TextAttribute.WEIGHT, TextAttribute.WIDTH, TextAttribute.POSTURE, TextAttribute.SIZE, TextAttribute.TRANSFORM, TextAttribute.SUPERSCRIPT, TextAttribute.CHAR_REPLACEMENT, TextAttribute.FOREGROUND, TextAttribute.BACKGROUND, TextAttribute.UNDERLINE, TextAttribute.STRIKETHROUGH, TextAttribute.RUN_DIRECTION, TextAttribute.BIDI_EMBEDDING, TextAttribute.JUSTIFICATION, TextAttribute.INPUT_METHOD_HIGHLIGHT, TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.SWAP_COLORS, TextAttribute.NUMERIC_SHAPING, TextAttribute.KERNING, TextAttribute.LIGATURES, TextAttribute.TRACKING };
    return attributes;
}