org.geotoolkit.parameter
Class ParameterWriter

Object
  extended by Writer
      extended by FilterWriter
          extended by ParameterWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, Localized

@Decorator(value=java.io.Writer.class)
public class ParameterWriter
extends FilterWriter
implements Localized

Formats parameter descriptors or parameter values in a tabular format. This writer assumes a monospaced font and an encoding capable to provide drawing box characters (e.g. unicode).

Since:
2.1
Version:
3.17
Author:
Martin Desruisseaux (IRD, Geomatys)
Module:
referencing/geotk-referencing (download)    View source code for this class

Field Summary
 
Fields inherited from class FilterWriter
out
 
Fields inherited from class Writer
lock
 
Constructor Summary
ParameterWriter()
          Creates a new formatter writing parameters to the console if there is one, or to the default output stream otherwise.
ParameterWriter(Writer out)
          Creates a new formatter writing parameters to the specified output writer.
 
Method Summary
 void format(OperationMethod operation)
          Prints the elements of an operation to the output stream.
 void format(ParameterDescriptorGroup descriptor)
          Prints the elements of a descriptor group to the output stream.
 void format(ParameterValueGroup values)
          Prints the elements of a parameter group to the output stream.
protected  String formatValue(Object value)
          Formats the specified value as a string.
 Set<String> getAuthorities()
          Returns the list of authorities to filter, or null if there is no restriction.
 Locale getLocale()
          Returns the current locale.
 boolean isBrief()
          Returns true if the table is formatted in a brief format.
 boolean isColorEnabled()
          Returns true if this writer is allowed to send color instructions for X3.64 compatible terminal.
static void print(OperationMethod operation)
          Prints the elements of an operation to the console with colored syntax if possible, or to the default output stream otherwise.
static void print(ParameterDescriptorGroup descriptor)
          Prints the elements of a descriptor group to the console with colored syntax if possible, or to the default output stream otherwise.
static void print(ParameterValueGroup values)
          Prints the elements of a parameter group to the console with colored syntax if possible, or to the default output stream otherwise.
 void setAuthorities(String... authorities)
          Sets the list of authorities to filter, or null for accepting all of them.
 void setBrief(boolean b)
          Sets whatever the table should formatted in a brief format.
 void setColorEnabled(boolean enabled)
          Sets whatever this writer is allowed to send color instructions for X3.64 compatible terminal.
 void setLocale(Locale locale)
          Sets the locale to use for table formatting.
 void summary(Collection<? extends IdentifiedObject> objects)
          Formats a summary of a collection of identified objects.
static String toString(ParameterDescriptorGroup descriptor)
          Returns a string representation of the given descriptor group in the brief format.
static String toString(ParameterValueGroup values)
          Returns a string representation of the given parameter group in the brief format.
 
Methods inherited from class FilterWriter
close, flush, write, write, write
 
Methods inherited from class Writer
append, append, append, write, write
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterWriter

public ParameterWriter()
Creates a new formatter writing parameters to the console if there is one, or to the default output stream otherwise. If the output is the console and the X3.64 standard is enabled, then the default value of isColorEnabled() will be true.


ParameterWriter

public ParameterWriter(Writer out)
Creates a new formatter writing parameters to the specified output writer.

Parameters:
out - Where to write the parameters.
Method Detail

print

public static void print(OperationMethod operation)
Prints the elements of an operation to the console with colored syntax if possible, or to the default output stream otherwise. This is a convenience method for:
new ParameterWriter().format(operation)

Parameters:
operation - The operation for which to write the parameters.

print

public static void print(ParameterDescriptorGroup descriptor)
Prints the elements of a descriptor group to the console with colored syntax if possible, or to the default output stream otherwise. This is a convenience method for:
new ParameterWriter().format(descriptor)

Parameters:
descriptor - The parameter descriptor to write.

print

public static void print(ParameterValueGroup values)
Prints the elements of a parameter group to the console with colored syntax if possible, or to the default output stream otherwise. This is a convenience method for:
new ParameterWriter().format(values)

Parameters:
values - The parameter values to write.

toString

public static String toString(ParameterDescriptorGroup descriptor)
Returns a string representation of the given descriptor group in the brief format. This is a convenience method for:
StringWriter    buffer = new StringWriter();
ParameterWriter writer = new ParameterWriter(buffer);
writer.setBrief(true);
writer.format(descriptor);
return buffer.toString();

Parameters:
descriptor - The parameter descriptor to format.
Returns:
The string representation of the given parameter descriptor.
Since:
3.17

toString

public static String toString(ParameterValueGroup values)
Returns a string representation of the given parameter group in the brief format. This is a convenience method for:
StringWriter    buffer = new StringWriter();
ParameterWriter writer = new ParameterWriter(buffer);
writer.setBrief(true);
writer.format(values);
return buffer.toString();

Parameters:
values - The parameter values to format.
Returns:
The string representation of the given parameter values.
Since:
3.17

format

public void format(OperationMethod operation)
            throws IOException
Prints the elements of an operation to the output stream.

Parameters:
operation - The operation method to format.
Throws:
IOException - if an error occurred will writing to the stream.

format

public void format(ParameterDescriptorGroup descriptor)
            throws IOException
Prints the elements of a descriptor group to the output stream.

Parameters:
descriptor - The descriptor group to format.
Throws:
IOException - if an error occurred will writing to the stream.

format

public void format(ParameterValueGroup values)
            throws IOException
Prints the elements of a parameter group to the output stream.

Parameters:
values - The parameter group to format.
Throws:
IOException - if an error occurred will writing to the stream.

summary

public void summary(Collection<? extends IdentifiedObject> objects)
             throws IOException
Formats a summary of a collection of identified objects. The objects may be parameters, available map projections, CRS, etc. The summary contains the identifier name and alias aligned in a table.

The table formatted by default may be quite large. It is recommended to invoke setAuthorities(java.lang.String...) before this method in order to reduce the amount of columns to display.

Parameters:
objects - The collection of objects to format.
Throws:
IOException - if an error occurred will writing to the stream.

getAuthorities

public Set<String> getAuthorities()
Returns the list of authorities to filter, or null if there is no restriction. If non-null, only name or alias of those authorities will be displayed. The default value is null.

Returns:
The authorities to filter, or null if no restriction.
Since:
3.00

setAuthorities

public void setAuthorities(String... authorities)
Sets the list of authorities to filter, or null for accepting all of them. The strings are authority names like "OGC", "EPSG", "ESRI" or "GeoTIFF". A few strings are treated especially:

Parameters:
authorities - The authorities to filter, or null for accepting all of them.
Since:
3.00

isBrief

public boolean isBrief()
Returns true if the table is formatted in a brief format. If true, then for each descriptor only the name is formatted; aliases and identifiers are omitted. In addition, no line separator will be inserted between parameters since most parameters will fit on a single line.

Returns:
true for the brief format, or false for the complete format.
Since:
3.17

setBrief

public void setBrief(boolean b)
Sets whatever the table should formatted in a brief format.

Parameters:
b - true for the brief format, or false for the complete format.
Since:
3.17

isColorEnabled

public boolean isColorEnabled()
Returns true if this writer is allowed to send color instructions for X3.64 compatible terminal. The default value is false, unless the no-argument constructor was used and the console seems to be compatible with the X3.64 standard.

Returns:
true if this writer is allowed to send X3.64 sequences.
Since:
3.00

setColorEnabled

public void setColorEnabled(boolean enabled)
Sets whatever this writer is allowed to send color instructions for X3.64 compatible terminal. This is used for example in order to emphases the identifier in a list of alias.

The default value is false, unless the no-argument constructor was used and the console seems to be compatible with the X3.64 standard.

Parameters:
enabled - true to allow this writer to send X3.64 sequences.
Since:
3.00

getLocale

public Locale getLocale()
Returns the current locale. Newly constructed ParameterWriter use the system default.

Specified by:
getLocale in interface Localized
Returns:
The current locale.

setLocale

public void setLocale(Locale locale)
Sets the locale to use for table formatting.

Parameters:
locale - The new locale to use.

formatValue

protected String formatValue(Object value)
Formats the specified value as a string. This method is automatically invoked by format(...) methods. The default implementation format Number, Date and Angle object according the current locale. This method can been overridden if more objects need to be formatted in a special way.

Parameters:
value - the value to format.
Returns:
The value formatted as a string.


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.