本文整理匯總了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());
}
}