uk.ac.starlink.ttools.taplint
Class AdhocCode

java.lang.Object
  extended by uk.ac.starlink.ttools.taplint.AdhocCode
All Implemented Interfaces:
ReportCode

public class AdhocCode
extends Object
implements ReportCode

ReportCode implementation which can be created at runtime. In general, use of this class should be avoided in favour of FixedCode (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
static int LABEL_LENGTH
          Required length of labels.
 
Constructor Summary
AdhocCode(ReportType type, String label)
          Constructor.
 
Method Summary
static AdhocCode createCodeFromText(ReportType type, String text)
          Uses some hash function to generate a report code from text.
static String createLabelChars(Object id, int nchar)
          Uses some hash function to generate a fixed-length character string from a supplied object.
 boolean equals(Object o)
           
 String getLabel()
          Returns the 4-character label of this code.
 ReportType getType()
          Returns the type of this code.
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

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,
                 String label)
Constructor.

Parameters:
type - report type
label - 4-character label
Method Detail

getType

public ReportType getType()
Description copied from interface: ReportCode
Returns the type of this code.

Specified by:
getType in interface ReportCode
Returns:
type

getLabel

public String getLabel()
Description copied from interface: ReportCode
Returns the 4-character label of this code.

Specified by:
getLabel in interface ReportCode
Returns:
4-character label

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

createCodeFromText

public static AdhocCode createCodeFromText(ReportType type,
                                           String text)
Uses some hash function to generate a report code from text. Probably unique, but not guaranteed to be.

Parameters:
type - report type
text - message text
Returns:
suitable message code

createLabelChars

public static String createLabelChars(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 generation
nchar - number of characters required
Returns:
nchar-character string


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.