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