com.sun.xml.internal.txw2.annotation.XmlCDATA Java Examples

The following examples show how to use com.sun.xml.internal.txw2.annotation.XmlCDATA. 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: ContainerElement.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes a new element.
 */
private Object addElement(XmlElement e, Method method, Object[] args) {
    Class<?> rt = method.getReturnType();

    // the last precedence: default name
    String nsUri = "##default";
    String localName = method.getName();

    if(e!=null) {
        // then the annotation on this method
        if(e.value().length()!=0)
            localName = e.value();
        nsUri = e.ns();
    }

    if(nsUri.equals("##default")) {
        // look for the annotation on the declaring class
        Class<?> c = method.getDeclaringClass();
        XmlElement ce = c.getAnnotation(XmlElement.class);
        if(ce!=null) {
            nsUri = ce.ns();
        }

        if(nsUri.equals("##default"))
            // then default to the XmlNamespace
            nsUri = getNamespace(c.getPackage());
    }



    if(rt==Void.TYPE) {
        // leaf element with just a value

        boolean isCDATA = method.getAnnotation(XmlCDATA.class)!=null;

        StartTag st = new StartTag(document,nsUri,localName);
        addChild(st);
        for( Object arg : args ) {
            Text text;
            if(isCDATA)     text = new Cdata(document,st,arg);
            else            text = new Pcdata(document,st,arg);
            addChild(text);
        }
        addChild(new EndTag());
        return null;
    }
    if(TypedXmlWriter.class.isAssignableFrom(rt)) {
        // sub writer
        return _element(nsUri,localName,(Class)rt);
    }

    throw new IllegalSignatureException("Illegal return type: "+rt);
}
 
Example #2
Source File: ContainerElement.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes a new element.
 */
private Object addElement(XmlElement e, Method method, Object[] args) {
    Class<?> rt = method.getReturnType();

    // the last precedence: default name
    String nsUri = "##default";
    String localName = method.getName();

    if(e!=null) {
        // then the annotation on this method
        if(e.value().length()!=0)
            localName = e.value();
        nsUri = e.ns();
    }

    if(nsUri.equals("##default")) {
        // look for the annotation on the declaring class
        Class<?> c = method.getDeclaringClass();
        XmlElement ce = c.getAnnotation(XmlElement.class);
        if(ce!=null) {
            nsUri = ce.ns();
        }

        if(nsUri.equals("##default"))
            // then default to the XmlNamespace
            nsUri = getNamespace(c.getPackage());
    }



    if(rt==Void.TYPE) {
        // leaf element with just a value

        boolean isCDATA = method.getAnnotation(XmlCDATA.class)!=null;

        StartTag st = new StartTag(document,nsUri,localName);
        addChild(st);
        for( Object arg : args ) {
            Text text;
            if(isCDATA)     text = new Cdata(document,st,arg);
            else            text = new Pcdata(document,st,arg);
            addChild(text);
        }
        addChild(new EndTag());
        return null;
    }
    if(TypedXmlWriter.class.isAssignableFrom(rt)) {
        // sub writer
        return _element(nsUri,localName,(Class)rt);
    }

    throw new IllegalSignatureException("Illegal return type: "+rt);
}
 
Example #3
Source File: ContainerElement.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes a new element.
 */
private Object addElement(XmlElement e, Method method, Object[] args) {
    Class<?> rt = method.getReturnType();

    // the last precedence: default name
    String nsUri = "##default";
    String localName = method.getName();

    if(e!=null) {
        // then the annotation on this method
        if(e.value().length()!=0)
            localName = e.value();
        nsUri = e.ns();
    }

    if(nsUri.equals("##default")) {
        // look for the annotation on the declaring class
        Class<?> c = method.getDeclaringClass();
        XmlElement ce = c.getAnnotation(XmlElement.class);
        if(ce!=null) {
            nsUri = ce.ns();
        }

        if(nsUri.equals("##default"))
            // then default to the XmlNamespace
            nsUri = getNamespace(c.getPackage());
    }



    if(rt==Void.TYPE) {
        // leaf element with just a value

        boolean isCDATA = method.getAnnotation(XmlCDATA.class)!=null;

        StartTag st = new StartTag(document,nsUri,localName);
        addChild(st);
        for( Object arg : args ) {
            Text text;
            if(isCDATA)     text = new Cdata(document,st,arg);
            else            text = new Pcdata(document,st,arg);
            addChild(text);
        }
        addChild(new EndTag());
        return null;
    }
    if(TypedXmlWriter.class.isAssignableFrom(rt)) {
        // sub writer
        return _element(nsUri,localName,(Class)rt);
    }

    throw new IllegalSignatureException("Illegal return type: "+rt);
}
 
Example #4
Source File: ContainerElement.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes a new element.
 */
private Object addElement(XmlElement e, Method method, Object[] args) {
    Class<?> rt = method.getReturnType();

    // the last precedence: default name
    String nsUri = "##default";
    String localName = method.getName();

    if(e!=null) {
        // then the annotation on this method
        if(e.value().length()!=0)
            localName = e.value();
        nsUri = e.ns();
    }

    if(nsUri.equals("##default")) {
        // look for the annotation on the declaring class
        Class<?> c = method.getDeclaringClass();
        XmlElement ce = c.getAnnotation(XmlElement.class);
        if(ce!=null) {
            nsUri = ce.ns();
        }

        if(nsUri.equals("##default"))
            // then default to the XmlNamespace
            nsUri = getNamespace(c.getPackage());
    }



    if(rt==Void.TYPE) {
        // leaf element with just a value

        boolean isCDATA = method.getAnnotation(XmlCDATA.class)!=null;

        StartTag st = new StartTag(document,nsUri,localName);
        addChild(st);
        for( Object arg : args ) {
            Text text;
            if(isCDATA)     text = new Cdata(document,st,arg);
            else            text = new Pcdata(document,st,arg);
            addChild(text);
        }
        addChild(new EndTag());
        return null;
    }
    if(TypedXmlWriter.class.isAssignableFrom(rt)) {
        // sub writer
        return _element(nsUri,localName,(Class)rt);
    }

    throw new IllegalSignatureException("Illegal return type: "+rt);
}
 
Example #5
Source File: ContainerElement.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes a new element.
 */
private Object addElement(XmlElement e, Method method, Object[] args) {
    Class<?> rt = method.getReturnType();

    // the last precedence: default name
    String nsUri = "##default";
    String localName = method.getName();

    if(e!=null) {
        // then the annotation on this method
        if(e.value().length()!=0)
            localName = e.value();
        nsUri = e.ns();
    }

    if(nsUri.equals("##default")) {
        // look for the annotation on the declaring class
        Class<?> c = method.getDeclaringClass();
        XmlElement ce = c.getAnnotation(XmlElement.class);
        if(ce!=null) {
            nsUri = ce.ns();
        }

        if(nsUri.equals("##default"))
            // then default to the XmlNamespace
            nsUri = getNamespace(c.getPackage());
    }



    if(rt==Void.TYPE) {
        // leaf element with just a value

        boolean isCDATA = method.getAnnotation(XmlCDATA.class)!=null;

        StartTag st = new StartTag(document,nsUri,localName);
        addChild(st);
        for( Object arg : args ) {
            Text text;
            if(isCDATA)     text = new Cdata(document,st,arg);
            else            text = new Pcdata(document,st,arg);
            addChild(text);
        }
        addChild(new EndTag());
        return null;
    }
    if(TypedXmlWriter.class.isAssignableFrom(rt)) {
        // sub writer
        return _element(nsUri,localName,(Class)rt);
    }

    throw new IllegalSignatureException("Illegal return type: "+rt);
}
 
Example #6
Source File: ContainerElement.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes a new element.
 */
private Object addElement(XmlElement e, Method method, Object[] args) {
    Class<?> rt = method.getReturnType();

    // the last precedence: default name
    String nsUri = "##default";
    String localName = method.getName();

    if(e!=null) {
        // then the annotation on this method
        if(e.value().length()!=0)
            localName = e.value();
        nsUri = e.ns();
    }

    if(nsUri.equals("##default")) {
        // look for the annotation on the declaring class
        Class<?> c = method.getDeclaringClass();
        XmlElement ce = c.getAnnotation(XmlElement.class);
        if(ce!=null) {
            nsUri = ce.ns();
        }

        if(nsUri.equals("##default"))
            // then default to the XmlNamespace
            nsUri = getNamespace(c.getPackage());
    }



    if(rt==Void.TYPE) {
        // leaf element with just a value

        boolean isCDATA = method.getAnnotation(XmlCDATA.class)!=null;

        StartTag st = new StartTag(document,nsUri,localName);
        addChild(st);
        for( Object arg : args ) {
            Text text;
            if(isCDATA)     text = new Cdata(document,st,arg);
            else            text = new Pcdata(document,st,arg);
            addChild(text);
        }
        addChild(new EndTag());
        return null;
    }
    if(TypedXmlWriter.class.isAssignableFrom(rt)) {
        // sub writer
        return _element(nsUri,localName,(Class)rt);
    }

    throw new IllegalSignatureException("Illegal return type: "+rt);
}
 
Example #7
Source File: ContainerElement.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes a new element.
 */
private Object addElement(XmlElement e, Method method, Object[] args) {
    Class<?> rt = method.getReturnType();

    // the last precedence: default name
    String nsUri = "##default";
    String localName = method.getName();

    if(e!=null) {
        // then the annotation on this method
        if(e.value().length()!=0)
            localName = e.value();
        nsUri = e.ns();
    }

    if(nsUri.equals("##default")) {
        // look for the annotation on the declaring class
        Class<?> c = method.getDeclaringClass();
        XmlElement ce = c.getAnnotation(XmlElement.class);
        if(ce!=null) {
            nsUri = ce.ns();
        }

        if(nsUri.equals("##default"))
            // then default to the XmlNamespace
            nsUri = getNamespace(c.getPackage());
    }



    if(rt==Void.TYPE) {
        // leaf element with just a value

        boolean isCDATA = method.getAnnotation(XmlCDATA.class)!=null;

        StartTag st = new StartTag(document,nsUri,localName);
        addChild(st);
        for( Object arg : args ) {
            Text text;
            if(isCDATA)     text = new Cdata(document,st,arg);
            else            text = new Pcdata(document,st,arg);
            addChild(text);
        }
        addChild(new EndTag());
        return null;
    }
    if(TypedXmlWriter.class.isAssignableFrom(rt)) {
        // sub writer
        return _element(nsUri,localName,(Class)rt);
    }

    throw new IllegalSignatureException("Illegal return type: "+rt);
}
 
Example #8
Source File: ContainerElement.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes a new element.
 */
private Object addElement(XmlElement e, Method method, Object[] args) {
    Class<?> rt = method.getReturnType();

    // the last precedence: default name
    String nsUri = "##default";
    String localName = method.getName();

    if(e!=null) {
        // then the annotation on this method
        if(e.value().length()!=0)
            localName = e.value();
        nsUri = e.ns();
    }

    if(nsUri.equals("##default")) {
        // look for the annotation on the declaring class
        Class<?> c = method.getDeclaringClass();
        XmlElement ce = c.getAnnotation(XmlElement.class);
        if(ce!=null) {
            nsUri = ce.ns();
        }

        if(nsUri.equals("##default"))
            // then default to the XmlNamespace
            nsUri = getNamespace(c.getPackage());
    }



    if(rt==Void.TYPE) {
        // leaf element with just a value

        boolean isCDATA = method.getAnnotation(XmlCDATA.class)!=null;

        StartTag st = new StartTag(document,nsUri,localName);
        addChild(st);
        for( Object arg : args ) {
            Text text;
            if(isCDATA)     text = new Cdata(document,st,arg);
            else            text = new Pcdata(document,st,arg);
            addChild(text);
        }
        addChild(new EndTag());
        return null;
    }
    if(TypedXmlWriter.class.isAssignableFrom(rt)) {
        // sub writer
        return _element(nsUri,localName,(Class)rt);
    }

    throw new IllegalSignatureException("Illegal return type: "+rt);
}