本文整理匯總了Java中com.thoughtworks.xstream.io.HierarchicalStreamWriter.endNode方法的典型用法代碼示例。如果您正苦於以下問題:Java HierarchicalStreamWriter.endNode方法的具體用法?Java HierarchicalStreamWriter.endNode怎麽用?Java HierarchicalStreamWriter.endNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.thoughtworks.xstream.io.HierarchicalStreamWriter
的用法示例。
在下文中一共展示了HierarchicalStreamWriter.endNode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: marshal
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
/**
* writes the argument <code>value</code> to the XML file specified through
* <code>writer</code>
*
* @pre <code>value</code> is a valid <code>ConstantNode</code>, <code>
* writer</code> is a valid <code>HierarchicalStreamWriter</code>, and
* <code>context</code> is a valid <code>MarshallingContext</code>
* @post <code>value</code> is written to the XML file specified via
* <code>writer</code>
* @param value <code>ConstantNode</code> that you wish to write to a file
* @param writer stream to write through
* @param context <code>MarshallingContext</code> used to store generic data
*/
@Override
public void marshal(Object value, HierarchicalStreamWriter writer,
MarshallingContext context) {
ExpressionTreeInterface constantNode = (ConstantNode) value;
writer.startNode("name");
writer.setValue(constantNode.getName());
writer.endNode();
writer.startNode("value");
Object myValue = ((ConstantNode) constantNode).getValue();
if (myValue instanceof Double) {
writer.setValue(Double.toString((Double) ((ConstantNode) constantNode).getValue()));
} else if (myValue instanceof Integer) {
writer.setValue(Integer.toString((Integer) ((ConstantNode) constantNode).getValue()));
} else if (myValue instanceof String) {
writer.setValue((String) ((ConstantNode) constantNode).getValue());
} else { // boolean
writer.setValue(Boolean.toString((Boolean) ((ConstantNode) constantNode).getValue()));
}
writer.endNode();
}
示例2: marshalMethod
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
private void marshalMethod(final HierarchicalStreamWriter writer, final String declaringClassName,
final String methodName, final Class<?>[] parameterTypes) {
writer.startNode("class");
writer.setValue(declaringClassName);
writer.endNode();
if (methodName != null) {
// it's a method and not a ctor
writer.startNode("name");
writer.setValue(methodName);
writer.endNode();
}
writer.startNode("parameter-types");
for (final Class<?> parameterType : parameterTypes) {
writer.startNode("class");
writer.setValue(javaClassConverter.toString(parameterType));
writer.endNode();
}
writer.endNode();
}
示例3: marshal
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void marshal(HierarchicalStreamWriter writer, MarshallingContext context, Object object)
{
Collection<?> col = getCollection(object);
if( col != null )
{
Iterator<?> i = col.iterator();
boolean first = true;
while( i.hasNext() )
{
Object value = i.next();
if( value == null )
{
continue;
}
if( !first )
{
writer.endNode();
writer.startNode(endNode);
}
first = false;
converter.marshal(writer, context, value);
}
}
}
示例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();
}
}
}
示例5: 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();
}
示例6: marshal
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
@SuppressWarnings("unchecked")
final List<String> list = (List<String>) source;
for (final String string : list) {
writer.startNode(this.alias);
writer.setValue(string);
writer.endNode();
}
}
示例7: marshal
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
AbstractMap map = (AbstractMap) value;
for (Object obj : map.entrySet()) {
Map.Entry entry = (Map.Entry) obj;
writer.startNode(entry.getKey().toString());
Object val = entry.getValue();
if (null != val) {
writer.setValue(val.toString());
}
writer.endNode();
}
}
示例8: marshal
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
/**
* writes the argument <code>value</code> to the XML file specified through
* <code>writer</code>
*
* @pre <code>value</code> is a valid <code>SquidSpeciesModel</code>, <code>
* writer</code> is a valid <code>HierarchicalStreamWriter</code>, and
* <code>context</code> is a valid <code>MarshallingContext</code>
* @post <code>value</code> is written to the XML file specified via
* <code>writer</code>
* @param value <code>SquidSpeciesModel</code> that you wish to write to a
* file
* @param writer stream to write through
* @param context <code>MarshallingContext</code> used to store generic data
*/
@Override
public void marshal(Object value, HierarchicalStreamWriter writer,
MarshallingContext context) {
SquidSpeciesModel squidSpeciesModel = (SquidSpeciesModel) value;
writer.startNode("massStationIndex");
writer.setValue(String.valueOf(squidSpeciesModel.getMassStationIndex()));
writer.endNode();
writer.startNode("massStationSpeciesName");
writer.setValue(squidSpeciesModel.getMassStationSpeciesName());
writer.endNode();
writer.startNode("isotopeName");
writer.setValue(squidSpeciesModel.getIsotopeName());
writer.endNode();
writer.startNode("elementName");
writer.setValue(squidSpeciesModel.getElementName());
writer.endNode();
writer.startNode("isBackground");
writer.setValue(String.valueOf(squidSpeciesModel.getIsBackground()));
writer.endNode();
}
示例9: marshalPrincipals
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
protected void marshalPrincipals(final Set<Principal> principals, final HierarchicalStreamWriter writer,
final MarshallingContext context) {
writer.startNode("principals");
for (final Principal principal : principals) {
writeItem(principal, context, writer);
}
writer.endNode();
}
示例10: addInterfacesToXml
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
private void addInterfacesToXml(final Object source, final HierarchicalStreamWriter writer) {
final Class<?>[] interfaces = source.getClass().getInterfaces();
for (final Class<?> currentInterface : interfaces) {
writer.startNode("interface");
writer.setValue(mapper.serializedClass(currentInterface));
writer.endNode();
}
}
示例11: 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();
}
}
}
}
示例12: endNode
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
private void endNode(HierarchicalStreamWriter writer, Stack current, String[] nodes)
{
int i = current.size() - 1;
boolean isWithin = nodes.length > 0 && current.size() > 0 && current.get(0).toString().equals(nodes[0]);
for( ; current.size() > 0 && i >= 0; i-- )
{
String node = current.peek().toString();
if( ((isWithin && nodes.length > i && !node.equals(nodes[i])) || !isWithin) )
{
current.pop();
writer.endNode();
}
}
}
示例13: marshalComparator
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
protected void marshalComparator(final Comparator<?> comparator, final HierarchicalStreamWriter writer,
final MarshallingContext context) {
if (comparator != null) {
writer.startNode("comparator");
writer.addAttribute(mapper().aliasForSystemAttribute("class"), mapper().serializedClass(
comparator.getClass()));
context.convertAnother(comparator);
writer.endNode();
}
}
示例14: marshal
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
try {
final Externalizable externalizable = (Externalizable)source;
final CustomObjectOutputStream.StreamCallback callback = new CustomObjectOutputStream.StreamCallback() {
@Override
public void writeToStream(final Object object) {
if (object == null) {
writer.startNode("null");
writer.endNode();
} else {
ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedClass(object
.getClass()), object.getClass());
context.convertAnother(object);
writer.endNode();
}
}
@Override
public void writeFieldsToStream(final Map<String, Object> fields) {
throw new UnsupportedOperationException();
}
@Override
public void defaultWriteObject() {
throw new UnsupportedOperationException();
}
@Override
public void flush() {
writer.flush();
}
@Override
public void close() {
throw new UnsupportedOperationException(
"Objects are not allowed to call ObjectOutput.close() from writeExternal()");
}
};
@SuppressWarnings("resource")
final CustomObjectOutputStream objectOutput = CustomObjectOutputStream.getInstance(context, callback);
externalizable.writeExternal(objectOutput);
objectOutput.popCallback();
} catch (final IOException e) {
throw new ConversionException("Cannot serialize " + source.getClass().getName() + " using Externalization",
e);
}
}
示例15: marshal
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; //導入方法依賴的package包/類
/**
* writes the argument <code>value</code> to the XML file specified through
* <code>writer</code>
*
* @pre <code>value</code> is a valid <code>ExpressionTree</code>, <code>
* writer</code> is a valid <code>HierarchicalStreamWriter</code>, and
* <code>context</code> is a valid <code>MarshallingContext</code>
* @post <code>value</code> is written to the XML file specified via
* <code>writer</code>
* @param value <code>ExpressionTree</code> that you wish to write to a file
* @param writer stream to write through
* @param context <code>MarshallingContext</code> used to store generic data
*/
@Override
public void marshal(Object value, HierarchicalStreamWriter writer,
MarshallingContext context) {
ExpressionTree expressionTree = (ExpressionTree) value;
writer.startNode("name");
writer.setValue(expressionTree.getName());
writer.endNode();
writer.startNode("childrenET");
context.convertAnother(expressionTree.getChildrenET());
writer.endNode();
writer.startNode("operation");
context.convertAnother(expressionTree.getOperation());
writer.endNode();
writer.startNode("ratiosOfInterest");
context.convertAnother(expressionTree.getRatiosOfInterest());
writer.endNode();
writer.startNode("squidSwitchSCSummaryCalculation");
writer.setValue(String.valueOf(expressionTree.isSquidSwitchSCSummaryCalculation()));
writer.endNode();
writer.startNode("squidSwitchSTReferenceMaterialCalculation");
writer.setValue(String.valueOf(expressionTree.isSquidSwitchSTReferenceMaterialCalculation()));
writer.endNode();
writer.startNode("squidSwitchSAUnknownCalculation");
writer.setValue(String.valueOf(expressionTree.isSquidSwitchSAUnknownCalculation()));
writer.endNode();
writer.startNode("squidSpecialUPbThExpression");
writer.setValue(String.valueOf(expressionTree.isSquidSpecialUPbThExpression()));
writer.endNode();
writer.startNode("rootExpressionTree");
writer.setValue(String.valueOf(expressionTree.isRootExpressionTree()));
writer.endNode();
}