Browse Source

Make sure can not set attributes if is a reference datatype

add a nicer toString method


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272601 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
49bc4e2af1
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionAdapter.java

+ 21
- 0
src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionAdapter.java View File

@@ -116,6 +116,7 @@ public class ExtensionAdapter
*/ */
public void setExtensionName( final String extensionName ) public void setExtensionName( final String extensionName )
{ {
verifyNotAReference();
m_extensionName = extensionName; m_extensionName = extensionName;
} }


@@ -126,6 +127,7 @@ public class ExtensionAdapter
*/ */
public void setSpecificationVersion( final String specificationVersion ) public void setSpecificationVersion( final String specificationVersion )
{ {
verifyNotAReference();
m_specificationVersion = new DeweyDecimal( specificationVersion ); m_specificationVersion = new DeweyDecimal( specificationVersion );
} }


@@ -136,6 +138,7 @@ public class ExtensionAdapter
*/ */
public void setSpecificationVendor( final String specificationVendor ) public void setSpecificationVendor( final String specificationVendor )
{ {
verifyNotAReference();
m_specificationVendor = specificationVendor; m_specificationVendor = specificationVendor;
} }


@@ -146,6 +149,7 @@ public class ExtensionAdapter
*/ */
public void setImplementationVendorId( final String implementationVendorID ) public void setImplementationVendorId( final String implementationVendorID )
{ {
verifyNotAReference();
m_implementationVendorID = implementationVendorID; m_implementationVendorID = implementationVendorID;
} }


@@ -156,6 +160,7 @@ public class ExtensionAdapter
*/ */
public void setImplementationVendor( final String implementationVendor ) public void setImplementationVendor( final String implementationVendor )
{ {
verifyNotAReference();
m_implementationVendor = implementationVendor; m_implementationVendor = implementationVendor;
} }


@@ -166,6 +171,7 @@ public class ExtensionAdapter
*/ */
public void setImplementationVersion( final String implementationVersion ) public void setImplementationVersion( final String implementationVersion )
{ {
verifyNotAReference();
m_implementationVersion = new DeweyDecimal( implementationVersion ); m_implementationVersion = new DeweyDecimal( implementationVersion );
} }


@@ -176,6 +182,7 @@ public class ExtensionAdapter
*/ */
public void setImplementationUrl( final String implementationURL ) public void setImplementationUrl( final String implementationURL )
{ {
verifyNotAReference();
m_implementationURL = implementationURL; m_implementationURL = implementationURL;
} }


@@ -225,6 +232,15 @@ public class ExtensionAdapter
super.setRefid( reference ); super.setRefid( reference );
} }


private void verifyNotAReference()
throws BuildException
{
if( isReference() )
{
throw tooManyAttributes();
}
}

/** /**
* Convert this adpater object into an extension object. * Convert this adpater object into an extension object.
* *
@@ -257,4 +273,9 @@ public class ExtensionAdapter
m_implementationVendor, m_implementationVendor,
m_implementationURL ); m_implementationURL );
} }

public String toString()
{
return toExtension().toString();
}
} }

Loading…
Cancel
Save