JavaScript is disabled on your browser.
javolution.text

Annotation Type DefaultTextFormat



  • @Documented
    @Inherited
    @Target(value=TYPE)
    @Retention(value=RUNTIME)
    public @interface DefaultTextFormat

    Specifies the default text format of a class (for parsing/formatting). The default format is typically used by the Object.toString() method and can be locally overridden in the scope of a TextContext.

     @DefaultTextFormat(Complex.Cartesian.class) 
     public class Complex {
     public String toString() { // Uses the default format unless locally overridden.
     return TextContext.toString(this);
     }
     public static Complex valueOf(CharSequence csq) {
     return TextContext.parse(csq, Complex.class);
     }
     public static class Cartesian extends TextFormat<Complex> { ... }
     public static class Polar extends TextFormat<Complex> { ... }
     }
     ...
     TextContext ctx = TextContext.enter(); // Enters a local textual context.
     try {
     ctx.setFormat(Complex.class, new Complex.Polar()); // Configure the local context.
     System.out.println(complexMatrix); // Displays complex numbers in polar coordinates.
     } finally {
     ctx.exit(); // Exits local context (reverts to previous Cartesian format).
     }
    Version:
    6.0, July 21, 2013
    Author:
    Jean-Marie Dautelle
    • Required Element Summary

      Required Elements
      Modifier and Type Required Element and Description
      Class<? extends TextFormat<?>> value
      Returns the default text format of the annotated class.
    • Element Detail

      • value

        public abstract Class<? extends TextFormat<?>> value
        Returns the default text format of the annotated class.

Copyright © 2005-2013 Javolution. All Rights Reserved.

AltStyle によって変換されたページ (->オリジナル) /