當前位置: 首頁>>代碼示例>>Java>>正文


Java HierarchicalStreamWriter.addAttribute方法代碼示例

本文整理匯總了Java中com.thoughtworks.xstream.io.HierarchicalStreamWriter.addAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java HierarchicalStreamWriter.addAttribute方法的具體用法?Java HierarchicalStreamWriter.addAttribute怎麽用?Java HierarchicalStreamWriter.addAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.thoughtworks.xstream.io.HierarchicalStreamWriter的用法示例。


在下文中一共展示了HierarchicalStreamWriter.addAttribute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: copy

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
public void copy(HierarchicalStreamReader source, HierarchicalStreamWriter destination) {
    destination.startNode(source.getNodeName());
    int attributeCount = source.getAttributeCount();
    for (int i = 0; i < attributeCount; i++) {
        destination.addAttribute(source.getAttributeName(i), source.getAttribute(i));
    }
    String value = source.getValue();
    if (value != null && value.length() > 0) {
        destination.setValue(value);
    }
    while (source.hasMoreChildren()) {
        source.moveDown();
        copy(source, destination);
        source.moveUp();
    }
    destination.endNode();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:HierarchicalStreamCopier.java

示例2: marshal

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void marshal(Object arg0, HierarchicalStreamWriter writer, MarshallingContext arg2)
{
	writer.addAttribute("xmlns:oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/");
	writer.addAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
	writer.addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
	writer.addAttribute("xsi:schemaLocation",
		"http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd");

	DublinCore metadata = (DublinCore) arg0;

	startNode(writer, "dc:title", metadata.getTitle());
	startNode(writer, "dc:creator", metadata.getCreator());
	startNode(writer, "dc:creator", metadata.getTitle());
	startNode(writer, "dc:date", metadata.getDate());
	startNode(writer, "dc:description", metadata.getDescription());
	startNode(writer, "dc:identifier", metadata.getIdentifier());
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:OAIDublinCoreConverter.java

示例3: marshal

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext arg2)
{
	Request rep = (Request) object;
	Map map = rep.getAttributes();
	Iterator i = map.keySet().iterator();
	while( i.hasNext() )
	{
		String key = i.next().toString();
		String[] value = (String[]) map.get(key);
		for( int j = 0; j < value.length; j++ )
		{
			writer.addAttribute(key, value[j]);
		}
	}

	writer.setValue(rep.getNode());
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:OAIRequestConverter.java

示例4: marshal

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
    final Properties properties = (Properties)source;
    final Map<Object, Object> map = sort ? new TreeMap<Object, Object>(properties) : properties;
    for (final Map.Entry<Object, Object> entry : map.entrySet()) {
        writer.startNode("property");
        writer.addAttribute("name", entry.getKey().toString());
        writer.addAttribute("value", entry.getValue().toString());
        writer.endNode();
    }
    if (defaultsField != null) {
        final Properties defaults = (Properties)Fields.read(defaultsField, properties);
        if (defaults != null) {
            writer.startNode("defaults");
            marshal(defaults, writer, context);
            writer.endNode();
        }
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:20,代碼來源:PropertiesConverter.java

示例5: marshal

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
    final int length = Array.getLength(source);
    for (int i = 0; i < length; ++i) {
        final Object item = Array.get(source, i);
        final Class<?> itemType = item == null ? Mapper.Null.class : arrayType.getComponentType().isPrimitive()
            ? Primitives.unbox(item.getClass())
            : item.getClass();
        ExtendedHierarchicalStreamWriterHelper.startNode(writer, itemName, itemType);
        if (!itemType.equals(arrayType.getComponentType())) {
            final String attributeName = mapper.aliasForSystemAttribute("class");
            if (attributeName != null) {
                writer.addAttribute(attributeName, mapper.serializedClass(itemType));
            }
        }
        if (item != null) {
            context.convertAnother(item);
        }
        writer.endNode();
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:NamedArrayConverter.java

示例6: writeClass

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void writeClass(HierarchicalStreamWriter writer, Object object)
{
	if( object.getClass() != clazz )
	{
		writer.addAttribute(XCLASS, object.getClass().getName());
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:9,代碼來源:DataMapping.java

示例7: marshallElement

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
private void marshallElement(HierarchicalStreamWriter writer, Element element) {
	writer.startNode(element.getName());
	for (Attribute attribute: (List<Attribute>)element.attributes())
		writer.addAttribute(attribute.getName(), attribute.getValue());
	if (element.getText().trim().length() != 0)
		writer.setValue(element.getText().trim());
	for (Element child: (List<Element>)element.elements())
		marshallElement(writer, child);
	writer.endNode();
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:11,代碼來源:JpaConverter.java

示例8: rmarshalNode

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
private void rmarshalNode(HierarchicalStreamWriter writer, MarshallingContext context, Node node)
{
	NamedNodeMap map = node.getAttributes();
	int count;
	if( map != null )
	{
		count = map.getLength();
		for( int i = 0; i < count; i++ )
		{
			Node attribute = map.item(i);
			writer.addAttribute(attribute.getNodeName(), attribute.getNodeValue());
		}
	}
	NodeList list = node.getChildNodes();
	if( list != null )
	{
		count = list.getLength();
		for( int i = 0; i < count; i++ )
		{
			Node child = list.item(i);
			if( child.getNodeType() == Node.TEXT_NODE )
			{
				String value = child.getNodeValue();
				if( value != null && value.length() > 0 )
				{
					writer.setValue(value);
				}
			}
			else
			{
				writer.startNode(child.getNodeName());
				rmarshalNode(writer, context, child);
				writer.endNode();
			}
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:38,代碼來源:ElementMapping.java

示例9: writeClass

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void writeClass(HierarchicalStreamWriter writer, Object object)
{
	Class<?> clazz = object.getClass();
	if( !clazz.equals(defaultClass) )
	{
		String name = mapping.inverse().get(clazz);
		if( name != null )
		{
			writer.addAttribute(attribute, name);
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:14,代碼來源:XMLDataResolverMapping.java

示例10: setValue

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
public void setValue(HierarchicalStreamWriter writer, String string)
{
	if( attributeName != null )
	{
		writer.addAttribute(attributeName, string);
	}
	else
	{
		writer.setValue(string);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:12,代碼來源:XMLPath.java

示例11: marshal

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
    final InvocationHandler invocationHandler = Proxy.getInvocationHandler(source);
    addInterfacesToXml(source, writer);
    writer.startNode("handler");
    final String attributeName = mapper.aliasForSystemAttribute("class");
    if (attributeName != null) {
        writer.addAttribute(attributeName, mapper.serializedClass(invocationHandler.getClass()));
    }
    context.convertAnother(invocationHandler);
    writer.endNode();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:DynamicProxyConverter.java

示例12: marshal

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context)
{
	BaseEntity entity = (BaseEntity) obj;
	writer.addAttribute("entityclass", obj.getClass().getName()); //$NON-NLS-1$
	String uuid = entity.getUuid();
	writer.addAttribute("uuid", uuid); //$NON-NLS-1$
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:9,代碼來源:BaseEntityXmlConverter.java

示例13: writeItem

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
protected void writeItem(final String name, final Class<?> type, final Object item,
        final MarshallingContext context, final HierarchicalStreamWriter writer) {
    final Class<?> itemType = item == null ? Mapper.Null.class : item.getClass();
    ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, itemType);
    if (!itemType.equals(type)) {
        final String attributeName = mapper().aliasForSystemAttribute("class");
        if (attributeName != null) {
            writer.addAttribute(attributeName, mapper().serializedClass(itemType));
        }
    }
    if (item != null) {
        context.convertAnother(item);
    }
    writer.endNode();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:16,代碼來源:NamedMapConverter.java

示例14: addAttribute

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
protected void addAttribute(HierarchicalStreamWriter writer, String name, String value)
{
	if( value != null && value.length() > 0 )
	{
		writer.addAttribute(name, value);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:8,代碼來源:OAIAbstractConverter.java

示例15: marshal

import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext arg2)
{
	ResumptionToken token = (ResumptionToken) object;
	writer.addAttribute(COMPLETELISTSIZE, "" + token.getCompleteListSize());
	writer.addAttribute(CURSOR, "" + token.getCursor());
	writer.setValue(token.getToken());
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:9,代碼來源:OAIResumptionTokenConverter.java


注:本文中的com.thoughtworks.xstream.io.HierarchicalStreamWriter.addAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。