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 implements Serializable { 036 037 private static final long serialVersionUID = -2661183859962287565L; 038 039 @XNode("@name") 040 private String name; 041 042 @XNode("@type") 043 private String type = "string"; 044 045 private Serializable value; 046 047 @XNode("@value") 048 private void setStringValue(String value) { 049 this.value = PropertyDecoder.decode(type, value); 050 } 051 052 // TODO 053 // @XContent 054 // public void setValueFromContent(String value) { 055 // this.value = PropertyDecoder.decode(type, value); 056 // } 057 058 public Object getValue() { 059 return value; 060 } 061 062 // Not used. 063 // public void setValue(Object value) { 064 // this.value = value; 065 // } 066 067 // Not used. 068 public String getType() { 069 return type; 070 } 071 072 // Not used. 073 public String getName() { 074 return name; 075 } 076 077 // Not used. 078 public String getString() { 079 return value.toString(); 080 } 081 082 // Not used. 083 public Integer getInteger() { 084 return (Integer) value; 085 } 086 087 // Not used. 088 public Boolean getBoolean() { 089 return (Boolean) value; 090 } 091 092 // Not used. 093 @SuppressWarnings("unchecked") 094 public List<String> getList() { 095 return (List<String>) value; 096 } 097 098}