本文整理汇总了Java中com.thoughtworks.xstream.io.HierarchicalStreamReader.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java HierarchicalStreamReader.getAttribute方法的具体用法?Java HierarchicalStreamReader.getAttribute怎么用?Java HierarchicalStreamReader.getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thoughtworks.xstream.io.HierarchicalStreamReader
的用法示例。
在下文中一共展示了HierarchicalStreamReader.getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveClass
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
@Override
public Class resolveClass(HierarchicalStreamReader reader)
{
String xclass = reader.getAttribute(XCLASS);
Class clazz2use = null;
if( xclass != null )
{
try
{
clazz2use = Class.forName(xclass, false, Thread.currentThread().getContextClassLoader());
}
catch( ClassNotFoundException e )
{
throw new RuntimeException(e);
}
}
return clazz2use;
}
示例2: unmarshal
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
@Override
@SuppressWarnings({"unchecked", "nls"})
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
String classFromStream = reader.getAttribute("entityclass"); //$NON-NLS-1$
String uuidFromStream = reader.getAttribute("uuid"); //$NON-NLS-1$
try
{
AbstractEntityService<?, ? extends BaseEntity> service = registry
.getServiceForClass((Class<? extends BaseEntity>) Class.forName(classFromStream));
if( service == null )
{
throw new RuntimeException("Could not find service for class '" + classFromStream
+ "' in entity registry!");
}
return service.getByUuid(uuidFromStream);
}
catch( ClassNotFoundException e )
{
throw new RuntimeException(e);
}
}
示例3: unmarshal
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
@Override
public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingContext context)
{
final WorkflowNodeSupplier supplier = (WorkflowNodeSupplier) context.get(WorkflowNodeSupplier.class);
final String workflowUuid = reader.getAttribute(ATTR_WORKFLOW);
final String nodeUuid = reader.getValue();
long id = supplier.getIdForNode(workflowUuid, nodeUuid);
final WorkflowItem node = new WorkflowItem();
if( id != 0 )
{
node.setId(id);
}
else
{
node.setUuid(nodeUuid);
context.addCompletionCallback(new Runnable()
{
@Override
public void run()
{
node.setId(supplier.getIdForNode(workflowUuid, nodeUuid));
}
}, 1);
}
return node;
}
示例4: parseSubTree2
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
private Element parseSubTree2(HierarchicalStreamReader reader, Document doc)
{
String qname = reader.getNodeName();
Element parent = doc.createElement(qname);
Iterator i = reader.getAttributeNames();
while( i.hasNext() )
{
String aname = i.next().toString();
String value = reader.getAttribute(aname);
parent.setAttribute(aname, value);
}
String text = reader.getValue();
if( text.trim().length() != 0 )
{
Text textEl = doc.createTextNode(text);
parent.appendChild(textEl);
}
for( ; reader.hasMoreChildren(); reader.moveUp() )
{
reader.moveDown();
Element child = parseSubTree2(reader, doc);
parent.appendChild(child);
}
return parent;
}
示例5: resolveClass
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
@Override
public Class<?> resolveClass(HierarchicalStreamReader reader)
{
String name = reader.getAttribute(attribute);
Class<?> clazz = mapping.get(name);
if( clazz == null )
{
clazz = defaultClass;
}
return clazz;
}
示例6: getValue
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
public Object getValue(HierarchicalStreamReader reader)
{
Object value;
if( attributeName != null )
{
value = reader.getAttribute(attributeName);
}
else
{
value = reader.getValue();
}
return value;
}
示例7: unmarshal
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
ItemId id = new ItemId(reader.getAttribute("itemid")); //$NON-NLS-1$
try
{
return itemService.get(id);
}
catch( NotFoundException nfe )
{
return null;
}
}
示例8: unmarshal
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
Header header = new Header();
String status = reader.getAttribute("status");
header.setStatus(status);
for( ; reader.hasMoreChildren(); reader.moveUp() )
{
reader.moveDown();
String name = reader.getNodeName();
String value = reader.getValue();
if( name.equals("identifier") )
{
header.setIdentifier(value);
}
else if( name.equals("datestamp") )
{
header.setDatestamp(value);
}
else if( name.equals("setSpec") )
{
header.addSpec(value);
}
}
return header;
}
示例9: unmarshal
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
ResumptionToken token = new ResumptionToken();
String size = reader.getAttribute(COMPLETELISTSIZE);
String cursor = reader.getAttribute(CURSOR);
token.setCompleteListSize(parseInt(size, 0));
token.setCursor(parseInt(cursor, 0));
token.setToken(reader.getValue());
return token;
}
示例10: parseSubTree2
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
private Element parseSubTree2(HierarchicalStreamReader reader, Document doc)
{
String qname = reader.getNodeName();
Element parent = doc.createElement(qname);
// Iterator i = reader.getAttributeNames();
int count = reader.getAttributeCount();
for( int i = 0; i < count; i++ )
{
String aname = reader.getAttributeName(i);
String value = reader.getAttribute(i);
parent.setAttribute(aname, value);
}
String text = reader.getValue();
if( text.trim().length() != 0 )
{
Text textEl = doc.createTextNode(text);
parent.appendChild(textEl);
}
for( ; reader.hasMoreChildren(); reader.moveUp() )
{
reader.moveDown();
Element child = parseSubTree2(reader, doc);
parent.appendChild(child);
}
return parent;
}
示例11: unmarshal
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
String code = reader.getAttribute("code");
String message = reader.getValue();
return new OAIError(code, message);
}
示例12: unmarshallElement
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
private void unmarshallElement(HierarchicalStreamReader reader, Branch branch) {
Element element = branch.addElement(reader.getNodeName());
for (int i=0; i<reader.getAttributeCount(); i++) {
String attributeName = reader.getAttributeName(i);
String attributeValue = reader.getAttribute(i);
element.addAttribute(attributeName, attributeValue);
}
if (StringUtils.isNotBlank(reader.getValue()))
element.setText(reader.getValue().trim());
while (reader.hasMoreChildren()) {
reader.moveDown();
unmarshallElement(reader, element);
reader.moveUp();
}
}
示例13: instantiateNewInstance
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
protected Object instantiateNewInstance(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
final String attributeName = mapper.aliasForSystemAttribute("resolves-to");
final String readResolveValue = attributeName == null ? null : reader.getAttribute(attributeName);
final Object currentObject = context.currentObject();
if (currentObject != null) {
return currentObject;
} else if (readResolveValue != null) {
return reflectionProvider.newInstance(mapper.realClass(readResolveValue));
} else {
return reflectionProvider.newInstance(context.getRequiredType());
}
}
示例14: determineType
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
private Class<?> determineType(final HierarchicalStreamReader reader, final Object result, final String fieldName) {
final String classAttributeName = mapper.aliasForSystemAttribute("class");
final String classAttribute = classAttributeName == null ? null : reader.getAttribute(classAttributeName);
if (classAttribute != null) {
return mapper.realClass(classAttribute);
} else {
return mapper.defaultImplementationOf(beanProvider.getPropertyType(result, fieldName));
}
}
示例15: unmarshal
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
@Override
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
final String nullAttribute = reader.getAttribute("null");
if (nullAttribute != null && nullAttribute.equals("true")) {
return new Character('\0');
} else {
return fromString(reader.getValue());
}
}