uk.ac.starlink.gbin
Class DefaultGbinTableProfile

java.lang.Object
  extended by uk.ac.starlink.gbin.DefaultGbinTableProfile
All Implemented Interfaces:
GbinTableProfile

public class DefaultGbinTableProfile
extends java.lang.Object
implements GbinTableProfile

Default implementation of GbinTableProfile.

Since:
3 Sep 2015

Constructor Summary
DefaultGbinTableProfile()
          Constructs a profile with default configuration.
DefaultGbinTableProfile(java.lang.Class<?>[] simpleClasses, java.lang.Class<?>[] stringClasses, java.lang.Class<?>[] ignoreClasses)
          Constructs a profile with explicit configuration.
 
Method Summary
static
<T> Representation<T>
createIdentityRepresentation(java.lang.Class<T> clazz, boolean isColumn)
          Returns a representation that uses the input values unchanged.
 Representation<?> createRepresentation(java.lang.Class<?> clazz)
          Returns an object which can represent a particular data type returned from an accessor method of a GBIN object (or one of its descendants).
static Representation<java.lang.String> createStringColumnRepresentation(java.lang.Class<?> clazz)
          Returns a representation that maps its input values to strings using their toString method, and uses the result like a column.
 java.lang.String[] getIgnoreMethodNames()
          Returns the list of method names to ignore when coming up with a list of columns for an object.
 java.lang.String getNameSeparator()
          Returns the separation string used to delimit parts of column hierarchical names.
 boolean isHierarchicalNames()
          Indicates whether column names in the output table should be forced to reflect the compositional hierarchy of their position in the element objects.
 boolean isReadMeta()
          Indicates whether non-essential metadata is read from the GBIN file.
 boolean isSortedMethods()
          Indicates whether object accessor method names should be sorted alphabetically when producing the column sequence.
 boolean isTestMagic()
          Indicates whether the magic number is read from GBIN files before attempting to turn them into tables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGbinTableProfile

public DefaultGbinTableProfile()
Constructs a profile with default configuration.


DefaultGbinTableProfile

public DefaultGbinTableProfile(java.lang.Class<?>[] simpleClasses,
                               java.lang.Class<?>[] stringClasses,
                               java.lang.Class<?>[] ignoreClasses)
Constructs a profile with explicit configuration. Any classes not referred to in the supplied lists, apart from primitive classes which are always used, will be treated as elements in the object hierarchy and descended into recursively.

Parameters:
simpleClasses - list of scalar Object subclasses that are suitable contents of a column as they stand
stringClasses - list of scalar Object subclasses that can be used as string contents of a column by invoking their toString method
ignoreClasses - classes which should be ignored completely when converting to a table
Method Detail

isReadMeta

public boolean isReadMeta()
Description copied from interface: GbinTableProfile
Indicates whether non-essential metadata is read from the GBIN file. This includes amongst other things the row count and a description of the data. Because of the way GBIN reading works, reading metadata requires acquisition of a new InputStream (it can't be done using the same stream that reads the data objects) so it may be expensive.

Specified by:
isReadMeta in interface GbinTableProfile
Returns:
true to attempt to read metadata where possible

isTestMagic

public boolean isTestMagic()
Description copied from interface: GbinTableProfile
Indicates whether the magic number is read from GBIN files before attempting to turn them into tables. It's probably a good idea to set this true, but there may be GBIN variants for which the magic number testing supplied gives false negatives, in which case you'd want to turn it off.

Specified by:
isTestMagic in interface GbinTableProfile
Returns:
true if you want magic number mismatch to cause read failure

isHierarchicalNames

public boolean isHierarchicalNames()
Description copied from interface: GbinTableProfile
Indicates whether column names in the output table should be forced to reflect the compositional hierarchy of their position in the element objects. If set true, columns will have names like "Astrometry_Alpha", if false they may just be called "Alpha". In case of name duplication however, the hierarchical form is always used.

Specified by:
isHierarchicalNames in interface GbinTableProfile
Returns:
true to force use of hierarchical column names

getNameSeparator

public java.lang.String getNameSeparator()
Description copied from interface: GbinTableProfile
Returns the separation string used to delimit parts of column hierarchical names. If the value is "_" you may see column names like "Astrometry_Alpha". An empty string is permissible too.

Specified by:
getNameSeparator in interface GbinTableProfile
Returns:
column hierarchical name separator string

isSortedMethods

public boolean isSortedMethods()
Description copied from interface: GbinTableProfile
Indicates whether object accessor method names should be sorted alphabetically when producing the column sequence. Otherwise get* method names will be used in whatever sequence reflection provides them in, which according to the Class.getMethods() javadocs is "not sorted and are not in any particular order".

Specified by:
isSortedMethods in interface GbinTableProfile
Returns:
true to sort method names alphabetically

getIgnoreMethodNames

public java.lang.String[] getIgnoreMethodNames()
Description copied from interface: GbinTableProfile
Returns the list of method names to ignore when coming up with a list of columns for an object. Any methods matching strings in the return value will not be used to generate columns in an output table. Only public instance methods of the form getXxx() or isXxx() are used in any case.

Specified by:
getIgnoreMethodNames in interface GbinTableProfile
Returns:
list of accessor method names to ignore

createRepresentation

public Representation<?> createRepresentation(java.lang.Class<?> clazz)
Description copied from interface: GbinTableProfile
Returns an object which can represent a particular data type returned from an accessor method of a GBIN object (or one of its descendants). If null is returned, the object should not appear in the output table at all.

Specified by:
createRepresentation in interface GbinTableProfile
Parameters:
clazz - return type of an accessor method
Returns:
object indicating how accessed objects should appear in the output table; null to truncate the hierarchy here

createIdentityRepresentation

public static <T> Representation<T> createIdentityRepresentation(java.lang.Class<T> clazz,
                                                                 boolean isColumn)
Returns a representation that uses the input values unchanged.

Parameters:
clazz - input type
isColumn - whether this represents a column or not
Returns:
representation of column or structured object

createStringColumnRepresentation

public static Representation<java.lang.String> createStringColumnRepresentation(java.lang.Class<?> clazz)
Returns a representation that maps its input values to strings using their toString method, and uses the result like a column.

Parameters:
clazz - input type
Returns:
representation of column

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.