Package uk.ac.starlink.table
Class JoinFixAction
- java.lang.Object
-
- uk.ac.starlink.table.JoinFixAction
-
public abstract class JoinFixAction extends java.lang.Object
Class defining the possible actions for doctoring column names when joining tables. Joining tables can cause confusion if columns with the same names exist in some of them. An instance of this class defines how the join should behave in this case.- Since:
- 8 Sep 2005
- Author:
- Mark Taylor
- See Also:
JoinStarTable
-
-
Field Summary
Fields Modifier and Type Field Description static JoinFixAction
NO_ACTION
Action which causes names to be left alone.
-
Constructor Summary
Constructors Modifier Constructor Description protected
JoinFixAction(java.lang.String name)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static java.lang.String
ensureUnique(java.lang.String name, java.util.Collection others, boolean caseSensitive)
Utility method which repeatedly doctors a name until it fails to match any of the others in a given collection.abstract java.lang.String
getFixedName(java.lang.String origName, java.util.Collection otherNames)
Returns a, possibly modified, name for a column in the context of existing column names.static boolean
isDuplicate(java.lang.String name, java.util.Collection others, boolean caseSensitive)
Utility method to determine whether a given name is a duplicate of any in a given collection of other names.static JoinFixAction
makeNumericDeduplicationAction(java.lang.String delimiter, boolean caseSensitive)
Returns an action which will deduplicate names by appending a numeric value to them.static JoinFixAction
makeRenameAllAction(java.lang.String appendage)
Returns an action for renaming all column names with default options.static JoinFixAction
makeRenameAllAction(java.lang.String appendage, boolean caseSensitive, boolean ensureUnique)
Returns an action for renaming all columns with additional options.static JoinFixAction
makeRenameDuplicatesAction(java.lang.String appendage)
Returns an action for renaming duplicated column names with default options.static JoinFixAction
makeRenameDuplicatesAction(java.lang.String appendage, boolean caseSensitive, boolean ensureUnique)
Returns an action for renaming duplicated column names with additional options.java.lang.String
toString()
Returns this action's name.
-
-
-
Field Detail
-
NO_ACTION
public static final JoinFixAction NO_ACTION
Action which causes names to be left alone.
-
-
Method Detail
-
getFixedName
public abstract java.lang.String getFixedName(java.lang.String origName, java.util.Collection otherNames)
Returns a, possibly modified, name for a column in the context of existing column names.- Parameters:
origName
- input nameotherNames
- list of names which may be duplicates oforigName
- Returns:
- output name - may or may not be the same as
origName
-
toString
public java.lang.String toString()
Returns this action's name.- Overrides:
toString
in classjava.lang.Object
-
isDuplicate
public static boolean isDuplicate(java.lang.String name, java.util.Collection others, boolean caseSensitive)
Utility method to determine whether a given name is a duplicate of any in a given collection of other names.- Parameters:
name
- name to testothers
- potential duplicates ofname
caseSensitive
- true iff matching is to be done in a case-sensitive fashion- Returns:
- true iff
name
matches any of the entries inothers
-
ensureUnique
public static java.lang.String ensureUnique(java.lang.String name, java.util.Collection others, boolean caseSensitive)
Utility method which repeatedly doctors a name until it fails to match any of the others in a given collection. Currently some arbitrary scheme of appending characters is used.- Parameters:
name
- input nameothers
- list of names that must not matchcaseSensitive
- whether matching others is case sensitive- Returns:
- name similar to
name
but not matchingothers
-
makeRenameDuplicatesAction
public static JoinFixAction makeRenameDuplicatesAction(java.lang.String appendage)
Returns an action for renaming duplicated column names with default options.- Parameters:
appendage
- string to append to duplicate columns- Returns:
- fixer
-
makeRenameDuplicatesAction
public static JoinFixAction makeRenameDuplicatesAction(java.lang.String appendage, boolean caseSensitive, boolean ensureUnique)
Returns an action for renaming duplicated column names with additional options. The action indicates that column names which would be duplicated elsewhere in the result table should be modified by appending a given string.- Parameters:
appendage
- string to append to duplicate columnscaseSensitive
- whether duplicate location should be case sensitiveensureUnique
- if true, every effort will be made to ensure that the output name matches none of the others; if false, the output name may still match (but differently from the input one)- Returns:
- fixer
-
makeRenameAllAction
public static JoinFixAction makeRenameAllAction(java.lang.String appendage)
Returns an action for renaming all column names with default options.- Parameters:
appendage
- string to append to columns- Returns:
- fixer
-
makeRenameAllAction
public static JoinFixAction makeRenameAllAction(java.lang.String appendage, boolean caseSensitive, boolean ensureUnique)
Returns an action for renaming all columns with additional options. The action indicates that all names will be modified by appending a given string.- Parameters:
appendage
- string to append to columnscaseSensitive
- whether duplicate location should be case sensitive (only relevant ifensureUnique
is true)ensureUnique
- if true, every effort will be made to ensure that the output name matches none of the others;- Returns:
- fixer
-
makeNumericDeduplicationAction
public static JoinFixAction makeNumericDeduplicationAction(java.lang.String delimiter, boolean caseSensitive)
Returns an action which will deduplicate names by appending a numeric value to them. The number is guaranteed unique; the value used is one higher than the currently highest used one- Parameters:
delimiter
- string used to separate main part of name from numeric partcaseSensitive
- whether duplicate location is case sensitive- Returns:
- fixer
-
-