kmoore | c9c9e2b | 2011-02-06 02:07:28 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
kmoore | c7a0867 | 2011-08-01 15:10:18 +0000 | [diff] [blame] | 2 | * Copyright (c) 2010, 2011 Oracle. All rights reserved. |
kmoore | c9c9e2b | 2011-02-06 02:07:28 +0000 | [diff] [blame] | 3 | * This program and the accompanying materials are made available under the |
| 4 | * terms of the Eclipse Public License v1.0, which accompanies this distribution |
| 5 | * and is available at http://www.eclipse.org/legal/epl-v10.html. |
| 6 | * |
| 7 | * Contributors: |
| 8 | * Oracle - initial API and implementation |
| 9 | ******************************************************************************/ |
| 10 | package org.eclipse.jpt.jpa.core.context.orm; |
| 11 | |
kmoore | c7a0867 | 2011-08-01 15:10:18 +0000 | [diff] [blame] | 12 | import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute; |
| 13 | import org.eclipse.jpt.common.core.resource.java.JavaResourceField; |
| 14 | import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod; |
kmoore | c9c9e2b | 2011-02-06 02:07:28 +0000 | [diff] [blame] | 15 | import org.eclipse.jpt.jpa.core.context.AttributeMapping; |
| 16 | import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; |
| 17 | import org.eclipse.jpt.jpa.core.context.XmlContextNode; |
| 18 | import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; |
kmoore | c9c9e2b | 2011-02-06 02:07:28 +0000 | [diff] [blame] | 19 | |
| 20 | /** |
| 21 | * Read-only context <code>orm.xml</code> persistent <em>attribute</em> |
| 22 | * (field or property). |
| 23 | * <p> |
| 24 | * Provisional API: This interface is part of an interim API that is still |
| 25 | * under development and expected to change significantly before reaching |
| 26 | * stability. It is available at this early stage to solicit feedback from |
| 27 | * pioneering adopters on the understanding that any code that uses this API |
| 28 | * will almost certainly be broken (repeatedly) as the API evolves. |
| 29 | */ |
| 30 | public interface OrmReadOnlyPersistentAttribute |
| 31 | extends ReadOnlyPersistentAttribute, XmlContextNode |
| 32 | { |
| 33 | /** |
| 34 | * A <em>specified</em> <code>orm.xml</code> attribute will return an |
| 35 | * <code>orm.xml</code> mapping, while a <em>virtual</em> attribute will |
| 36 | * return a Java mapping. If the attribute is <em>virtual</em>, the returned |
| 37 | * (Java) mapping is also <em>virtual</em>; i.e. it is read-only and is not to |
| 38 | * be modified (nor are any of its parts). The modifiable Java |
| 39 | * mapping can be retrieved via the modifiable Java attribute: |
| 40 | * {@link #resolveJavaPersistentAttribute()}. |
| 41 | */ |
| 42 | AttributeMapping getMapping(); |
| 43 | |
| 44 | OrmPersistentType getOwningPersistentType(); |
| 45 | |
| 46 | OrmTypeMapping getOwningTypeMapping(); |
| 47 | |
| 48 | /** |
| 49 | * If the <code>orm.xml</code> attribute is <em>virtual</em>, the returned Java |
| 50 | * attribute is also <em>virtual</em>; i.e. it is read-only and is not to |
| 51 | * be modified (nor are any of its parts [e.g. column]). The modifiable Java |
| 52 | * attribute can be retrieved via {@link #resolveJavaPersistentAttribute()}. |
| 53 | */ |
| 54 | JavaPersistentAttribute getJavaPersistentAttribute(); |
| 55 | String JAVA_PERSISTENT_ATTRIBUTE_PROPERTY = "javaPersistentAttribute"; //$NON-NLS-1$ |
| 56 | |
| 57 | /** |
| 58 | * Return the <code>orm.xml</code> attribute's Java attribute; which, in the |
| 59 | * case of <em>virtual</em> attributes, is not the same Java attribute as |
| 60 | * returned by {@link #getJavaPersistentAttribute()}. |
| 61 | * <p> |
| 62 | * This is probably useful only to tests; since nothing else will want to |
| 63 | * modify the returned Java attribute. |
| 64 | */ |
| 65 | JavaPersistentAttribute resolveJavaPersistentAttribute(); |
| 66 | |
kmoore | c7a0867 | 2011-08-01 15:10:18 +0000 | [diff] [blame] | 67 | JavaResourceAttribute getJavaResourceAttribute(); |
| 68 | |
| 69 | boolean isFor(JavaResourceField javaResourceField); |
| 70 | |
| 71 | boolean isFor(JavaResourceMethod javaResourceGetter, JavaResourceMethod javaResourceSetter); |
kmoore | c9c9e2b | 2011-02-06 02:07:28 +0000 | [diff] [blame] | 72 | |
| 73 | boolean contains(int textOffset); |
| 74 | |
| 75 | |
| 76 | // ********** virtual -> specified ********** |
| 77 | |
| 78 | /** |
| 79 | * Convert the (currently virtual) attribute to a specified |
| 80 | * attribute. The attribute will be added to the list of specified |
| 81 | * attributes and added to the <code>orm.xml</code> file. The mapping will |
| 82 | * remain the same. Return the new attribute. |
| 83 | * @see #isVirtual() |
| 84 | * @throw IllegalStateException if the attribute is already specified |
| 85 | */ |
| 86 | OrmPersistentAttribute convertToSpecified(); |
| 87 | |
| 88 | /** |
| 89 | * Convert the (currently virtual) persistent attribute to a specified |
| 90 | * attribute. The attribute will be added to the list of specified |
| 91 | * attributes and added to the <code>orm.xml</code> file. The mapping will |
| 92 | * be changed according to the specified mapping key. |
| 93 | * Return the new attribute. |
| 94 | * @see #isVirtual() |
| 95 | * @throw IllegalStateException if the attribute is already specified |
| 96 | */ |
| 97 | OrmPersistentAttribute convertToSpecified(String mappingKey); |
| 98 | } |