當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。