All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nakedobjects.nos.remote.command.java.JavaValueData Maven / Gradle / Ivy

There is a newer version: 3.0.3
Show newest version
package org.nakedobjects.nos.remote.command.java;

import java.io.Serializable;

import org.nakedobjects.noa.util.ByteDecoder;
import org.nakedobjects.noa.util.ByteEncoder;
import org.nakedobjects.noa.util.Encodable;
import org.nakedobjects.nof.core.util.ToString;
import org.nakedobjects.nof.reflect.remote.data.ValueData;


public class JavaValueData implements ValueData, Encodable, Serializable {
    private static final long serialVersionUID = 1L;
    private String type;
    private String encodedValue;

    protected JavaValueData(final String type, final String encodedValue) {
        this.type = type.equals(String.class.getName()) ? "s" :  type;
        this.encodedValue = encodedValue;
    }

    public JavaValueData(final ByteDecoder decoder) {
        type = decoder.getString();
        encodedValue = decoder.getString();
    }
    
    public void encode(ByteEncoder encoder) {
        encoder.add(type);
        encoder.add(encodedValue);
    }
    
    public String getEncodedValue() {
        return encodedValue;
    }

    public String getType() {
        return type.equals("s") ? String.class.getName() : type;
    }

    public String toString() {
        ToString str = new ToString(this);
        str.append("type", type);
        str.append("value", encodedValue);
        return str.toString();
    }

}
// Copyright (c) Naked Objects Group Ltd.




© 2015 - 2025 Weber Informatics LLC | Privacy Policy