本文整理了Java中com.google.api.client.xml.XmlNamespaceDictionary
类的一些代码示例,展示了XmlNamespaceDictionary
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlNamespaceDictionary
类的具体详情如下:
包路径:com.google.api.client.xml.XmlNamespaceDictionary
类名称:XmlNamespaceDictionary
[英]Beta
Thread-safe XML namespace dictionary that provides a one-to-one map of namespace alias to URI.
Implementation is thread-safe. For maximum efficiency, applications should use a single globally-shared instance of the XML namespace dictionary.
A namespace alias is uniquely mapped to a single namespace URI, and a namespace URI is uniquely mapped to a single namespace alias. In other words, it is not possible to have duplicates.
Sample usage:
static final XmlNamespaceDictionary DICTIONARY = new XmlNamespaceDictionary()
[中]贝塔
线程安全的XML名称空间字典,提供名称空间别名到URI的一对一映射。
实现是线程安全的。为了获得最大效率,应用程序应该使用XML命名空间字典的一个全局共享实例。
命名空间别名唯一映射到单个命名空间URI,命名空间URI唯一映射到单个命名空间别名。换句话说,不可能有重复的。
示例用法:
static final XmlNamespaceDictionary DICTIONARY = new XmlNamespaceDictionary()
代码示例来源:origin: io.minio/minio
/**
* Constructs a new XmlEntity class.
*/
public XmlEntity() throws XmlPullParserException {
super.namespaceDictionary = new XmlNamespaceDictionary();
super.namespaceDictionary.set("s3", "http://s3.amazonaws.com/doc/2006-03-01/");
super.namespaceDictionary.set("", "");
this.xmlPullParser = Xml.createParser();
this.defaultNamespaceDictionary = new XmlNamespaceDictionary();
}
代码示例来源:origin: com.google.http-client/google-http-client-xml
/**
* Shows a debug string representation of an element data object of key/value pairs.
*
* @param element element data object ({@link GenericXml}, {@link Map}, or any object with public
* fields)
* @param elementName XML element local name prefixed by its namespace alias
* @throws IOException I/O exception
*/
public void serialize(XmlSerializer serializer, String elementName, Object element)
throws IOException {
serialize(serializer, elementName, element, true);
}
代码示例来源:origin: com.google.http-client/google-http-client-xml
@Override
public String toString() {
XmlNamespaceDictionary namespaceDictionary = this.namespaceDictionary;
if (namespaceDictionary == null) {
namespaceDictionary = new XmlNamespaceDictionary();
}
return namespaceDictionary.toStringOf(name, this);
}
代码示例来源:origin: io.minio/minio
/**
* Constructs a new notification configuration with default namespace.
*/
public NotificationConfiguration() throws XmlPullParserException {
super();
super.name = "NotificationConfiguration";
super.namespaceDictionary.set("", "http://s3.amazonaws.com/doc/2006-03-01/");
}
代码示例来源:origin: stackoverflow.com
static final XmlNamespaceDictionary DICTIONARY = new XmlNamespaceDictionary()
.set("", "http://www.w3.org/2005/Atom")
.set("activity", "http://activitystrea.ms/spec/1.0/")
.set("georss", "http://www.georss.org/georss")
.set("media", "http://search.yahoo.com/mrss/")
.set("thr", "http://purl.org/syndication/thread/1.0");
代码示例来源:origin: com.google.http-client/google-http-client-xml
String namespace = parser.getNamespaceUri(i);
if (namespaceDictionary.getAliasForUri(namespace) == null) {
String prefix = parser.getNamespacePrefix(i);
String originalAlias = prefix == null ? "" : prefix;
while (namespaceDictionary.getUriForAlias(alias) != null) {
suffix++;
alias = originalAlias + suffix;
namespaceDictionary.set(alias, namespace);
代码示例来源:origin: com.google.http-client/google-http-client-xml
private void serialize(XmlSerializer serializer, String elementNamespaceUri,
String elementLocalName, Object element, boolean errorOnUnknown) throws IOException {
String elementAlias = elementNamespaceUri == null ? null : getAliasForUri(elementNamespaceUri);
startDoc(serializer, element, errorOnUnknown, elementAlias).serialize(
serializer, elementNamespaceUri, elementLocalName);
serializer.endDocument();
}
代码示例来源:origin: com.google.http-client/google-http-client-xml
private ElementSerializer startDoc(
XmlSerializer serializer, Object element, boolean errorOnUnknown, String elementAlias)
throws IOException {
serializer.startDocument(null, null);
SortedSet<String> aliases = new TreeSet<String>();
computeAliases(element, aliases);
if (elementAlias != null) {
aliases.add(elementAlias);
}
for (String alias : aliases) {
String uri = getNamespaceUriForAliasHandlingUnknown(errorOnUnknown, alias);
serializer.setPrefix(alias, uri);
}
return new ElementSerializer(element, errorOnUnknown);
}
代码示例来源:origin: com.google.http-client/google-http-client-xml
/**
* Returns the namespace alias to use for a given namespace URI, throwing an exception if the
* namespace URI can be found in this dictionary.
*
* @param namespaceUri namespace URI
* @throws IllegalArgumentException if the namespace URI is not found in this dictionary
*/
String getNamespaceAliasForUriErrorOnUnknown(String namespaceUri) {
String result = getAliasForUri(namespaceUri);
Preconditions.checkArgument(result != null,
"invalid XML: no alias declared for namesapce <%s>; "
+ "work-around by setting XML namepace directly by calling the set method of %s",
namespaceUri, XmlNamespaceDictionary.class.getName());
return result;
}
代码示例来源:origin: com.google.http-client/google-http-client-xml
private void computeAliases(Object element, SortedSet<String> aliases) {
for (Map.Entry<String, Object> entry : Data.mapOf(element).entrySet()) {
Object value = entry.getValue();
if (value != null) {
String name = entry.getKey();
if (!Xml.TEXT_CONTENT.equals(name)) {
int colon = name.indexOf(':');
boolean isAttribute = name.charAt(0) == '@';
if (colon != -1 || !isAttribute) {
String alias = colon == -1 ? "" : name.substring(name.charAt(0) == '@' ? 1 : 0, colon);
aliases.add(alias);
}
Class<?> valueClass = value.getClass();
if (!isAttribute && !Data.isPrimitive(valueClass) && !valueClass.isEnum() ) {
if (value instanceof Iterable<?> || valueClass.isArray()) {
for (Object subValue : Types.iterableOf(value)) {
computeAliases(subValue, aliases);
}
} else {
computeAliases(value, aliases);
}
}
}
}
}
}
代码示例来源:origin: com.google.http-client/google-http-client-xml
String name = parser.getName();
String namespace = parser.getNamespace();
String alias = namespaceDictionary.getNamespaceAliasForUriErrorOnUnknown(namespace);
genericXml.name = alias.length() == 0 ? name : alias + ":" + name;
String attributeNamespace = parser.getAttributeNamespace(i);
String attributeAlias = attributeNamespace.length() == 0
? "" : namespaceDictionary.getNamespaceAliasForUriErrorOnUnknown(attributeNamespace);
String fieldName = getFieldName(true, attributeAlias, attributeNamespace, attributeName);
Field field = classInfo == null ? null : classInfo.getField(fieldName);
String alias = namespaceDictionary.getNamespaceAliasForUriErrorOnUnknown(namespace);
代码示例来源:origin: io.minio/minio
/**
* Constructs a new CreateBucketConfiguration object with given location constraint.
*/
public CreateBucketConfiguration(String locationConstraint) throws XmlPullParserException {
super();
super.name = "CreateBucketConfiguration";
super.namespaceDictionary.set("", "http://s3.amazonaws.com/doc/2006-03-01/");
this.locationConstraint = locationConstraint;
}
代码示例来源:origin: stackoverflow.com
parent.child.value = "This is a child";
String xml = new XmlNamespaceDictionary()
.toStringOf("Parent", parent.toOrderedXml()); // the important part
代码示例来源:origin: com.google.http-client/google-http-client-xml
/**
* Shows a debug string representation of an element data object of key/value pairs.
*
* <p>
* It will make up something for the element name and XML namespaces. If those are known, it is
* better to use {@link XmlNamespaceDictionary#toStringOf(String, Object)}.
*
* @param element element data object of key/value pairs ({@link GenericXml}, {@link Map}, or any
* object with public fields)
*/
public static String toStringOf(Object element) {
return new XmlNamespaceDictionary().toStringOf(null, element);
}
代码示例来源:origin: minio/minio-java
/**
* Constructs a new XmlEntity class.
*/
public XmlEntity() throws XmlPullParserException {
super.namespaceDictionary = new XmlNamespaceDictionary();
super.namespaceDictionary.set("s3", "http://s3.amazonaws.com/doc/2006-03-01/");
super.namespaceDictionary.set("", "");
this.xmlPullParser = Xml.createParser();
this.defaultNamespaceDictionary = new XmlNamespaceDictionary();
}
代码示例来源:origin: minio/minio-java
/**
* Constructs new delete request for given object list and quiet flag.
*/
public DeleteRequest(List<DeleteObject> objectList, boolean quiet) throws XmlPullParserException {
super();
super.name = "Delete";
super.namespaceDictionary.set("", "http://s3.amazonaws.com/doc/2006-03-01/");
this.objectList = objectList;
this.quiet = quiet;
}
}
代码示例来源:origin: stackoverflow.com
static HttpParser parser = new AtomParser(new XmlNamespaceDictionary());
代码示例来源:origin: com.google.http-client/google-http-client-xml
/**
* Shows a debug string representation of an element data object of key/value pairs.
*
* @param element element data object ({@link GenericXml}, {@link Map}, or any object with public
* fields)
* @param elementNamespaceUri XML namespace URI or {@code null} for no namespace
* @param elementLocalName XML local name
* @throws IOException I/O exception
*/
public void serialize(
XmlSerializer serializer, String elementNamespaceUri, String elementLocalName, Object element)
throws IOException {
serialize(serializer, elementNamespaceUri, elementLocalName, element, true);
}
代码示例来源:origin: minio/minio-java
/**
* Fills up this ErrorResponse object's fields by reading/parsing values from given Reader input stream.
*/
@Override
public void parseXml(Reader reader) throws IOException, XmlPullParserException {
XmlNamespaceDictionary namespaceDictionary = new XmlNamespaceDictionary();
namespaceDictionary.set("", "");
super.parseXml(reader, namespaceDictionary);
}
代码示例来源:origin: minio/minio-java
/**
* Constructs a new CreateBucketConfiguration object with given location constraint.
*/
public CreateBucketConfiguration(String locationConstraint) throws XmlPullParserException {
super();
super.name = "CreateBucketConfiguration";
super.namespaceDictionary.set("", "http://s3.amazonaws.com/doc/2006-03-01/");
this.locationConstraint = locationConstraint;
}
内容来源于网络,如有侵权,请联系作者删除!