org.apache.xmlbeans.impl.jam.internal.elements.AnnotatedElementImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-xmlbeans Show documentation
Show all versions of commons-xmlbeans Show documentation
The Apache Commons Codec package contains simple encoder and decoders for
various formats such as Base64 and Hexadecimal. In addition to these
widely used encoders and decoders, the codec package also maintains a
collection of phonetic encoding utilities.
The newest version!
package org.apache.xmlbeans.impl.jam.internal.elements;
import org.apache.xmlbeans.impl.jam.JAnnotation;
import org.apache.xmlbeans.impl.jam.JAnnotationValue;
import org.apache.xmlbeans.impl.jam.JComment;
import org.apache.xmlbeans.impl.jam.annotation.AnnotationProxy;
import org.apache.xmlbeans.impl.jam.mutable.MAnnotatedElement;
import org.apache.xmlbeans.impl.jam.mutable.MAnnotation;
import org.apache.xmlbeans.impl.jam.mutable.MComment;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Patrick Calahan <email: pcal-at-bea-dot-com>
*/
public abstract class AnnotatedElementImpl extends ElementImpl
implements MAnnotatedElement
{
// ========================================================================
// Variables
private Map mName2Annotation = null;
private MComment mComment = null;
private List mAllAnnotations = null;
// ========================================================================
// Constructors
protected AnnotatedElementImpl(ElementContext ctx) { super(ctx); }
protected AnnotatedElementImpl(ElementImpl parent) { super(parent); }
// ========================================================================
// JAnnotatedElement implementation
public JAnnotation[] getAnnotations() {
return getMutableAnnotations();
}
public JAnnotation getAnnotation(Class proxyClass) {
return getMutableAnnotation(proxyClass.getName());
}
public JAnnotation getAnnotation(String named) {
return getMutableAnnotation(named);
}
public JAnnotationValue getAnnotationValue(String valueId) {
if (mName2Annotation == null) return null;
valueId = valueId.trim();
int delim = valueId.indexOf('@');
if (delim == -1 || delim == valueId.length()-1) {
JAnnotation ann = getAnnotation(valueId);
if (ann == null) return null;
return ann.getValue(JAnnotation.SINGLE_VALUE_NAME);
} else {
JAnnotation ann = getAnnotation(valueId.substring(0,delim));
if (ann == null) return null;
return ann.getValue(valueId.substring(delim+1));
}
}
public Object getAnnotationProxy(Class proxyClass) {
return getEditableProxy(proxyClass);
}
public JComment getComment() { return getMutableComment(); }
/**
* @deprecated
*/
public JAnnotation[] getAllJavadocTags() {
if (mAllAnnotations == null) return NO_ANNOTATION;
JAnnotation[] out = new JAnnotation[mAllAnnotations.size()];
mAllAnnotations.toArray(out);
return out;
}
/*
public JAnnotation[] getAllJavadocTags(String named) {
//FIXME this impl is quite gross
if (mAllAnnotations == null) return NO_ANNOTATION;
List list = new ArrayList();
for(int i=0; i