// (C)2007 Attila Kovacs <attila@submm.caltech.edu>


import java.text.*;

public class TimeFormat extends AngleFormat {
	/**
	 * 
	 */
	private static final long serialVersionUID = -6135295347868421521L;
	
	protected static final char[] colonMarker = { ':', ':', 0};
	protected static final char[] hmsMarker = { 'h', 'm', 's'};
	protected static final char[] symbolMarker = { 'h', '\'', '"'};
		
	public TimeFormat() { defaults(); }
	
	public TimeFormat(DecimalFormat df) { super(df); defaults(); }
	
	public TimeFormat(int decimals) { super(decimals); defaults(); }

	public void defaults() {
		unit = new double[] { Unit.hour, Unit.min, Unit.sec };	
		marker = hmsMarker;	
		wraparound = 24.0 * Unit.hour;
		oneSided = true;
	}
	
	public void setSeparator(int type) {
		switch(type) {
		case COLONS: marker = colonMarker; break;
		case HMS: marker = hmsMarker; break;
		case SYMBOLS: marker = symbolMarker; break;
		default: marker = colonMarker;
		}	
	}
	
	public int getSeparator() {
		if(marker == colonMarker) return COLONS;
		else if(marker == hmsMarker) return HMS;
		else if(marker == symbolMarker) return SYMBOLS;	
		else return -1;
	}
	
	public void colons() { marker = colonMarker; }
	
	public void letters() { marker = hmsMarker; }
	
	public void symbols() { marker = symbolMarker; }
	
	
	public void setTopLevel(int level) { 
		if(level < DEGREE || level > SECOND) throw new IllegalArgumentException("Undefined " + getClass().getSimpleName() + " level.");
		topLevel = level; 	
	}
	
	public void setBottomLevel(int level) { 
		if(level < DEGREE || level > SECOND) throw new IllegalArgumentException("Undefined " + getClass().getSimpleName() + " level.");
		bottomLevel = level; 		
	}
	
	public int getTopLevel() { return topLevel; }
	
	public int getBottomLevel() { return bottomLevel; }
	
	public void setSecondsFormat(DecimalFormat df) { seconds = df; }
	
	public DecimalFormat getSecondsFormat() { return seconds; }
	
	
	public static final int HOUR = AngleFormat.DEGREE;
	public static final int MINUTE = AngleFormat.MINUTE;
	public static final int SECOND = AngleFormat.SECOND;
	
	public static final int COLONS = 0;
	public static final int HMS = 1;
	public static final int SYMBOLS = 2;


}