/*
 * Copyright 2011-14 Fraunhofer ISE
 *
 * This file is part of OpenMUC.
 * For more information visit http://www.openmuc.org
 *
 * OpenMUC is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * OpenMUC is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OpenMUC.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package org.openmuc.framework.data;

public enum ValueType {
    DOUBLE, FLOAT, LONG, INTEGER, SHORT, BYTE, BOOLEAN, BYTE_ARRAY, STRING;

    public static Value newValue(ValueType valueType, byte[] concatenate) {
        return null;
    }
}

@@ -800,16 +800,45 @@
 .data;%0A%0A
+import java.nio.ByteBuffer;%0A%0A
 public e
@@ -1006,16 +1006,1084 @@
 nate) %7B%0A
+        if (valueType == DOUBLE)%0A            return new DoubleValue(ByteBuffer.wrap(concatenate).getDouble());%0A%0A        if (valueType == FLOAT)%0A            return new FloatValue(ByteBuffer.wrap(concatenate).getFloat());%0A%0A        if (valueType == LONG)%0A            return new LongValue(ByteBuffer.wrap(concatenate).getLong());%0A%0A        if (valueType == INTEGER)%0A            return new IntValue(ByteBuffer.wrap(concatenate).getInt());%0A%0A        if (valueType == SHORT)%0A            return new ShortValue(ByteBuffer.wrap(concatenate).getShort());%0A%0A        if (valueType == BYTE)%0A            return new ByteValue(concatenate%5B0%5D);%0A%0A        if (valueType == BOOLEAN) %7B%0A            boolean value = (concatenate == null %7C%7C concatenate.length == 0) ?%0A                            false :%0A                            concatenate%5B0%5D != 0x00;%0A            return new BooleanValue(value);%0A        %7D%0A%0A        if (valueType == BYTE_ARRAY)%0A            return new ByteArrayValue(concatenate);%0A%0A        if (valueType == STRING)%0A            return new StringValue(new String(concatenate));%0A%0A
         
@@ -2095,16 +2095,17 @@
 n null;%0A
-
     %7D%0A
+%0A
 %7D%0A

implement ValueType.newValue()