All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.xmlbeans.impl.jam.internal.elements.AnnotationImpl Maven / Gradle / Ivy

There is a newer version: 4.0.115
Show newest version
/*   Copyright 2004 The Apache Software Foundation
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.apache.xmlbeans.impl.jam.internal.elements;

import org.apache.xmlbeans.impl.jam.JAnnotationValue;
import org.apache.xmlbeans.impl.jam.JClass;
import org.apache.xmlbeans.impl.jam.annotation.AnnotationProxy;
import org.apache.xmlbeans.impl.jam.mutable.MAnnotation;
import org.apache.xmlbeans.impl.jam.visitor.JVisitor;
import org.apache.xmlbeans.impl.jam.visitor.MVisitor;

/**
 * 

Standard implementation of AnnotationImpl.

* * @author Patrick Calahan <email: pcal-at-bea-dot-com> */ public final class AnnotationImpl extends ElementImpl implements MAnnotation { // ======================================================================== // Variables private AnnotationProxy mProxy; private Object mAnnotationInstance = null; private String mQualifiedName = null; // ======================================================================== // Constructors /*package*/ AnnotationImpl(ElementContext ctx, AnnotationProxy proxy, String qualifiedName) { super(ctx); if (proxy == null) throw new IllegalArgumentException("null proxy"); if (qualifiedName == null) throw new IllegalArgumentException("null qn"); mProxy = proxy; // review maybe this should just be the behavior in the default impl // of getSimpleName(). setSimpleName(qualifiedName.substring(qualifiedName.lastIndexOf('.')+1)); mQualifiedName = qualifiedName; } // ======================================================================== // JAnnotation implementation public Object getProxy() { return mProxy; } public JAnnotationValue[] getValues() { return mProxy.getValues(); } public JAnnotationValue getValue(String name) { return mProxy.getValue(name); } public Object getAnnotationInstance() { return mAnnotationInstance; } // ======================================================================== // MAnnotation implementation public void setAnnotationInstance(Object o) { mAnnotationInstance = o; } public void setSimpleValue(String name, Object value, JClass type) { if (name == null) throw new IllegalArgumentException("null name"); if (type == null) throw new IllegalArgumentException("null type"); if (value == null) throw new IllegalArgumentException("null value"); mProxy.setValue(name,value,type); } public MAnnotation createNestedValue(String name, String annTypeName) { if (name == null) throw new IllegalArgumentException("null name"); if (annTypeName == null) throw new IllegalArgumentException("null typename"); AnnotationProxy p = getContext().createAnnotationProxy(annTypeName); AnnotationImpl out = new AnnotationImpl(getContext(),p,annTypeName); JClass type = getContext().getClassLoader().loadClass(annTypeName); mProxy.setValue(name,out,type); return out; } public MAnnotation[] createNestedValueArray(String name, String annComponentTypeName, int dimensions) { if (name == null) throw new IllegalArgumentException("null name"); if (annComponentTypeName == null) throw new IllegalArgumentException("null typename"); if (dimensions < 0) throw new IllegalArgumentException("dimensions = "+dimensions); MAnnotation[] out = new MAnnotation[dimensions]; for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy