001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id$
020 */
021
022package org.nuxeo.runtime.model;
023
024import java.io.Serializable;
025import java.util.List;
026
027import org.nuxeo.common.xmap.annotation.XNode;
028import org.nuxeo.common.xmap.annotation.XObject;
029import org.nuxeo.runtime.model.impl.PropertyDecoder;
030
031/**
032 * @author Bogdan Stefanescu
033 */
034@XObject(value = "property", order = { "@name", "@type" })
035public class Property {
036
037    @XNode("@name")
038    private String name;
039
040    @XNode("@type")
041    private String type = "string";
042
043    private Serializable value;
044
045    @XNode("@value")
046    private void setStringValue(String value) {
047        this.value = PropertyDecoder.decode(type, value);
048    }
049
050    // TODO
051    // @XContent
052    // public void setValueFromContent(String value) {
053    // this.value = PropertyDecoder.decode(type, value);
054    // }
055
056    public Object getValue() {
057        return value;
058    }
059
060    // Not used.
061    // public void setValue(Object value) {
062    // this.value = value;
063    // }
064
065    // Not used.
066    public String getType() {
067        return type;
068    }
069
070    // Not used.
071    public String getName() {
072        return name;
073    }
074
075    // Not used.
076    public String getString() {
077        return value.toString();
078    }
079
080    // Not used.
081    public Integer getInteger() {
082        return (Integer) value;
083    }
084
085    // Not used.
086    public Boolean getBoolean() {
087        return (Boolean) value;
088    }
089
090    // Not used.
091    @SuppressWarnings("unchecked")
092    public List<String> getList() {
093        return (List<String>) value;
094    }
095
096}