com.sun.xml.internal.bind.v2.model.annotation.Locatable Java Examples

The following examples show how to use com.sun.xml.internal.bind.v2.model.annotation.Locatable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnumLeafInfoImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param clazz
 * @param type
 *      clazz and type should both point to the enum class
 *      that this {@link EnumLeafInfo} represents.
 *      Because of the type parameterization we have to take them separately.
 */
public EnumLeafInfoImpl(ModelBuilder<T,C,F,M> builder,
                        Locatable upstream, C clazz, T type ) {
    super(builder,upstream);
    this.clazz = clazz;
    this.type = type;

    elementName = parseElementName(clazz);

    // compute the type name
    // TODO: I guess it must be allowed for enums to have @XmlElement
    typeName = parseTypeName(clazz);

    // locate the base type.
    // this can be done eagerly because there shouldn't be no cycle.
    XmlEnum xe = builder.reader.getClassAnnotation(XmlEnum.class, clazz, this);
    if(xe!=null) {
        T base = builder.reader.getClassValue(xe, "value");
        baseType = builder.getTypeInfo(base,this);
    } else {
        baseType = builder.getTypeInfo(builder.nav.ref(String.class),this);
    }
}
 
Example #2
Source File: EnumLeafInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param clazz
 * @param type
 *      clazz and type should both point to the enum class
 *      that this {@link EnumLeafInfo} represents.
 *      Because of the type parameterization we have to take them separately.
 */
public EnumLeafInfoImpl(ModelBuilder<T,C,F,M> builder,
                        Locatable upstream, C clazz, T type ) {
    super(builder,upstream);
    this.clazz = clazz;
    this.type = type;

    elementName = parseElementName(clazz);

    // compute the type name
    // TODO: I guess it must be allowed for enums to have @XmlElement
    typeName = parseTypeName(clazz);

    // locate the base type.
    // this can be done eagerly because there shouldn't be no cycle.
    XmlEnum xe = builder.reader.getClassAnnotation(XmlEnum.class, clazz, this);
    if(xe!=null) {
        T base = builder.reader.getClassValue(xe, "value");
        baseType = builder.getTypeInfo(base,this);
    } else {
        baseType = builder.getTypeInfo(builder.nav.ref(String.class),this);
    }
}
 
Example #3
Source File: ModelBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Have the builder recognize the type (if it hasn't done so yet),
 * and returns a {@link NonElement} that represents it.
 *
 * @return
 *      always non-null.
 */
public NonElement<T,C> getTypeInfo(T t,Locatable upstream) {
    NonElement<T,C> r = typeInfoSet.getTypeInfo(t);
    if(r!=null)     return r;

    if(nav.isArray(t)) { // no need for checking byte[], because above typeInfoset.getTypeInfo() would return non-null
        ArrayInfoImpl<T,C,F,M> ai =
            createArrayInfo(upstream, t);
        addTypeName(ai);
        typeInfoSet.add(ai);
        return ai;
    }

    C c = nav.asDecl(t);
    assert c!=null : t.toString()+" must be a leaf, but we failed to recognize it.";
    return getClassInfo(c,upstream);
}
 
Example #4
Source File: ModelBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Have the builder recognize the type (if it hasn't done so yet),
 * and returns a {@link NonElement} that represents it.
 *
 * @return
 *      always non-null.
 */
public NonElement<T,C> getTypeInfo(T t,Locatable upstream) {
    NonElement<T,C> r = typeInfoSet.getTypeInfo(t);
    if(r!=null)     return r;

    if(nav.isArray(t)) { // no need for checking byte[], because above typeInfoset.getTypeInfo() would return non-null
        ArrayInfoImpl<T,C,F,M> ai =
            createArrayInfo(upstream, t);
        addTypeName(ai);
        typeInfoSet.add(ai);
        return ai;
    }

    C c = nav.asDecl(t);
    assert c!=null : t.toString()+" must be a leaf, but we failed to recognize it.";
    return getClassInfo(c,upstream);
}
 
Example #5
Source File: ModelBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Have the builder recognize the type (if it hasn't done so yet),
 * and returns a {@link NonElement} that represents it.
 *
 * @return
 *      always non-null.
 */
public NonElement<T,C> getTypeInfo(T t,Locatable upstream) {
    NonElement<T,C> r = typeInfoSet.getTypeInfo(t);
    if(r!=null)     return r;

    if(nav.isArray(t)) { // no need for checking byte[], because above typeInfoset.getTypeInfo() would return non-null
        ArrayInfoImpl<T,C,F,M> ai =
            createArrayInfo(upstream, t);
        addTypeName(ai);
        typeInfoSet.add(ai);
        return ai;
    }

    C c = nav.asDecl(t);
    assert c!=null : t.toString()+" must be a leaf, but we failed to recognize it.";
    return getClassInfo(c,upstream);
}
 
Example #6
Source File: ModelBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Have the builder recognize the type (if it hasn't done so yet),
 * and returns a {@link NonElement} that represents it.
 *
 * @return
 *      always non-null.
 */
public NonElement<T,C> getTypeInfo(T t,Locatable upstream) {
    NonElement<T,C> r = typeInfoSet.getTypeInfo(t);
    if(r!=null)     return r;

    if(nav.isArray(t)) { // no need for checking byte[], because above typeInfoset.getTypeInfo() would return non-null
        ArrayInfoImpl<T,C,F,M> ai =
            createArrayInfo(upstream, t);
        addTypeName(ai);
        typeInfoSet.add(ai);
        return ai;
    }

    C c = nav.asDecl(t);
    assert c!=null : t.toString()+" must be a leaf, but we failed to recognize it.";
    return getClassInfo(c,upstream);
}
 
Example #7
Source File: TypeInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected TypeInfoImpl(
    ModelBuilder<TypeT,ClassDeclT,FieldT,MethodT> builder,
    Locatable upstream) {

    this.builder = builder;
    this.owner = builder.typeInfoSet;
    this.upstream = upstream;
}
 
Example #8
Source File: Util.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static <T,C,F,M> QName calcSchemaType(
        AnnotationReader<T,C,F,M> reader,
        AnnotationSource primarySource, C enclosingClass, T individualType, Locatable src ) {

    XmlSchemaType xst = primarySource.readAnnotation(XmlSchemaType.class);
    if(xst!=null) {
        return new QName(xst.namespace(),xst.name());
    }

    // check the defaulted annotation
    XmlSchemaTypes xsts = reader.getPackageAnnotation(XmlSchemaTypes.class,enclosingClass,src);
    XmlSchemaType[] values = null;
    if(xsts!=null)
        values = xsts.value();
    else {
        xst = reader.getPackageAnnotation(XmlSchemaType.class,enclosingClass,src);
        if(xst!=null) {
            values = new XmlSchemaType[1];
            values[0] = xst;
        }
    }
    if(values!=null) {
        for( XmlSchemaType item : values ) {
            if(reader.getClassValue(item,"type").equals(individualType)) {
                return new QName(item.namespace(),item.name());
            }
        }
    }

    return null;
}
 
Example #9
Source File: IllegalAnnotationException.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private List<List<Location>> build(Locatable... srcs) {
    List<List<Location>> r = new ArrayList<List<Location>>();
    for( Locatable l : srcs ) {
        if(l!=null) {
            List<Location> ll = convert(l);
            if(ll!=null && !ll.isEmpty())
                r.add(ll);
        }
    }
    return Collections.unmodifiableList(r);
}
 
Example #10
Source File: TypeInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected TypeInfoImpl(
    ModelBuilder<TypeT,ClassDeclT,FieldT,MethodT> builder,
    Locatable upstream) {

    this.builder = builder;
    this.owner = builder.typeInfoSet;
    this.upstream = upstream;
}
 
Example #11
Source File: Util.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static <T,C,F,M> QName calcSchemaType(
        AnnotationReader<T,C,F,M> reader,
        AnnotationSource primarySource, C enclosingClass, T individualType, Locatable src ) {

    XmlSchemaType xst = primarySource.readAnnotation(XmlSchemaType.class);
    if(xst!=null) {
        return new QName(xst.namespace(),xst.name());
    }

    // check the defaulted annotation
    XmlSchemaTypes xsts = reader.getPackageAnnotation(XmlSchemaTypes.class,enclosingClass,src);
    XmlSchemaType[] values = null;
    if(xsts!=null)
        values = xsts.value();
    else {
        xst = reader.getPackageAnnotation(XmlSchemaType.class,enclosingClass,src);
        if(xst!=null) {
            values = new XmlSchemaType[1];
            values[0] = xst;
        }
    }
    if(values!=null) {
        for( XmlSchemaType item : values ) {
            if(reader.getClassValue(item,"type").equals(individualType)) {
                return new QName(item.namespace(),item.name());
            }
        }
    }

    return null;
}
 
Example #12
Source File: Util.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static <T,C,F,M> QName calcSchemaType(
        AnnotationReader<T,C,F,M> reader,
        AnnotationSource primarySource, C enclosingClass, T individualType, Locatable src ) {

    XmlSchemaType xst = primarySource.readAnnotation(XmlSchemaType.class);
    if(xst!=null) {
        return new QName(xst.namespace(),xst.name());
    }

    // check the defaulted annotation
    XmlSchemaTypes xsts = reader.getPackageAnnotation(XmlSchemaTypes.class,enclosingClass,src);
    XmlSchemaType[] values = null;
    if(xsts!=null)
        values = xsts.value();
    else {
        xst = reader.getPackageAnnotation(XmlSchemaType.class,enclosingClass,src);
        if(xst!=null) {
            values = new XmlSchemaType[1];
            values[0] = xst;
        }
    }
    if(values!=null) {
        for( XmlSchemaType item : values ) {
            if(reader.getClassValue(item,"type").equals(individualType)) {
                return new QName(item.namespace(),item.name());
            }
        }
    }

    return null;
}
 
Example #13
Source File: IllegalAnnotationException.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private List<List<Location>> build(Locatable... srcs) {
    List<List<Location>> r = new ArrayList<List<Location>>();
    for( Locatable l : srcs ) {
        if(l!=null) {
            List<Location> ll = convert(l);
            if(ll!=null && !ll.isEmpty())
                r.add(ll);
        }
    }
    return Collections.unmodifiableList(r);
}
 
Example #14
Source File: IllegalAnnotationException.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private List<List<Location>> build(Locatable... srcs) {
    List<List<Location>> r = new ArrayList<List<Location>>();
    for( Locatable l : srcs ) {
        if(l!=null) {
            List<Location> ll = convert(l);
            if(ll!=null && !ll.isEmpty())
                r.add(ll);
        }
    }
    return Collections.unmodifiableList(r);
}
 
Example #15
Source File: Util.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static <T,C,F,M> QName calcSchemaType(
        AnnotationReader<T,C,F,M> reader,
        AnnotationSource primarySource, C enclosingClass, T individualType, Locatable src ) {

    XmlSchemaType xst = primarySource.readAnnotation(XmlSchemaType.class);
    if(xst!=null) {
        return new QName(xst.namespace(),xst.name());
    }

    // check the defaulted annotation
    XmlSchemaTypes xsts = reader.getPackageAnnotation(XmlSchemaTypes.class,enclosingClass,src);
    XmlSchemaType[] values = null;
    if(xsts!=null)
        values = xsts.value();
    else {
        xst = reader.getPackageAnnotation(XmlSchemaType.class,enclosingClass,src);
        if(xst!=null) {
            values = new XmlSchemaType[1];
            values[0] = xst;
        }
    }
    if(values!=null) {
        for( XmlSchemaType item : values ) {
            if(reader.getClassValue(item,"type").equals(individualType)) {
                return new QName(item.namespace(),item.name());
            }
        }
    }

    return null;
}
 
Example #16
Source File: IllegalAnnotationException.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private List<List<Location>> build(Locatable... srcs) {
    List<List<Location>> r = new ArrayList<List<Location>>();
    for( Locatable l : srcs ) {
        if(l!=null) {
            List<Location> ll = convert(l);
            if(ll!=null && !ll.isEmpty())
                r.add(ll);
        }
    }
    return Collections.unmodifiableList(r);
}
 
Example #17
Source File: RuntimeModelBuilder.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public RuntimeNonElement getClassInfo( Class clazz, Locatable upstream ) {
    return (RuntimeNonElement)super.getClassInfo(clazz,upstream);
}
 
Example #18
Source File: IllegalAnnotationException.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public IllegalAnnotationException(String message, Locatable src) {
    super(message);
    pos = build(src);
}
 
Example #19
Source File: InlineAnnotationReaderImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public <A extends Annotation> A getMethodAnnotation(Class<A> a, ExecutableElement method, Locatable srcPos) {
    return LocatableAnnotation.create(method.getAnnotation(a),srcPos);
}
 
Example #20
Source File: InlineAnnotationReaderImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public <A extends Annotation> A getPackageAnnotation(Class<A> a, TypeElement clazz, Locatable srcPos) {
    return LocatableAnnotation.create(clazz.getEnclosingElement().getAnnotation(a), srcPos);
}
 
Example #21
Source File: IllegalAnnotationException.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public IllegalAnnotationException(String message, Locatable src1, Locatable src2) {
    super(message);
    pos = build(src1,src2);
}
 
Example #22
Source File: IllegalAnnotationException.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public IllegalAnnotationException(String message, Locatable src) {
    super(message);
    pos = build(src);
}
 
Example #23
Source File: IllegalAnnotationException.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public IllegalAnnotationException(String message, Locatable src1, Locatable src2) {
    super(message);
    pos = build(src1,src2);
}
 
Example #24
Source File: InlineAnnotationReaderImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public <A extends Annotation> A getPackageAnnotation(Class<A> a, TypeElement clazz, Locatable srcPos) {
    return LocatableAnnotation.create(clazz.getEnclosingElement().getAnnotation(a), srcPos);
}
 
Example #25
Source File: IllegalAnnotationException.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public IllegalAnnotationException(String message, Locatable src) {
    super(message);
    pos = build(src);
}
 
Example #26
Source File: IllegalAnnotationException.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public IllegalAnnotationException(String message, Throwable cause, Locatable src) {
    super(message, cause);
    pos = build(src);
}
 
Example #27
Source File: FieldPropertySeed.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Use the enclosing class as the upsream {@link Location}.
 */
public Locatable getUpstream() {
    return parent;
}
 
Example #28
Source File: RuntimeEnumLeafInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
RuntimeEnumLeafInfoImpl(RuntimeModelBuilder builder, Locatable upstream, Class<T> enumType) {
    super(builder,upstream,enumType,enumType);
    this.printMap = new EnumMap<T,B>(enumType);

    baseXducer = ((RuntimeNonElement)baseType).getTransducer();
}
 
Example #29
Source File: RegistryInfoImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Locatable getUpstream() {
    return upstream;
}
 
Example #30
Source File: AnyTypeImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Locatable getUpstream() {
    return null;
}