1 package net.sf.mbus4j.dataframes.datablocks.vif;
2
3 /*
4 * #%L
5 * mbus4j-core
6 * %%
7 * Copyright (C) 2009 - 2014 MBus4J
8 * %%
9 * mbus4j - Drivers for the M-Bus protocol - http://mbus4j.sourceforge.net/
10 * Copyright (C) 2009-2014, mbus4j.sf.net, and individual contributors as indicated
11 * by the @authors tag. See the copyright.txt in the distribution for a
12 * full listing of individual contributors.
13 *
14 * This is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 3 of
17 * the License, or (at your option) any later version.
18 *
19 * This software is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this software; if not, write to the Free
26 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
28 * #L%
29 */
30 /**
31 *
32 * @author arnep@users.sourceforge.net
33 * @version $Id: ObjectAction.java 104 2014-02-21 09:31:17Z arnep $
34 */
35 public enum ObjectAction {
36
37 WRITE(0x00, "write(replace)"),
38 ADD_VALUE(0x01, "add value"),
39 SUBTRACT_VALUE(0x02, "subtract value"),
40 OR(0x03, "or"),
41 AND(0x04, "and"),
42 XOR(0x05, "xor"),
43 AND_NOT(0x06, "and not"),
44 CLEAR(0x07, "clear"),
45 ADD_ENTRY(0x08, "add entry"),
46 DELETE_ENTRY(0x09, "delete entry"),
47 RESERVED_0X0A(0x0A, "Reserved 0x0A"),
48 FREEZE_DATA(0x0B, "freeze data"),
49 ADD_TO_READOUT_LIST(0x0C, "add to readout list"),
50 DELETE_FROM_READOUT_LIST(0x0D, "delete from readout list");
51
52 public static ObjectAction valueOf(int id) {
53 for (ObjectAction oa : ObjectAction.values()) {
54 if (oa.id == id) {
55 return oa;
56 }
57 }
58 return null;
59 }
60 public final int id;
61 private final String label;
62
63 private ObjectAction(int id, String label) {
64 this.id = id;
65 this.label = label;
66 }
67
68 @Override
69 public String toString() {
70 return label;
71 }
72
73 public String getLabel() {
74 return label;
75 }
76
77 public static ObjectAction fromLabel(String label) {
78 for (ObjectAction value : values()) {
79 if (value.label.equals(label)) {
80 return value;
81 }
82 }
83 return valueOf(label);
84 }
85 }