| /******************************************************************************* |
| * Copyright (c) 2010 Oracle. All rights reserved. |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v1.0, which accompanies this distribution |
| * and is available at http://www.eclipse.org/legal/epl-v10.html. |
| * |
| * Contributors: |
| * Oracle - initial API and implementation |
| ******************************************************************************/ |
| package org.eclipse.jpt.jaxb.core.internal.resource.java; |
| |
| import org.eclipse.jdt.core.IAnnotation; |
| import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement; |
| import org.eclipse.jpt.common.core.utility.jdt.Attribute; |
| import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlElementRefAnnotation; |
| import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlElementRefAnnotation; |
| import org.eclipse.jpt.jaxb.core.resource.java.Annotation; |
| import org.eclipse.jpt.jaxb.core.resource.java.JAXB; |
| import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement; |
| import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField; |
| import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; |
| import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition; |
| |
| /** |
| * javax.xml.bind.annotation.XmlElementRef |
| */ |
| public final class XmlElementRefAnnotationDefinition |
| implements NestableAnnotationDefinition |
| { |
| // singleton |
| private static final NestableAnnotationDefinition INSTANCE = new XmlElementRefAnnotationDefinition(); |
| |
| /** |
| * Return the singleton. |
| */ |
| public static NestableAnnotationDefinition instance() { |
| return INSTANCE; |
| } |
| |
| /** |
| * Ensure single instance. |
| */ |
| private XmlElementRefAnnotationDefinition() { |
| super(); |
| } |
| |
| public NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, int index) { |
| return SourceXmlElementRefAnnotation.buildSourceXmlElementRefAnnotation((JavaResourceField) parent, (Attribute) annotatedElement, index); |
| } |
| |
| public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { |
| throw new UnsupportedOperationException(); |
| } |
| |
| public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { |
| return new BinaryXmlElementRefAnnotation(parent, jdtAnnotation); |
| } |
| |
| public String getNestableAnnotationName() { |
| return JAXB.XML_ELEMENT_REF; |
| } |
| |
| public String getContainerAnnotationName() { |
| return JAXB.XML_ELEMENT_REFS; |
| } |
| |
| public String getElementName() { |
| return JAXB.XML_ELEMENT_REFS__VALUE; |
| } |
| |
| } |