From 0ad112c8f781211212cb6427d35eaeb758d903cb Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Fri, 13 Jun 2003 05:15:11 +0000 Subject: [PATCH] refactoring out something that I see in too, too many places in datatypes git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274666 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/types/DataType.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/org/apache/tools/ant/types/DataType.java b/src/main/org/apache/tools/ant/types/DataType.java index a646b0311..868d2305e 100644 --- a/src/main/org/apache/tools/ant/types/DataType.java +++ b/src/main/org/apache/tools/ant/types/DataType.java @@ -232,8 +232,34 @@ public abstract class DataType extends ProjectComponent { this.checked = checked; } + /** + * get the reference set on this object + * @return the reference or null + */ protected Reference getRefid() { return ref; } + + /** + * check that it is ok to set attributes, i.e that no reference is defined + * @since Ant 1.6 + * @throw BuildException if not allowed + */ + protected void checkAttributesAllowed() { + if (isReference()) { + throw tooManyAttributes(); + } + } + + /** + * check that it is ok to add children, i.e that no reference is defined + * @since Ant 1.6 + * @throw BuildException if not allowed + */ + protected void checkChildrenAllowed() { + if (isReference()) { + throw noChildrenAllowed(); + } + } }