001 /** 002 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portal.model; 016 017 import com.liferay.portal.service.ServiceContext; 018 import com.liferay.portlet.expando.model.ExpandoBridge; 019 020 import java.io.Serializable; 021 022 import java.util.Map; 023 024 /** 025 * The base interface for all model classes. This interface should never need to 026 * be used directly. 027 * 028 * @author Brian Wing Shun Chan 029 * @see com.liferay.portal.model.impl.BaseModelImpl 030 */ 031 public interface BaseModel<T> 032 extends ClassedModel, Cloneable, Comparable<T>, Serializable { 033 034 /** 035 * Creates a shallow clone of this model instance. 036 * 037 * @return the shallow clone of this model instance 038 */ 039 public Object clone(); 040 041 /** 042 * Returns the expando bridge for this model instance. 043 * 044 * @return the expando bridge for this model instance 045 */ 046 public ExpandoBridge getExpandoBridge(); 047 048 public Map<String, Object> getModelAttributes(); 049 050 /** 051 * Returns the primary key of this model instance. 052 * 053 * @return the primary key of this model instance 054 */ 055 public Serializable getPrimaryKeyObj(); 056 057 /** 058 * Returns <code>true</code> if this model instance was retrieved from the 059 * entity cache. 060 * 061 * @return <code>true</code> if this model instance was retrieved from the 062 * entity cache; <code>false</code> otherwise 063 * @see #setCachedModel(boolean) 064 */ 065 public boolean isCachedModel(); 066 067 /** 068 * Returns <code>true</code> if this model instance is escaped. 069 * 070 * @return <code>true</code> if this model instance is escaped; 071 * <code>false</code> otherwise 072 */ 073 public boolean isEscapedModel(); 074 075 /** 076 * Returns <code>true</code> if this model instance does not yet exist in 077 * the database. 078 * 079 * @return <code>true</code> if this model instance does not yet exist in 080 * the database; <code>false</code> otherwise 081 */ 082 public boolean isNew(); 083 084 /** 085 * Reset all original fields to current values. 086 */ 087 public void resetOriginalValues(); 088 089 /** 090 * Sets whether this model instance was retrieved from the entity cache. 091 * 092 * @param cachedModel whether this model instance was retrieved from the 093 * entity cache 094 * @see com.liferay.portal.kernel.dao.orm.EntityCache 095 */ 096 public void setCachedModel(boolean cachedModel); 097 098 public void setExpandoBridgeAttributes(BaseModel<?> baseModel); 099 100 public void setExpandoBridgeAttributes(ExpandoBridge expandoBridge); 101 102 /** 103 * Sets the expando bridge attributes for this model instance to the 104 * attributes stored in the service context. 105 * 106 * @param serviceContext the service context to be applied 107 * @see com.liferay.portal.service.ServiceContext#getExpandoBridgeAttributes( 108 * ) 109 */ 110 public void setExpandoBridgeAttributes(ServiceContext serviceContext); 111 112 public void setModelAttributes(Map<String, Object> attributes); 113 114 /** 115 * Sets whether this model instance does not yet exist in the database. 116 * 117 * @param n whether this model instance does not yet exist in the database 118 */ 119 public void setNew(boolean n); 120 121 /** 122 * Sets the primary key of this model instance. 123 * 124 * @param primaryKeyObj the primary key of this model instance 125 */ 126 public void setPrimaryKeyObj(Serializable primaryKeyObj); 127 128 /** 129 * Returns a cache model object for this entity used by entity cache. 130 * 131 * @return the cache model object 132 */ 133 public CacheModel<T> toCacheModel(); 134 135 /** 136 * Returns a copy of this entity as an escaped model instance by wrapping it 137 * with an {@link com.liferay.portal.kernel.bean.AutoEscapeBeanHandler}. 138 * 139 * @return the escaped model instance 140 * @see com.liferay.portal.kernel.bean.AutoEscapeBeanHandler 141 */ 142 public T toEscapedModel(); 143 144 public T toUnescapedModel(); 145 146 /** 147 * Returns the XML representation of this model instance. 148 * 149 * @return the XML representation of this model instance 150 */ 151 public String toXmlString(); 152 153 }