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 * Florent Guillaume 011 */ 012 013package org.nuxeo.ecm.core.storage.sql; 014 015import org.nuxeo.ecm.core.api.model.ReadOnlyPropertyException; 016 017/** 018 * A {@code Property} gives access to a scalar or array value stored in an underlying table. This base class contains 019 * common code. 020 * <p> 021 * When stored, the values are normalized to their standard type. 022 * 023 * @author Florent Guillaume 024 */ 025public abstract class BaseProperty { 026 027 /** The property name. */ 028 protected final String name; 029 030 /** The property type. */ 031 public final PropertyType type; 032 033 /** Is this property readonly (for system properties). */ 034 private final boolean readonly; 035 036 /** 037 * Creates a Property. 038 */ 039 public BaseProperty(String name, PropertyType type, boolean readonly) { 040 this.name = name; 041 this.type = type; 042 this.readonly = readonly; 043 } 044 045 // ----- basics ----- 046 047 public String getName() { 048 return name; 049 } 050 051 // ----- modification ----- 052 053 public void refresh(boolean keepChanges) { 054 throw new UnsupportedOperationException(); 055 } 056 057 public void remove() { 058 throw new UnsupportedOperationException(); 059 } 060 061 public void save() { 062 throw new UnsupportedOperationException(); 063 } 064 065 protected void checkWritable() { 066 if (readonly) { 067 throw new ReadOnlyPropertyException(name); 068 } 069 } 070 071}