Javolution 6.0.0 java
javolution.util.FastCollection< E >.Format Class Reference
Inheritance diagram for javolution.util.FastCollection< E >.Format:
[legend]
Collaboration diagram for javolution.util.FastCollection< E >.Format:
[legend]

Public Member Functions

FastCollection< Object > parse (CharSequence csq, Cursor cursor) throws IllegalArgumentException
 
Appendable format (FastCollection<?> that, final Appendable dest) throws IOException
 
parse (CharSequence csq) throws IllegalArgumentException
 
abstract Appendable format (T obj, Appendable dest) throws IOException
 
TextBuilder format (T obj, TextBuilder dest)
 
String format (T obj)
 

Detailed Description

Default text format for fast collections (parsing not supported). It is the format used when printing standard

java.util.Collection


instances except that the elements themselves are written using their TextContext format.

Definition at line 663 of file FastCollection.java.

Member Function Documentation

◆ format() [1/4]

Appendable javolution.util.FastCollection< E >.Format.format ( FastCollection<?>  that,
final Appendable  dest 
) throws IOException

Definition at line 672 of file FastCollection.java.

673  {
674  dest.append('[');
675  Class<?> elementType = null;
676  TextFormat<Object> format = null;
677  for (Object element : that) {
678  if (elementType == null) elementType = Void.class;
679  else dest.append(", "); // Not the first.
680  if (element == null) {
681  dest.append("null");
682  continue;
683  }
684  Class<?> cls = element.getClass();
685  if (elementType.equals(cls)) {
686  format.format(element, dest);
687  continue;
688  }
689  elementType = cls;
690  format = TextContext.getFormat(cls);
691  format.format(element, dest);
692  }
693  return dest.append(']');
694  }

References javolution.text.TextFormat< T >.format(), and javolution.text.TextContext.getFormat().

Here is the call graph for this function:

◆ format() [2/4]

String javolution.text.TextFormat< T >.format ( obj)
inherited

Convenience method to format the specified object to a String.

Parameters
objthe object to format.
Returns
the formatting result as a string.

Definition at line 121 of file TextFormat.java.

121  {
122  return this.format(obj, new TextBuilder()).toString();
123 
124  }

◆ format() [3/4]

abstract Appendable javolution.text.TextFormat< T >.format ( obj,
Appendable  dest 
) throws IOException
abstractinherited

Formats the specified object into an Appendable

Parameters
objthe object to format.
destthe appendable destination.
Returns
the specified Appendable.

Referenced by javolution.text.TextBuilder.append(), javolution.text.TextFormat< FastCollection<?> >.format(), and javolution.util.FastCollection< E >.Format.format().

Here is the caller graph for this function:

◆ format() [4/4]

TextBuilder javolution.text.TextFormat< T >.format ( obj,
TextBuilder  dest 
)
inherited

Convenience method to format the specified object to a TextBuilder; unlike the abstract format method, this method does not throw IOException.

Parameters
objthe object to format.
destthe appendable destination.
Returns
the specified TextBuilder.

Definition at line 106 of file TextFormat.java.

106  {
107  try {
108  this.format(obj, (Appendable) dest);
109  return dest;
110  } catch (IOException e) {
111  throw new Error(e); // Cannot happens.
112  }
113  }

◆ parse() [1/2]

T javolution.text.TextFormat< T >.parse ( CharSequence  csq) throws IllegalArgumentException
inherited

Convenience method to parse the whole character sequence; if there are unread extraneous characters after parsing then an exception is raised.

Parameters
csqthe CharSequence to parse from the first character to the last.
Exceptions
IllegalArgumentExceptionif the syntax of the specified character sequence is incorrect or if there are extraneous characters at the end not parsed.

Definition at line 89 of file TextFormat.java.

89  {
90  Cursor cursor = new Cursor();
91  T obj = parse(csq, cursor);
92  if (!cursor.atEnd(csq))
93  throw new IllegalArgumentException("Extraneous character(s) \""
94  + cursor.tail(csq) + "\"");
95  return obj;
96  }

◆ parse() [2/2]

FastCollection<Object> javolution.util.FastCollection< E >.Format.parse ( CharSequence  csq,
Cursor  cursor 
) throws IllegalArgumentException

Reads a portion of the specified CharSequence from the specified cursor position to produce an object. If parsing succeeds, then the index of the cursor argument is updated to the index after the last character used.

Parameters
csqthe character sequence to parse.
cursorthe cursor holding the current parsing index.
Returns
the object parsed.
Exceptions
IllegalArgumentExceptionif the syntax of the specified character sequence is incorrect.
UnsupportedOperationExceptionif parsing is not supported.

Reimplemented from javolution.text.TextFormat< T >.

Definition at line 666 of file FastCollection.java.

667  {
668  throw new UnsupportedOperationException();
669  }

The documentation for this class was generated from the following file:
javolution.text.TextFormat.parse
abstract T parse(CharSequence csq, Cursor cursor)
javolution.text.TextFormat.format
abstract Appendable format(T obj, Appendable dest)
javolution.util.FastCollection.Format.format
Appendable format(FastCollection<?> that, final Appendable dest)
Definition: FastCollection.java:672