cvs commit: spice/sandbox/metaclass/src/java/org/realityforge/metaclass/tools/qdox NonNamespaceAttributeRemovingInterceptor.java
Peter Donald <[email protected]>
| Newsgroups | gmane.comp.java.spice.cvs |
|---|---|
| Message-ID | <[email protected]> |
donaldp 03/10/29 00:27:13
Added: sandbox/metaclass/src/java/org/realityforge/metaclass/tools/qdox
NonNamespaceAttributeRemovingInterceptor.java
Log:
Add interceptor to strip out non-namespaced attributes and corresponding test case
Revision Changes Path
1.1 spice/sandbox/metaclass/src/java/org/realityforge/metaclass/tools/qdox/NonNamespaceAttributeRemovingInterceptor.java
Index: NonNamespaceAttributeRemovingInterceptor.java
===================================================================
/*
* Copyright (C) The Spice Group. All rights reserved.
*
* This software is published under the terms of the Spice
* Software License version 1.1, a copy of which has been included
* with this distribution in the LICENSE.txt file.
*/
package org.realityforge.metaclass.tools.qdox;
import org.realityforge.metaclass.model.Attribute;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaField;
import com.thoughtworks.qdox.model.JavaMethod;
/**
* Interceptor that only returns attributes if they have a namespace.
* Attributes with namespace have names of the form
* <namespace>.<name>.
*
* @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2003/10/29 08:27:12 $
*/
public class NonNamespaceAttributeRemovingInterceptor
extends DefaultQDoxAttributeInterceptor
{
/**
* Constant containing an instance of interceptor.
*/
public static final NonNamespaceAttributeRemovingInterceptor INTERCEPTOR =
new NonNamespaceAttributeRemovingInterceptor();
/**
* @see DefaultQDoxAttributeInterceptor#processClassAttribute
*/
public Attribute processClassAttribute( final JavaClass clazz,
final Attribute attribute )
{
return processAttribute( attribute );
}
/**
* @see DefaultQDoxAttributeInterceptor#processFieldAttribute
*/
public Attribute processFieldAttribute( final JavaField field,
final Attribute attribute )
{
return processAttribute( attribute );
}
/**
* @see DefaultQDoxAttributeInterceptor#processMethodAttribute
*/
public Attribute processMethodAttribute( final JavaMethod method,
final Attribute attribute )
{
return processAttribute( attribute );
}
/**
* Only return an attribute if it has a namespace.
*
* @param attribute the attribute
* @return the attribute or null
*/
Attribute processAttribute( final Attribute attribute )
{
final String name = attribute.getName();
final int length = name.length();
final int index = name.indexOf( "." );
if( -1 == index || 0 == index || length - 1 == index )
{
return null;
}
else
{
return attribute;
}
}
}
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/