uk.me.parabola.imgfmt.app
Class Label

java.lang.Object
  extended by uk.me.parabola.imgfmt.app.Label
All Implemented Interfaces:
java.lang.Comparable<Label>

public class Label
extends java.lang.Object
implements java.lang.Comparable<Label>

Labels are used for names of roads, points of interest etc. There are different storage formats. 1. A 6 bit compact uppercase ascii format, that has escape codes for some special characters. 2. An 8 bit format. This seems to be a fairly straightforward latin-1 like encoding with no tricks to reduce the amount of space required.

Author:
Steve Ratcliffe

Constructor Summary
Label(java.lang.String text)
           
 
Method Summary
 int compareTo(Label other)
          Note: this class has a natural ordering that is inconsistent with equals.
 boolean equals(java.lang.Object o)
           
 int getLength()
           
 int getOffset()
          The offset of this label in the LBL file.
 java.lang.String getText()
           
 java.lang.String getTextSansGarminCodes()
           
 int hashCode()
           
 void setOffset(int offset)
           
static java.lang.String squashSpaces(java.lang.String s)
           
static java.lang.String stripGarminCodes(java.lang.String s)
           
 java.lang.String toString()
          String version of the label, for diagnostic purposes.
 void write(ImgFileWriter writer, CharacterEncoder textEncoder)
          Write this label to the given img file.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Label

public Label(java.lang.String text)
Method Detail

getLength

public int getLength()

getText

public java.lang.String getText()

getTextSansGarminCodes

public java.lang.String getTextSansGarminCodes()

stripGarminCodes

public static java.lang.String stripGarminCodes(java.lang.String s)

squashSpaces

public static java.lang.String squashSpaces(java.lang.String s)

getOffset

public int getOffset()
The offset of this label in the LBL file. The first byte of this file is zero and an offset of zero means that the label has a zero length/is empty.

Returns:
The offset within the LBL file of this string.

setOffset

public void setOffset(int offset)

write

public void write(ImgFileWriter writer,
                  CharacterEncoder textEncoder)
Write this label to the given img file.

Parameters:
writer - The LBL file to write to.
textEncoder - The encoder to use for this text. Converts the unicode string representation to the correct byte stream for the file. This depends on encoding format, character set etc.

toString

public java.lang.String toString()
String version of the label, for diagnostic purposes.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(Label other)
Note: this class has a natural ordering that is inconsistent with equals. (But perhaps it shouldn't?)

Specified by:
compareTo in interface java.lang.Comparable<Label>