Package uk.ac.starlink.ttools.taplint
Class AdhocCode
- java.lang.Object
-
- uk.ac.starlink.ttools.taplint.AdhocCode
-
- All Implemented Interfaces:
ReportCode
public class AdhocCode extends java.lang.Object implements ReportCode
ReportCode implementation which can be created at runtime. In general, use of this class should be avoided in favour ofFixedCode(create as many new enum constants as you want) where possible, so that static determination of possible codes works as well as it can.- Since:
- 11 Jun 2014
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description static intLABEL_LENGTHRequired length of labels.
-
Constructor Summary
Constructors Constructor Description AdhocCode(ReportType type, java.lang.String label)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AdhocCodecreateCodeFromText(ReportType type, java.lang.String text)Uses some hash function to generate a report code from text.static java.lang.StringcreateLabelChars(java.lang.Object id, int nchar)Uses some hash function to generate a fixed-length character string from a supplied object.booleanequals(java.lang.Object o)java.lang.StringgetLabel()Returns the 4-character label of this code.ReportTypegetType()Returns the type of this code.inthashCode()
-
-
-
Field Detail
-
LABEL_LENGTH
public static final int LABEL_LENGTH
Required length of labels.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AdhocCode
public AdhocCode(ReportType type, java.lang.String label)
Constructor.- Parameters:
type- report typelabel- 4-character label
-
-
Method Detail
-
getType
public ReportType getType()
Description copied from interface:ReportCodeReturns the type of this code.- Specified by:
getTypein interfaceReportCode- Returns:
- type
-
getLabel
public java.lang.String getLabel()
Description copied from interface:ReportCodeReturns the 4-character label of this code.- Specified by:
getLabelin interfaceReportCode- Returns:
- 4-character label
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
createCodeFromText
public static AdhocCode createCodeFromText(ReportType type, java.lang.String text)
Uses some hash function to generate a report code from text. Probably unique, but not guaranteed to be.- Parameters:
type- report typetext- message text- Returns:
- suitable message code
-
createLabelChars
public static java.lang.String createLabelChars(java.lang.Object id, int nchar)Uses some hash function to generate a fixed-length character string from a supplied object.- Parameters:
id- object to seed character generationnchar- number of characters required- Returns:
- nchar-character string
-
-