当前位置: 首页>>代码示例>>Java>>正文


Java XmlElement.ns方法代码示例

本文整理汇总了Java中com.sun.xml.internal.txw2.annotation.XmlElement.ns方法的典型用法代码示例。如果您正苦于以下问题:Java XmlElement.ns方法的具体用法?Java XmlElement.ns怎么用?Java XmlElement.ns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.xml.internal.txw2.annotation.XmlElement的用法示例。


在下文中一共展示了XmlElement.ns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTagName

import com.sun.xml.internal.txw2.annotation.XmlElement; //导入方法依赖的package包/类
static QName getTagName( Class<?> c ) {
    String localName="";
    String nsUri="##default";

    XmlElement xe = c.getAnnotation(XmlElement.class);
    if(xe!=null) {
        localName = xe.value();
        nsUri = xe.ns();
    }

    if(localName.length()==0) {
        localName = c.getName();
        int idx = localName.lastIndexOf('.');
        if(idx>=0)
            localName = localName.substring(idx+1);

        localName = Character.toLowerCase(localName.charAt(0))+localName.substring(1);
    }

    if(nsUri.equals("##default")) {
        Package pkg = c.getPackage();
        if(pkg!=null) {
            XmlNamespace xn = pkg.getAnnotation(XmlNamespace.class);
            if(xn!=null)
                nsUri = xn.value();
        }
    }
    if(nsUri.equals("##default"))
        nsUri = "";

    return new QName(nsUri,localName);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:TXW.java

示例2: addElement

import com.sun.xml.internal.txw2.annotation.XmlElement; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:56,代码来源:ContainerElement.java


注:本文中的com.sun.xml.internal.txw2.annotation.XmlElement.ns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。