From 83ba7be3a3d4252b8f3074fa148611e315ed5a2c Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Fri, 24 Jun 2011 14:42:49 -0700 Subject: [PATCH] HHH-6364 : Add AttributeBinding.getValuesSpan() and Tuple.valuesSpan() --- .../binding/AbstractAttributeBinding.java | 14 ++++++++++++++ .../metamodel/binding/AttributeBinding.java | 11 +++++++++++ .../org/hibernate/metamodel/relational/Tuple.java | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AbstractAttributeBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AbstractAttributeBinding.java index 62b8cfb742..a1c6c578c3 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AbstractAttributeBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AbstractAttributeBinding.java @@ -165,6 +165,20 @@ public abstract class AbstractAttributeBinding implements AttributeBinding { return metaAttributeContext; } + @Override + public int getValuesSpan() { + if ( value == null ) { + return 0; + } + else if ( value instanceof Tuple ) { + return ( ( Tuple ) value ).valuesSpan(); + } + else { + return 1; + } + } + + @Override public Iterable getValues() { return value == null diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AttributeBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AttributeBinding.java index e7affb3d98..e6796ba643 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AttributeBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AttributeBinding.java @@ -71,6 +71,17 @@ public interface AttributeBinding { */ public MetaAttributeContext getMetaAttributeContext(); + /** + * Returns the number of {@link org.hibernate.metamodel.relational.SimpleValue} + * objects that will be returned by {@link #getValues()} + * + * @return the number of objects that will be returned by {@link #getValues()}. + * + * @see {@link org.hibernate.metamodel.relational.SimpleValue} + * @see {@link #getValues()} + */ + public int getValuesSpan(); + /** * @return In the case that {@link #getValue()} represents a {@link org.hibernate.metamodel.relational.Tuple} this method * gives access to its compound values. In the case of {@link org.hibernate.metamodel.relational.SimpleValue}, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Tuple.java b/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Tuple.java index 7edb97727b..c566dead53 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Tuple.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Tuple.java @@ -56,6 +56,10 @@ public class Tuple implements Value, ValueContainer, Loggable { return table; } + public int valuesSpan() { + return values.size(); + } + @Override public Iterable values() { return values;