com.sun.xml.internal.bind.v2.runtime.Name Java Examples

The following examples show how to use com.sun.xml.internal.bind.v2.runtime.Name. 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: FastInfosetStreamWriterOutput.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void writeLiteral(int type, Name name, String prefix, String namespaceURI) throws IOException {
    final int localNameIndex = tables.localNameIndexes[name.localNameIndex] - tables.indexOffset;

    if (localNameIndex < 0) {
        tables.localNameIndexes[name.localNameIndex] = fiout.getNextLocalNameIndex() + tables.indexOffset;

        fiout.writeLowLevelStartNameLiteral(
                type,
                prefix,
                localNames[name.localNameIndex].buf,
                namespaceURI);
    } else {
        fiout.writeLowLevelStartNameLiteral(
                type,
                prefix,
                localNameIndex,
                namespaceURI);
    }
}
 
Example #2
Source File: FastInfosetStreamWriterOutput.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void writeLiteral(int type, Name name, String prefix, String namespaceURI) throws IOException {
    final int localNameIndex = tables.localNameIndexes[name.localNameIndex] - tables.indexOffset;

    if (localNameIndex < 0) {
        tables.localNameIndexes[name.localNameIndex] = fiout.getNextLocalNameIndex() + tables.indexOffset;

        fiout.writeLowLevelStartNameLiteral(
                type,
                prefix,
                localNames[name.localNameIndex].buf,
                namespaceURI);
    } else {
        fiout.writeLowLevelStartNameLiteral(
                type,
                prefix,
                localNameIndex,
                namespaceURI);
    }
}
 
Example #3
Source File: ArrayElementProperty.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected ArrayElementProperty(JAXBContextImpl grammar, RuntimeElementPropertyInfo prop) {
    super(grammar, prop, prop.getXmlName(), prop.isCollectionNillable());
    this.prop = prop;

    List<? extends RuntimeTypeRef> types = prop.getTypes();

    Name n = null;

    for (RuntimeTypeRef typeRef : types) {
        Class type = (Class)typeRef.getTarget().getType();
        if(type.isPrimitive())
            type = RuntimeUtil.primitiveToBox.get(type);

        JaxBeanInfo beanInfo = grammar.getOrCreate(typeRef.getTarget());
        TagAndType tt = new TagAndType(
                            grammar.nameBuilder.createElementName(typeRef.getTagName()),
                            beanInfo);
        typeMap.put(type,tt);
        refs.put(typeRef,beanInfo);
        if(typeRef.isNillable() && n==null)
            n = tt.tagName;
    }

    nillableTagName = n;
}
 
Example #4
Source File: ArrayElementProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected ArrayElementProperty(JAXBContextImpl grammar, RuntimeElementPropertyInfo prop) {
    super(grammar, prop, prop.getXmlName(), prop.isCollectionNillable());
    this.prop = prop;

    List<? extends RuntimeTypeRef> types = prop.getTypes();

    Name n = null;

    for (RuntimeTypeRef typeRef : types) {
        Class type = (Class)typeRef.getTarget().getType();
        if(type.isPrimitive())
            type = RuntimeUtil.primitiveToBox.get(type);

        JaxBeanInfo beanInfo = grammar.getOrCreate(typeRef.getTarget());
        TagAndType tt = new TagAndType(
                            grammar.nameBuilder.createElementName(typeRef.getTagName()),
                            beanInfo);
        typeMap.put(type,tt);
        refs.put(typeRef,beanInfo);
        if(typeRef.isNillable() && n==null)
            n = tt.tagName;
    }

    nillableTagName = n;
}
 
Example #5
Source File: FastInfosetStreamWriterOutput.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void beginStartTag(Name name) throws IOException {
    fiout.writeLowLevelTerminationAndMark();

    if (nsContext.getCurrent().count() == 0) {
        final int qNameIndex = tables.elementIndexes[name.qNameIndex] - tables.indexOffset;
        final int prefixIndex = nsUriIndex2prefixIndex[name.nsUriIndex];

        if (qNameIndex >= 0 &&
                tables.elementIndexPrefixes[name.qNameIndex] == prefixIndex) {
            fiout.writeLowLevelStartElementIndexed(EncodingConstants.ELEMENT, qNameIndex);
        } else {
            tables.elementIndexes[name.qNameIndex] = fiout.getNextElementIndex() + tables.indexOffset;
            tables.elementIndexPrefixes[name.qNameIndex] = prefixIndex;
            writeLiteral(EncodingConstants.ELEMENT | EncodingConstants.ELEMENT_LITERAL_QNAME_FLAG,
                    name,
                    nsContext.getPrefix(prefixIndex),
                    nsContext.getNamespaceURI(prefixIndex));
        }
    } else {
        beginStartTagWithNamespaces(name);
    }
}
 
Example #6
Source File: FastInfosetStreamWriterOutput.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void beginStartTag(Name name) throws IOException {
    fiout.writeLowLevelTerminationAndMark();

    if (nsContext.getCurrent().count() == 0) {
        final int qNameIndex = tables.elementIndexes[name.qNameIndex] - tables.indexOffset;
        final int prefixIndex = nsUriIndex2prefixIndex[name.nsUriIndex];

        if (qNameIndex >= 0 &&
                tables.elementIndexPrefixes[name.qNameIndex] == prefixIndex) {
            fiout.writeLowLevelStartElementIndexed(EncodingConstants.ELEMENT, qNameIndex);
        } else {
            tables.elementIndexes[name.qNameIndex] = fiout.getNextElementIndex() + tables.indexOffset;
            tables.elementIndexPrefixes[name.qNameIndex] = prefixIndex;
            writeLiteral(EncodingConstants.ELEMENT | EncodingConstants.ELEMENT_LITERAL_QNAME_FLAG,
                    name,
                    nsContext.getPrefix(prefixIndex),
                    nsContext.getNamespaceURI(prefixIndex));
        }
    } else {
        beginStartTagWithNamespaces(name);
    }
}
 
Example #7
Source File: ArrayElementProperty.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected ArrayElementProperty(JAXBContextImpl grammar, RuntimeElementPropertyInfo prop) {
    super(grammar, prop, prop.getXmlName(), prop.isCollectionNillable());
    this.prop = prop;

    List<? extends RuntimeTypeRef> types = prop.getTypes();

    Name n = null;

    for (RuntimeTypeRef typeRef : types) {
        Class type = (Class)typeRef.getTarget().getType();
        if(type.isPrimitive())
            type = RuntimeUtil.primitiveToBox.get(type);

        JaxBeanInfo beanInfo = grammar.getOrCreate(typeRef.getTarget());
        TagAndType tt = new TagAndType(
                            grammar.nameBuilder.createElementName(typeRef.getTagName()),
                            beanInfo);
        typeMap.put(type,tt);
        refs.put(typeRef,beanInfo);
        if(typeRef.isNillable() && n==null)
            n = tt.tagName;
    }

    nillableTagName = n;
}
 
Example #8
Source File: FastInfosetStreamWriterOutput.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void attribute(Name name, String value) throws IOException {
    fiout.writeLowLevelStartAttributes();

    final int qNameIndex = tables.attributeIndexes[name.qNameIndex] - tables.indexOffset;
    if (qNameIndex >= 0) {
        fiout.writeLowLevelAttributeIndexed(qNameIndex);
    } else {
        tables.attributeIndexes[name.qNameIndex] = fiout.getNextAttributeIndex() + tables.indexOffset;

        final int namespaceURIId = name.nsUriIndex;
        if (namespaceURIId == -1) {
            writeLiteral(EncodingConstants.ATTRIBUTE_LITERAL_QNAME_FLAG,
                    name,
                    "",
                    "");
        } else {
            final int prefix = nsUriIndex2prefixIndex[namespaceURIId];
            writeLiteral(EncodingConstants.ATTRIBUTE_LITERAL_QNAME_FLAG,
                    name,
                    nsContext.getPrefix(prefix),
                    nsContext.getNamespaceURI(prefix));
        }
    }

    fiout.writeLowLevelAttributeValue(value);
}
 
Example #9
Source File: FastInfosetStreamWriterOutput.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void beginStartTagWithNamespaces(Name name) throws IOException {
    final NamespaceContextImpl.Element nse = nsContext.getCurrent();

    fiout.writeLowLevelStartNamespaces();
    for (int i = nse.count() - 1; i >= 0; i--) {
        final String uri = nse.getNsUri(i);
        if (uri.length() == 0 && nse.getBase() == 1)
            continue;   // no point in definint xmlns='' on the root
        fiout.writeLowLevelNamespace(nse.getPrefix(i), uri);
    }
    fiout.writeLowLevelEndNamespaces();

    final int qNameIndex = tables.elementIndexes[name.qNameIndex] - tables.indexOffset;
    final int prefixIndex = nsUriIndex2prefixIndex[name.nsUriIndex];

    if (qNameIndex >= 0 &&
            tables.elementIndexPrefixes[name.qNameIndex] == prefixIndex) {
        fiout.writeLowLevelStartElementIndexed(0, qNameIndex);
    } else {
        tables.elementIndexes[name.qNameIndex] = fiout.getNextElementIndex() + tables.indexOffset;
        tables.elementIndexPrefixes[name.qNameIndex] = prefixIndex;
        writeLiteral(EncodingConstants.ELEMENT_LITERAL_QNAME_FLAG,
                name,
                nsContext.getPrefix(prefixIndex),
                nsContext.getNamespaceURI(prefixIndex));
    }
}
 
Example #10
Source File: UTF8XmlOutput.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void attribute(Name name, String value) throws IOException {
    write(' ');
    if(name.nsUriIndex==-1) {
        localNames[name.localNameIndex].write(this);
    } else
        writeName(name);
    write(EQUALS);
    doText(value,true);
    write('\"');
}
 
Example #11
Source File: FastInfosetStreamWriterOutput.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void attribute(Name name, String value) throws IOException {
    fiout.writeLowLevelStartAttributes();

    final int qNameIndex = tables.attributeIndexes[name.qNameIndex] - tables.indexOffset;
    if (qNameIndex >= 0) {
        fiout.writeLowLevelAttributeIndexed(qNameIndex);
    } else {
        tables.attributeIndexes[name.qNameIndex] = fiout.getNextAttributeIndex() + tables.indexOffset;

        final int namespaceURIId = name.nsUriIndex;
        if (namespaceURIId == -1) {
            writeLiteral(EncodingConstants.ATTRIBUTE_LITERAL_QNAME_FLAG,
                    name,
                    "",
                    "");
        } else {
            final int prefix = nsUriIndex2prefixIndex[namespaceURIId];
            writeLiteral(EncodingConstants.ATTRIBUTE_LITERAL_QNAME_FLAG,
                    name,
                    nsContext.getPrefix(prefix),
                    nsContext.getNamespaceURI(prefix));
        }
    }

    fiout.writeLowLevelAttributeValue(value);
}
 
Example #12
Source File: C14nXmlOutput.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void attribute(Name name, String value) throws IOException {
    if(staticAttributes.length==len) {
        // reallocate
        int newLen = len*2;
        StaticAttribute[] newbuf = new StaticAttribute[newLen];
        System.arraycopy(staticAttributes,0,newbuf,0,len);
        for(int i=len;i<newLen;i++)
            staticAttributes[i] = new StaticAttribute();
        staticAttributes = newbuf;
    }

    staticAttributes[len++].set(name,value);
}
 
Example #13
Source File: XmlOutputAbstractImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void attribute( Name name, String value ) throws IOException, XMLStreamException {
    short idx = name.nsUriIndex;
    if(idx==-1)
        attribute(-1,name.localName, value);
    else
        attribute( nsUriIndex2prefixIndex[idx], name.localName, value );
}
 
Example #14
Source File: TransducedAccessor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void writeLeafElement(XMLSerializer w, Name tagName, BeanT o, String fieldName) throws SAXException, AccessorException, IOException, XMLStreamException {
    w.startElement(tagName,null);
    declareNamespace(o,w);
    w.endNamespaceDecls(null);
    w.endAttributes();
    xducer.writeText(w,acc.get(o),fieldName);
    w.endElement();
}
 
Example #15
Source File: TransducedAccessor.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void writeLeafElement(XMLSerializer w, Name tagName, BeanT o, String fieldName) throws SAXException, AccessorException, IOException, XMLStreamException {
    w.startElement(tagName,null);
    declareNamespace(o,w);
    w.endNamespaceDecls(null);
    w.endAttributes();
    xducer.writeText(w,acc.get(o),fieldName);
    w.endElement();
}
 
Example #16
Source File: UTF8XmlOutput.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void endTag(Name name) throws IOException {
    if(closeStartTagPending) {
        write(EMPTY_TAG);
        closeStartTagPending = false;
    } else {
        write(CLOSE_TAG);
        writeName(name);
        write('>');
    }
}
 
Example #17
Source File: UTF8XmlOutput.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void beginStartTag(Name name) throws IOException {
    closeStartTag();
    int base = pushNsDecls();
    write('<');
    writeName(name);
    writeNsDecls(base);
}
 
Example #18
Source File: TransducedAccessor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void writeLeafElement(XMLSerializer w, Name tagName, BeanT o, String fieldName) throws SAXException, AccessorException, IOException, XMLStreamException {
    w.startElement(tagName,null);
    declareNamespace(o,w);
    w.endNamespaceDecls(null);
    w.endAttributes();
    xducer.writeText(w,acc.get(o),fieldName);
    w.endElement();
}
 
Example #19
Source File: UTF8XmlOutput.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void endTag(Name name) throws IOException {
    if(closeStartTagPending) {
        write(EMPTY_TAG);
        closeStartTagPending = false;
    } else {
        write(CLOSE_TAG);
        writeName(name);
        write('>');
    }
}
 
Example #20
Source File: UTF8XmlOutput.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void beginStartTag(Name name) throws IOException {
    closeStartTag();
    int base = pushNsDecls();
    write('<');
    writeName(name);
    writeNsDecls(base);
}
 
Example #21
Source File: XmlOutputAbstractImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void attribute( Name name, String value ) throws IOException, XMLStreamException {
    short idx = name.nsUriIndex;
    if(idx==-1)
        attribute(-1,name.localName, value);
    else
        attribute( nsUriIndex2prefixIndex[idx], name.localName, value );
}
 
Example #22
Source File: C14nXmlOutput.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void attribute(Name name, String value) throws IOException {
    if(staticAttributes.length==len) {
        // reallocate
        int newLen = len*2;
        StaticAttribute[] newbuf = new StaticAttribute[newLen];
        System.arraycopy(staticAttributes,0,newbuf,0,len);
        for(int i=len;i<newLen;i++)
            staticAttributes[i] = new StaticAttribute();
        staticAttributes = newbuf;
    }

    staticAttributes[len++].set(name,value);
}
 
Example #23
Source File: FastInfosetStreamWriterOutput.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void beginStartTagWithNamespaces(Name name) throws IOException {
    final NamespaceContextImpl.Element nse = nsContext.getCurrent();

    fiout.writeLowLevelStartNamespaces();
    for (int i = nse.count() - 1; i >= 0; i--) {
        final String uri = nse.getNsUri(i);
        if (uri.length() == 0 && nse.getBase() == 1)
            continue;   // no point in definint xmlns='' on the root
        fiout.writeLowLevelNamespace(nse.getPrefix(i), uri);
    }
    fiout.writeLowLevelEndNamespaces();

    final int qNameIndex = tables.elementIndexes[name.qNameIndex] - tables.indexOffset;
    final int prefixIndex = nsUriIndex2prefixIndex[name.nsUriIndex];

    if (qNameIndex >= 0 &&
            tables.elementIndexPrefixes[name.qNameIndex] == prefixIndex) {
        fiout.writeLowLevelStartElementIndexed(0, qNameIndex);
    } else {
        tables.elementIndexes[name.qNameIndex] = fiout.getNextElementIndex() + tables.indexOffset;
        tables.elementIndexPrefixes[name.qNameIndex] = prefixIndex;
        writeLiteral(EncodingConstants.ELEMENT_LITERAL_QNAME_FLAG,
                name,
                nsContext.getPrefix(prefixIndex),
                nsContext.getNamespaceURI(prefixIndex));
    }
}
 
Example #24
Source File: FastInfosetStreamWriterOutput.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void attribute(Name name, String value) throws IOException {
    fiout.writeLowLevelStartAttributes();

    final int qNameIndex = tables.attributeIndexes[name.qNameIndex] - tables.indexOffset;
    if (qNameIndex >= 0) {
        fiout.writeLowLevelAttributeIndexed(qNameIndex);
    } else {
        tables.attributeIndexes[name.qNameIndex] = fiout.getNextAttributeIndex() + tables.indexOffset;

        final int namespaceURIId = name.nsUriIndex;
        if (namespaceURIId == -1) {
            writeLiteral(EncodingConstants.ATTRIBUTE_LITERAL_QNAME_FLAG,
                    name,
                    "",
                    "");
        } else {
            final int prefix = nsUriIndex2prefixIndex[namespaceURIId];
            writeLiteral(EncodingConstants.ATTRIBUTE_LITERAL_QNAME_FLAG,
                    name,
                    nsContext.getPrefix(prefix),
                    nsContext.getNamespaceURI(prefix));
        }
    }

    fiout.writeLowLevelAttributeValue(value);
}
 
Example #25
Source File: MTOMXmlOutput.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void beginStartTag(Name name) throws IOException, XMLStreamException {
    next.beginStartTag(name);
    this.nsUri = name.nsUri;
    this.localName = name.localName;
}
 
Example #26
Source File: RuntimeBuiltinLeafInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public final void writeLeafElement(XMLSerializer w, Name tagName, String o, String fieldName) throws IOException, SAXException, XMLStreamException {
    w.leafElement(tagName, o, fieldName);
}
 
Example #27
Source File: RuntimeClassInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void writeLeafElement(XMLSerializer w, Name tagName, BeanT o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException {
    if(!xacc.hasValue(o))
        throw new AccessorException(Messages.THERE_MUST_BE_VALUE_IN_XMLVALUE.format(o));
    xacc.writeLeafElement(w,tagName,o,fieldName);
}
 
Example #28
Source File: ForkXmlOutput.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void attribute(Name name, String value) throws IOException, XMLStreamException {
    lhs.attribute(name, value);
    rhs.attribute(name, value);
}
 
Example #29
Source File: MTOMXmlOutput.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void attribute( Name name, String value ) throws IOException, XMLStreamException {
    next.attribute(name, value);
}
 
Example #30
Source File: TransducedAccessor_field_Integer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void writeLeafElement(XMLSerializer w, Name tagName, Object o, String fieldName) throws SAXException, AccessorException, IOException, XMLStreamException {
    w.leafElement(tagName, ((Bean)o).f_int, fieldName );
}