本文整理汇总了Java中com.sun.org.apache.xerces.internal.xni.QName.setValues方法的典型用法代码示例。如果您正苦于以下问题:Java QName.setValues方法的具体用法?Java QName.setValues怎么用?Java QName.setValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xerces.internal.xni.QName
的用法示例。
在下文中一共展示了QName.setValues方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillQName
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
/** Fills in a QName object. */
private void fillQName(QName toFill, String uri, String localpart, String raw) {
if (!fStringsInternalized) {
uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
localpart = (localpart != null) ? fSymbolTable.addSymbol(localpart) : XMLSymbols.EMPTY_STRING;
raw = (raw != null) ? fSymbolTable.addSymbol(raw) : XMLSymbols.EMPTY_STRING;
}
else {
if (uri != null && uri.length() == 0) {
uri = null;
}
if (localpart == null) {
localpart = XMLSymbols.EMPTY_STRING;
}
if (raw == null) {
raw = XMLSymbols.EMPTY_STRING;
}
}
String prefix = XMLSymbols.EMPTY_STRING;
int prefixIdx = raw.indexOf(':');
if (prefixIdx != -1) {
prefix = fSymbolTable.addSymbol(raw.substring(0, prefixIdx));
}
toFill.setValues(prefix, localpart, raw, uri);
}
示例2: setDefaultNamespace
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
/**
* Set the specified URI as default namespace in the current namespace context.
*
* @param uri Namespace URI
*/
public void setDefaultNamespace(String uri) throws XMLStreamException {
if (uri != null) {
uri = fSymbolTable.addSymbol(uri);
}
if (fIsRepairingNamespace) {
if (isDefaultNamespace(uri)) {
return;
}
QName qname = new QName();
qname.setValues(DEFAULT_PREFIX, "xmlns", null, uri);
fNamespaceDecls.add(qname);
} else {
fInternalNamespaceContext.declarePrefix(DEFAULT_PREFIX, uri);
}
}
示例3: setDefaultNamespace
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
/**
* Set the specified URI as default namespace in the current namespace context.
*
* @param uri Namespace URI
*/
@Override
public void setDefaultNamespace(String uri) throws XMLStreamException {
if (uri != null) {
uri = fSymbolTable.addSymbol(uri);
}
if (fIsRepairingNamespace) {
if (isDefaultNamespace(uri)) {
return;
}
QName qname = new QName();
qname.setValues(DEFAULT_PREFIX, "xmlns", null, uri);
fNamespaceDecls.add(qname);
} else {
fInternalNamespaceContext.declarePrefix(DEFAULT_PREFIX, uri);
}
}
示例4: fillQName
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
/** Fills in a QName object. */
final void fillQName(QName toFill, String uri, String localpart, String prefix) {
uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
localpart = (localpart != null) ? fSymbolTable.addSymbol(localpart) : XMLSymbols.EMPTY_STRING;
prefix = (prefix != null && prefix.length() > 0) ? fSymbolTable.addSymbol(prefix) : XMLSymbols.EMPTY_STRING;
String raw = localpart;
if (prefix != XMLSymbols.EMPTY_STRING) {
fStringBuffer.clear();
fStringBuffer.append(prefix);
fStringBuffer.append(':');
fStringBuffer.append(localpart);
raw = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
}
toFill.setValues(prefix, localpart, raw, uri);
}
示例5: fillQName
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
private void fillQName(QName toFill, String uri, String localpart, String rawname) {
if (!fStringsInternalized) {
uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
localpart = (localpart != null) ? fSymbolTable.addSymbol(localpart) : XMLSymbols.EMPTY_STRING;
rawname = (rawname != null) ? fSymbolTable.addSymbol(rawname) : XMLSymbols.EMPTY_STRING;
}
else {
if (uri != null && uri.length() == 0) {
uri = null;
}
if (localpart == null) {
localpart = XMLSymbols.EMPTY_STRING;
}
if (rawname == null) {
rawname = XMLSymbols.EMPTY_STRING;
}
}
String prefix = XMLSymbols.EMPTY_STRING;
int prefixIdx = rawname.indexOf(':');
if (prefixIdx != -1) {
prefix = fSymbolTable.addSymbol(rawname.substring(0, prefixIdx));
// local part may be an empty string if this is a namespace declaration
if (localpart == XMLSymbols.EMPTY_STRING) {
localpart = fSymbolTable.addSymbol(rawname.substring(prefixIdx + 1));
}
}
// local part may be an empty string if this is a namespace declaration
else if (localpart == XMLSymbols.EMPTY_STRING) {
localpart = rawname;
}
toFill.setValues(prefix, localpart, rawname, uri);
}
示例6: setPrefix
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
/**
* Sets the prefix the uri is bound to. This prefix is bound in the scope of
* the current START_ELEMENT / END_ELEMENT pair. If this method is called before
* a START_ELEMENT has been written the prefix is bound in the root scope.
*
* @param prefix
* @param uri
* @throws XMLStreamException
*/
public void setPrefix(String prefix, String uri) throws XMLStreamException {
if (prefix == null) {
throw new XMLStreamException("Prefix cannot be null");
}
if (uri == null) {
throw new XMLStreamException("URI cannot be null");
}
prefix = fSymbolTable.addSymbol(prefix);
uri = fSymbolTable.addSymbol(uri);
if (fIsRepairingNamespace) {
String tmpURI = fInternalNamespaceContext.getURI(prefix);
if ((tmpURI != null) && (tmpURI == uri)) {
return;
}
if(checkUserNamespaceContext(prefix,uri))
return;
QName qname = new QName();
qname.setValues(prefix,XMLConstants.XMLNS_ATTRIBUTE, null,uri);
fNamespaceDecls.add(qname);
return;
}
fInternalNamespaceContext.declarePrefix(prefix, uri);
}
示例7: setPrefix
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
/**
* Sets the prefix the uri is bound to. This prefix is bound in the scope of
* the current START_ELEMENT / END_ELEMENT pair. If this method is called before
* a START_ELEMENT has been written the prefix is bound in the root scope.
*
* @param prefix
* @param uri
* @throws XMLStreamException
*/
@Override
public void setPrefix(String prefix, String uri) throws XMLStreamException {
if (prefix == null) {
throw new XMLStreamException("Prefix cannot be null");
}
if (uri == null) {
throw new XMLStreamException("URI cannot be null");
}
prefix = fSymbolTable.addSymbol(prefix);
uri = fSymbolTable.addSymbol(uri);
if (fIsRepairingNamespace) {
String tmpURI = fInternalNamespaceContext.getURI(prefix);
if ((tmpURI != null) && (tmpURI == uri)) {
return;
}
if(checkUserNamespaceContext(prefix,uri))
return;
QName qname = new QName();
qname.setValues(prefix,XMLConstants.XMLNS_ATTRIBUTE, null,uri);
fNamespaceDecls.add(qname);
return;
}
fInternalNamespaceContext.declarePrefix(prefix, uri);
}
示例8: writeDefaultNamespace
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
public void writeDefaultNamespace(String namespaceURI)
throws XMLStreamException {
// normalize namespaceURI
String namespaceURINormalized = null;
if (namespaceURI == null) {
namespaceURINormalized = ""; // XMLConstants.NULL_NS_URI
} else {
namespaceURINormalized = namespaceURI;
}
try {
if (!fStartTagOpened) {
throw new IllegalStateException(
"Namespace Attribute not associated with any element");
}
if (fIsRepairingNamespace) {
QName qname = new QName();
qname.setValues(XMLConstants.DEFAULT_NS_PREFIX,
XMLConstants.XMLNS_ATTRIBUTE, null, namespaceURINormalized);
fNamespaceDecls.add(qname);
return;
}
namespaceURINormalized = fSymbolTable.addSymbol(namespaceURINormalized);
if (fInternalNamespaceContext.containsPrefixInCurrentContext("")){
String tmp = fInternalNamespaceContext.getURI("");
if (tmp != null && tmp != namespaceURINormalized) {
throw new XMLStreamException(
"xmlns has been already bound to " +tmp +
". Rebinding it to "+ namespaceURINormalized +
" is an error");
}
}
fInternalNamespaceContext.declarePrefix("", namespaceURINormalized);
// use common namespace code with a prefix == null for xmlns="..."
writenamespace(null, namespaceURINormalized);
} catch (IOException e) {
throw new XMLStreamException(e);
}
}
示例9: writeStartElement
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
/**
* @param prefix
* @param localName
* @param namespaceURI
* @throws XMLStreamException
*/
public void writeStartElement(String prefix, String localName,
String namespaceURI) throws XMLStreamException {
try {
if (localName == null) {
throw new XMLStreamException("Local Name cannot be null");
}
if (namespaceURI == null) {
throw new XMLStreamException("NamespaceURI cannot be null");
}
if (!fIsRepairingNamespace) {
if (prefix == null) {
throw new XMLStreamException("Prefix cannot be null");
}
}
if (fStartTagOpened) {
closeStartTag();
}
openStartTag();
namespaceURI = fSymbolTable.addSymbol(namespaceURI);
if (prefix != null) {
prefix = fSymbolTable.addSymbol(prefix);
}
fElementStack.push(prefix, localName, null, namespaceURI, false);
fInternalNamespaceContext.pushContext();
String tmpPrefix = fNamespaceContext.getPrefix(namespaceURI);
if ((prefix != null) &&
((tmpPrefix == null) || !prefix.equals(tmpPrefix))) {
fInternalNamespaceContext.declarePrefix(prefix, namespaceURI);
}
if (fIsRepairingNamespace) {
if ((prefix == null) ||
((tmpPrefix != null) && prefix.equals(tmpPrefix))) {
return;
}
QName qname = new QName();
qname.setValues(prefix, XMLConstants.XMLNS_ATTRIBUTE, null,
namespaceURI);
fNamespaceDecls.add(qname);
return;
}
if ((prefix != null) && (prefix != XMLConstants.DEFAULT_NS_PREFIX)) {
fWriter.write(prefix);
fWriter.write(":");
}
fWriter.write(localName);
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
示例10: writeDefaultNamespace
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
@Override
public void writeDefaultNamespace(String namespaceURI)
throws XMLStreamException {
// normalize namespaceURI
String namespaceURINormalized;
if (namespaceURI == null) {
namespaceURINormalized = ""; // XMLConstants.NULL_NS_URI
} else {
namespaceURINormalized = namespaceURI;
}
try {
if (!fStartTagOpened) {
throw new IllegalStateException(
"Namespace Attribute not associated with any element");
}
if (fIsRepairingNamespace) {
QName qname = new QName();
qname.setValues(XMLConstants.DEFAULT_NS_PREFIX,
XMLConstants.XMLNS_ATTRIBUTE, null, namespaceURINormalized);
fNamespaceDecls.add(qname);
return;
}
namespaceURINormalized = fSymbolTable.addSymbol(namespaceURINormalized);
if (fInternalNamespaceContext.containsPrefixInCurrentContext("")){
String tmp = fInternalNamespaceContext.getURI("");
if (tmp != null && !tmp.equals(namespaceURINormalized)) {
throw new XMLStreamException(
"xmlns has been already bound to " +tmp +
". Rebinding it to "+ namespaceURINormalized +
" is an error");
}
}
fInternalNamespaceContext.declarePrefix("", namespaceURINormalized);
// use common namespace code with a prefix == null for xmlns="..."
writenamespace(null, namespaceURINormalized);
} catch (IOException e) {
throw new XMLStreamException(e);
}
}
示例11: writeStartElement
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
/**
* @param prefix
* @param localName
* @param namespaceURI
* @throws XMLStreamException
*/
@Override
public void writeStartElement(String prefix, String localName,
String namespaceURI) throws XMLStreamException {
try {
if (localName == null) {
throw new XMLStreamException("Local Name cannot be null");
}
if (namespaceURI == null) {
throw new XMLStreamException("NamespaceURI cannot be null");
}
if (!fIsRepairingNamespace) {
if (prefix == null) {
throw new XMLStreamException("Prefix cannot be null");
}
}
if (fStartTagOpened) {
closeStartTag();
}
openStartTag();
namespaceURI = fSymbolTable.addSymbol(namespaceURI);
if (prefix != null) {
prefix = fSymbolTable.addSymbol(prefix);
}
fElementStack.push(prefix, localName, null, namespaceURI, false);
fInternalNamespaceContext.pushContext();
String tmpPrefix = fNamespaceContext.getPrefix(namespaceURI);
if ((prefix != null) &&
((tmpPrefix == null) || !prefix.equals(tmpPrefix))) {
fInternalNamespaceContext.declarePrefix(prefix, namespaceURI);
}
if (fIsRepairingNamespace) {
if ((prefix == null) ||
((tmpPrefix != null) && prefix.equals(tmpPrefix))) {
return;
}
QName qname = new QName();
qname.setValues(prefix, XMLConstants.XMLNS_ATTRIBUTE, null,
namespaceURI);
fNamespaceDecls.add(qname);
return;
}
if ((prefix != null) && (prefix != XMLConstants.DEFAULT_NS_PREFIX)) {
fWriter.write(prefix);
fWriter.write(":");
}
fWriter.write(localName);
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
示例12: correctPrefix
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
/**
*
* @param uri
* @return
*/
private void correctPrefix(QName attr, int type) {
String tmpPrefix;
String prefix;
String uri;
prefix = attr.prefix;
uri = attr.uri;
boolean isSpecialCaseURI = false;
if (prefix == null || prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
if (uri == null) {
return;
}
if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix) && uri.equals(XMLConstants.DEFAULT_NS_PREFIX))
return;
uri = fSymbolTable.addSymbol(uri);
QName decl;
for (int i = 0; i < fNamespaceDecls.size(); i++) {
decl = fNamespaceDecls.get(i);
if ((decl != null) && (decl.uri.equals(attr.uri))) {
attr.prefix = decl.prefix;
return;
}
}
tmpPrefix = fNamespaceContext.getPrefix(uri);
if (XMLConstants.DEFAULT_NS_PREFIX.equals(tmpPrefix)) {
if (type == XMLStreamConstants.START_ELEMENT) {
return;
}
else if (type == XMLStreamConstants.ATTRIBUTE) {
//the uri happens to be the same as that of the default namespace
tmpPrefix = getAttrPrefix(uri);
isSpecialCaseURI = true;
}
}
if (tmpPrefix == null) {
StringBuilder genPrefix = new StringBuilder("zdef");
for (int i = 0; i < 1; i++) {
genPrefix.append(fPrefixGen.nextInt());
}
prefix = genPrefix.toString();
prefix = fSymbolTable.addSymbol(prefix);
} else {
prefix = fSymbolTable.addSymbol(tmpPrefix);
}
if (tmpPrefix == null) {
if (isSpecialCaseURI) {
addAttrNamespace(prefix, uri);
} else {
QName qname = new QName();
qname.setValues(prefix, XMLConstants.XMLNS_ATTRIBUTE, null, uri);
fNamespaceDecls.add(qname);
fInternalNamespaceContext.declarePrefix(fSymbolTable.addSymbol(
prefix), uri);
}
}
}
attr.prefix = prefix;
}
示例13: getName
import com.sun.org.apache.xerces.internal.xni.QName; //导入方法依赖的package包/类
/**
* Sets the fields in the given QName structure with the values
* of the attribute name at the specified index.
*
* @param attrIndex The attribute index.
* @param attrName The attribute name structure to fill in.
*/
public void getName(int attrIndex, QName attrName) {
attrName.setValues(fAttributes[attrIndex].name);
}