View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.support.model;
17  
18  /*
19      ui4 (ABS_COUNT, REL_COUNT, TRACK_NR, TAPE-INDEX, FRAME)
20      time (ABS_TIME, REL_TIME)
21      float (CHANNEL_FREQ, in Hz)
22      */
23  public enum SeekMode {
24  
25      TRACK_NR("TRACK_NR"),
26      ABS_TIME("ABS_TIME"),
27      REL_TIME("REL_TIME"),
28      ABS_COUNT("ABS_COUNT"),
29      REL_COUNT("REL_COUNT"),
30      CHANNEL_FREQ("CHANNEL_FREQ"),
31      TAPE_INDEX("TAPE-INDEX"),
32      FRAME("FRAME");
33  
34      private String protocolString;
35  
36      SeekMode(String protocolString) {
37          this.protocolString = protocolString;
38      }
39  
40      @Override
41      public String toString() {
42          return protocolString;
43      }
44  
45      public static SeekMode valueOrExceptionOf(String s) throws IllegalArgumentException {
46          for (SeekMode seekMode : values()) {
47              if (seekMode.protocolString.equals(s)) {
48                  return seekMode;
49              }
50          }
51          throw new IllegalArgumentException("Invalid seek mode string: " + s);
52      }
53  }
54