Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7c9eae2271a56b422625ba9b35e48e1bebd1fa92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 * Copyright (c) 2012, 2013 Eike Stepper (Loehne, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Christian W. Damus (CEA) - initial API and implementation
 */
package org.eclipse.emf.cdo.spi.common.model;

import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.model.CDOClassInfo;
import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject.EStore;

/**
 * If the meaning of this type isn't clear, there really should be more of a description here...
 *
 * @since 4.2
 * @author Eike Stepper
 */
public interface InternalCDOClassInfo extends CDOClassInfo
{
  public static final int NO_SLOT = EStore.NO_INDEX;

  public InternalCDORevision getRevisionForID(CDOID id);

  /**
   * Returns the index of the specified {@link EStructuralFeature feature} in the {@link CDORevisionImpl#values} array, never {@link #NO_SLOT}.
   *
   * @throws IllegalArgumentException if the specified feature is <b>not</b> {@link #isPersistent(int) persistent}.
   * @see #getPersistentFeatureIndex(int)
   */
  public int getPersistentFeatureIndex(EStructuralFeature feature) throws IllegalArgumentException;

  /**
   * Returns the index of the specified {@link EStructuralFeature feature} in the {@link CDORevisionImpl#values} array, never {@link #NO_SLOT}.
   *
   * @throws IllegalArgumentException if the specified feature is <b>not</b> {@link #isPersistent(int) persistent}.
   * @see #getPersistentFeatureIndex(EStructuralFeature)
   */
  public int getPersistentFeatureIndex(int featureID) throws IllegalArgumentException;

  /**
   * Returns the number of {@link EStructuralFeature features} whose values are <b>always</b> stored in the
   * <code>CDOObjectImpl.eSettings</code> array, whether an object is in <code>CDOState.TRANSIENT</code> or not.
   * <p>
   * These are the {@link EMFUtil#isPersistent(EStructuralFeature) transient} and/or {@link EStructuralFeature#isMany() many-valued} features.
   *
   * @see #getSettingsFeatureIndex(int)
   */
  public int getSettingsFeatureCount();

  /**
   * Returns the index of the specified {@link EStructuralFeature feature} in the <code>CDOObjectImpl.eSettings</code> array,
   * or {@link #NO_SLOT} if the feature is {@link EMFUtil#isPersistent(EStructuralFeature) non-transient} or {@link EStructuralFeature#isMany() single-valued}.
   *
   * @see #getSettingsFeatureCount()
   */
  public int getSettingsFeatureIndex(int featureID);

  /**
   * Returns the number of {@link EStructuralFeature features} whose values are additionally stored in the <code>CDOObjectImpl.eSettings</code> array,
   * if an object is in <code>CDOState.TRANSIENT</code>.
   * <p>
   * These are the {@link EMFUtil#isPersistent(EStructuralFeature) non-transient} and/or {@link EStructuralFeature#isMany() single-valued} features.
   *
   * @see #getTransientFeatureIndex(int)
   */
  public int getTransientFeatureCount();

  /**
   * Returns the index of the specified {@link EStructuralFeature feature} in the <code>CDOObjectImpl.eSettings</code> array,
   * or {@link #NO_SLOT} if the feature is {@link EMFUtil#isPersistent(EStructuralFeature) transient} or {@link EStructuralFeature#isMany() many-valued}
   *
   * @see #getTransientFeatureCount()
   */
  public int getTransientFeatureIndex(int featureID);

  /**
   * @see #getTransientFeatureIndex(int)
   */
  public int getTransientFeatureIndex(EStructuralFeature feature);

  /**
   * Obtains a rule that filters/transforms the persist values of the given
   * {@code feature}.
   *
   * @param feature a feature to be persisted
   * @return a persistence filter rule for the {@code feature}, or {@code null}
   *    if it has no filter but just follows the default persistence rules
   */
  public PersistenceFilter getPersistenceFilter(EStructuralFeature feature);

  /**
   * Encapsulation of a rule for filtering the persistent values
   * of a {@linkplain EStructuralFeature feature} in some model element.
   * Some models (such as UML's Activity metaclass) require partial persistence
   * of features, persisting a subset of the values in a feature that are also
   * in some other feature (the filtering feature). Other models may apply other
   * transformations to features that require partial or otherwise custom
   * persistence rules.
   */
  public interface PersistenceFilter
  {
    /**
     * Get a subset or other transformation of the specified {@code value} of
     * a persistable feature, based on its dependencies.
     *
     * @param owner an object this filter is to be applied to.
     * @param value the value (which may be a collection) of the {@code owner}'s feature.
     *
     * @return the transformed value to persist. It should be a collection (possibly empty)
     * if the {@code value} is a collection, or a scalar (possibly {@code null}) if the
     * {@code value} is a scalar
     */
    public Object getPersistableValue(EObject owner, Object value);
  }
}

Back to the top