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


Java Namespace类代码示例

本文整理汇总了Java中javax.xml.stream.events.Namespace的典型用法代码示例。如果您正苦于以下问题:Java Namespace类的具体用法?Java Namespace怎么用?Java Namespace使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: handleEndElement

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
private void handleEndElement(EndElement event) throws SAXException {
    if(!seenText && predictor.expectText()) {
        visitor.text("");
    }

    // fire endElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = qName.getLocalPart();
    visitor.endElement(tagName);

    // end namespace bindings
    for( Iterator<Namespace> i = event.getNamespaces(); i.hasNext();) {
        String prefix = fixNull(i.next().getPrefix());  // be defensive
        visitor.endPrefixMapping(prefix);
    }

    seenText = false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:StAXEventConnector.java

示例2: handleStartElement

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
private void handleStartElement(StartElement event) throws SAXException {
    // start namespace bindings
    for (Iterator i = event.getNamespaces(); i.hasNext();) {
        Namespace ns = (Namespace)i.next();
        visitor.startPrefixMapping(
            fixNull(ns.getPrefix()),
            fixNull(ns.getNamespaceURI()));
    }

    // fire startElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    String localName = qName.getLocalPart();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = localName;
    tagName.atts = getAttributes(event);
    visitor.startElement(tagName);

    seenText = false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:StAXEventConnector.java

示例3: handleStartElement

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
private void handleStartElement(StartElement startElement) throws SAXException {
	if (getContentHandler() != null) {
		QName qName = startElement.getName();
		if (hasNamespacesFeature()) {
			for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
				Namespace namespace = (Namespace) i.next();
				startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
			}
			for (Iterator i = startElement.getAttributes(); i.hasNext();){
				Attribute attribute = (Attribute) i.next();
				QName attributeName = attribute.getName();
				startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
			}

			getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
					getAttributes(startElement));
		}
		else {
			getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:StaxEventXMLReader.java

示例4: handleEndElement

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
private void handleEndElement(EndElement endElement) throws SAXException {
	if (getContentHandler() != null) {
		QName qName = endElement.getName();
		if (hasNamespacesFeature()) {
			getContentHandler().endElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName));
			for (Iterator i = endElement.getNamespaces(); i.hasNext();) {
				Namespace namespace = (Namespace) i.next();
				endPrefixMapping(namespace.getPrefix());
			}
		}
		else {
			getContentHandler().endElement("", "", toQualifiedName(qName));
		}

	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:StaxEventXMLReader.java

示例5: getNamespace

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private Namespace getNamespace(int index) {
	Iterator namespaces;
	if (this.event.isStartElement()) {
		namespaces = this.event.asStartElement().getNamespaces();
	}
	else if (this.event.isEndElement()) {
		namespaces = this.event.asEndElement().getNamespaces();
	}
	else {
		throw new IllegalStateException();
	}
	int count = 0;
	while (namespaces.hasNext()) {
		Namespace namespace = (Namespace) namespaces.next();
		if (count == index) {
			return namespace;
		}
		else {
			count++;
		}
	}
	throw new IllegalArgumentException();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:XMLEventStreamReader.java

示例6: getNamespaceCount

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public int getNamespaceCount() {
    XMLSecEvent xmlSecEvent = getCurrentEvent();
    switch (xmlSecEvent.getEventType()) {
        case START_ELEMENT:
            return xmlSecEvent.asStartElement().getOnElementDeclaredNamespaces().size();
        case END_ELEMENT:
            int count = 0;
            Iterator<Namespace> namespaceIterator = xmlSecEvent.asEndElement().getNamespaces();
            while (namespaceIterator.hasNext()) {
                namespaceIterator.next();
                count++;
            }
            return count;
        default:
            throw new IllegalStateException(ERR_STATE_NOT_ELEM);
    }
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:20,代码来源:XMLSecurityStreamReader.java

示例7: getNamespacePrefix

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public String getNamespacePrefix(int index) {
    XMLSecEvent xmlSecEvent = getCurrentEvent();
    switch (xmlSecEvent.getEventType()) {
        case START_ELEMENT:
            return xmlSecEvent.asStartElement().getOnElementDeclaredNamespaces().get(index).getPrefix();
        case END_ELEMENT:
            int count = 0;
            Iterator<Namespace> namespaceIterator = xmlSecEvent.asEndElement().getNamespaces();
            while (namespaceIterator.hasNext()) {
                Namespace namespace = namespaceIterator.next();
                if (count == index) {
                    return namespace.getPrefix();
                }
                count++;
            }
            throw new ArrayIndexOutOfBoundsException(index);
        default:
            throw new IllegalStateException(ERR_STATE_NOT_ELEM);
    }
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:23,代码来源:XMLSecurityStreamReader.java

示例8: getNamespace

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
private Namespace getNamespace(int index) {
	Iterator namespaces;
	if (event.isStartElement()) {
		namespaces = event.asStartElement().getNamespaces();
	}
	else if (event.isEndElement()) {
		namespaces = event.asEndElement().getNamespaces();
	}
	else {
		throw new IllegalStateException();
	}
	int count = 0;
	while (namespaces.hasNext()) {
		Namespace namespace = (Namespace) namespaces.next();
		if (count == index) {
			return namespace;
		}
		else {
			count++;
		}
	}
	throw new IllegalArgumentException();
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:24,代码来源:XMLEventStreamReader.java

示例9: startElement

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void startElement(XmlParserContext ctx, StartElement element) throws BagriException {
	ctx.appendCharacters();
	
	ctx.addData(element.getName().toString()); // getLocalPart());
	ctx.addElement(); 

	for (Iterator<Namespace> itr = element.getNamespaces(); itr.hasNext();) {
		Namespace ns = itr.next();
		// TODO: process default namespace properly
		String namespace = ns.getValue();
		if (namespace != null) {
			String prefix = ns.getName().getLocalPart();
			ctx.addNamespace(prefix, namespace);
		}
	}

	for (Iterator<Attribute> itr = element.getAttributes(); itr.hasNext();) {
		Attribute a = itr.next();
		//if (!a.getName().getPrefix().isEmpty()) {
		//	String prefix = model.translateNamespace(a.getName().getNamespaceURI(), a.getName().getPrefix());
		//	ctx.addNamespace(prefix, a.getName().getNamespaceURI());
		//}
		ctx.addAttribute(a.getName(), a.getValue()); 
	}
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:27,代码来源:XmlStaxParser.java

示例10: createNamespaces

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
/**
 * Create and return a list of {@code NameSpace} objects from the {@code NamespaceContext}.
 */
private List<Namespace> createNamespaces(SimpleNamespaceContext namespaceContext) {
    if (namespaceContext == null) {
        return null;
    }

    List<Namespace> namespaces = new ArrayList<Namespace>();
    String defaultNamespaceUri = namespaceContext.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
    if (StringUtils.hasLength(defaultNamespaceUri)) {
        namespaces.add(this.eventFactory.createNamespace(defaultNamespaceUri));
    }
    for (Iterator<String> iterator = namespaceContext.getBoundPrefixes(); iterator.hasNext(); ) {
        String prefix = iterator.next();
        String namespaceUri = namespaceContext.getNamespaceURI(prefix);
        namespaces.add(this.eventFactory.createNamespace(prefix, namespaceUri));
    }
    return namespaces;
}
 
开发者ID:blademainer,项目名称:common_utils,代码行数:21,代码来源:StaxEventContentHandler.java

示例11: createNamespaces

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
/**
 * Create and return a list of {@code NameSpace} objects from the {@code NamespaceContext}.
 */
private List<Namespace> createNamespaces(SimpleNamespaceContext namespaceContext) {
	if (namespaceContext == null) {
		return null;
	}

	List<Namespace> namespaces = new ArrayList<Namespace>();
	String defaultNamespaceUri = namespaceContext.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
	if (StringUtils.hasLength(defaultNamespaceUri)) {
		namespaces.add(this.eventFactory.createNamespace(defaultNamespaceUri));
	}
	for (Iterator iterator = namespaceContext.getBoundPrefixes(); iterator.hasNext();) {
		String prefix = (String) iterator.next();
		String namespaceUri = namespaceContext.getNamespaceURI(prefix);
		namespaces.add(this.eventFactory.createNamespace(prefix, namespaceUri));
	}
	return namespaces;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:StaxEventContentHandler.java

示例12: getNamespaces

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
@Override
public Iterator<Namespace> getNamespaces()
{
    if (mNsList == null) {
        int firstLocal = mFirstLocalNs;
        int len = mNsLength - firstLocal;
        if (len == 0) { // can this happen?
            return DataUtil.emptyIterator();
        }
        if (len == 2) { // only one NS
            return DataUtil.<Namespace>singletonIterator(NamespaceEventImpl.constructNamespace
                    (mLocation,
                            mNamespaces[firstLocal],
                            mNamespaces[firstLocal+1]));
        }
        ArrayList<Namespace> l = new ArrayList<Namespace>(len >> 1);
        String[] ns = mNamespaces;
        for (len = mNsLength; firstLocal < len;
             firstLocal += 2) {
            l.add(NamespaceEventImpl.constructNamespace(mLocation, ns[firstLocal],
                                          ns[firstLocal+1]));
        }
        mNsList = l;
    }
    return mNsList.iterator();
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:27,代码来源:CompactNsContext.java

示例13: outputNamespaceDeclarations

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
@Override
public void outputNamespaceDeclarations(Writer w) throws IOException
{
    for (int i = 0, len = mNamespaces.size(); i < len; ++i) {
        Namespace ns = mNamespaces.get(i);
        w.write(' ');
        w.write(XMLConstants.XMLNS_ATTRIBUTE);
        if (!ns.isDefaultNamespaceDeclaration()) {
            w.write(':');
            w.write(ns.getPrefix());
        }
        w.write("=\"");
        w.write(ns.getNamespaceURI());
        w.write('"');
    }
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:17,代码来源:MergedNsContext.java

示例14: buildByPrefixMap

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
private Map<String,Namespace> buildByPrefixMap()
{
    int len = mNamespaces.size();
    if (len == 0) {
        return Collections.emptyMap();
    }

    LinkedHashMap<String,Namespace> m = new LinkedHashMap<String,Namespace>(1 + len + (len>>1));
    for (int i = 0; i < len; ++i) {
        Namespace ns = mNamespaces.get(i);
        String prefix = ns.getPrefix();
        if (prefix == null) { // shouldn't happen but...
            prefix = "";
        }
        m.put(prefix, ns);
    }
    return m;
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:19,代码来源:MergedNsContext.java

示例15: buildByNsURIMap

import javax.xml.stream.events.Namespace; //导入依赖的package包/类
private Map<String,Namespace> buildByNsURIMap()
{
    int len = mNamespaces.size();
    if (len == 0) {
        return Collections.emptyMap();
    }

    LinkedHashMap<String,Namespace> m = new LinkedHashMap<String,Namespace>(1 + len + (len>>1));
    for (int i = 0; i < len; ++i) {
        Namespace ns = mNamespaces.get(i);
        String uri = ns.getNamespaceURI();
        if (uri == null) { // shouldn't happen but...
            uri = "";
        }
        m.put(uri, ns);
    }
    return m;
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:19,代码来源:MergedNsContext.java


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