001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Nuxeo - initial API and implementation
011 *
012 * $Id$
013 */
014
015package org.nuxeo.runtime.model;
016
017import java.io.Serializable;
018import java.util.List;
019
020import org.nuxeo.common.xmap.annotation.XNode;
021import org.nuxeo.common.xmap.annotation.XObject;
022import org.nuxeo.runtime.model.impl.PropertyDecoder;
023
024/**
025 * @author Bogdan Stefanescu
026 */
027@XObject(value = "property", order = { "@name", "@type" })
028public class Property implements Serializable {
029
030    private static final long serialVersionUID = -2661183859962287565L;
031
032    @XNode("@name")
033    private String name;
034
035    @XNode("@type")
036    private String type = "string";
037
038    private Serializable value;
039
040    @XNode("@value")
041    private void setStringValue(String value) {
042        this.value = PropertyDecoder.decode(type, value);
043    }
044
045    // TODO
046    // @XContent
047    // public void setValueFromContent(String value) {
048    // this.value = PropertyDecoder.decode(type, value);
049    // }
050
051    public Object getValue() {
052        return value;
053    }
054
055    // Not used.
056    // public void setValue(Object value) {
057    // this.value = value;
058    // }
059
060    // Not used.
061    public String getType() {
062        return type;
063    }
064
065    // Not used.
066    public String getName() {
067        return name;
068    }
069
070    // Not used.
071    public String getString() {
072        return value.toString();
073    }
074
075    // Not used.
076    public Integer getInteger() {
077        return (Integer) value;
078    }
079
080    // Not used.
081    public Boolean getBoolean() {
082        return (Boolean) value;
083    }
084
085    // Not used.
086    @SuppressWarnings("unchecked")
087    public List<String> getList() {
088        return (List<String>) value;
089    }
090
091}