Skip to Content.
Sympa Menu

perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r6246 - trunk/perfsonar-base/messaging/src/main/java/net/geant/perfsonar/messaging

Subject: perfsonar development work

List archive

[pS-dev] [GEANT/SA2/ps-java-services] r6246 - trunk/perfsonar-base/messaging/src/main/java/net/geant/perfsonar/messaging


Chronological Thread 
  • From:
  • To:
  • Subject: [pS-dev] [GEANT/SA2/ps-java-services] r6246 - trunk/perfsonar-base/messaging/src/main/java/net/geant/perfsonar/messaging
  • Date: Mon, 25 Mar 2013 12:39:19 +0000 (GMT)
  • Authentication-results: sfpop-ironport04.merit.edu; dkim=neutral (message not signed) header.i=none

Author: psnc.pietrzak
Date: 2013-03-25 12:39:19 +0000 (Mon, 25 Mar 2013)
New Revision: 6246

Modified:

trunk/perfsonar-base/messaging/src/main/java/net/geant/perfsonar/messaging/XPathDeserializer.java
Log:
Bug fix.

Modified:
trunk/perfsonar-base/messaging/src/main/java/net/geant/perfsonar/messaging/XPathDeserializer.java
===================================================================
---
trunk/perfsonar-base/messaging/src/main/java/net/geant/perfsonar/messaging/XPathDeserializer.java
2013-03-25 11:04:30 UTC (rev 6245)
+++
trunk/perfsonar-base/messaging/src/main/java/net/geant/perfsonar/messaging/XPathDeserializer.java
2013-03-25 12:39:19 UTC (rev 6246)
@@ -120,6 +120,7 @@
/**
* Deserializes objects from xml stream using streaming XPath
expressions.
*/
+ @SuppressWarnings("unchecked")
public List<?> deserialize(InputSource reader) throws
SAXPathException, XPathException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException, InstantiationException {

final XMLDog dog = new XMLDog(context);
final List<Expression> expressions = new
ArrayList<Expression>();
@@ -130,21 +131,12 @@
final XPathResults results = dog.sniff(reader);

for (Expression expr : sort(expressions)) {
- @SuppressWarnings("unchecked")
- final Collection<NodeItem> temp =
(Collection<NodeItem>) results.getResult(expr);
- if (temp.size() <= 0) continue;
final Method method =
XPathDeserializer.getXPathMethod(expr.getXPath());

- for (NodeItem item : temp) {
- if
(method.getParameterTypes()[0].equals(String.class)) {
- method.invoke(getInstance(method),
item.value);
- } else {
- final Object reference =
getReference(item.value, identifiers.get(method.getParameterTypes()[0]));
- if (reference == null) continue;
- method.invoke(getInstance(method),
reference);
- }
-
- increment(method);
+ if (results.getResult(expr) instanceof String)
+ process(method, (String)
results.getResult(expr));
+ else {
+ processNodeItem(expr, (Collection<NodeItem>)
results.getResult(expr), method);
}
}

@@ -154,6 +146,31 @@
return result;

}
+
+ private void processNodeItem(Expression expr, final
Collection<NodeItem> temp, Method method) throws IllegalAccessException,
+ InvocationTargetException, InstantiationException {
+ if (temp.size() <= 0)
+ return;
+
+ for (NodeItem item : temp) {
+ process(method, item.value);
+ }
+ }
+
+ private void process(final Method method, String value)
+ throws IllegalAccessException,
InvocationTargetException,
+ InstantiationException {
+ if (method.getParameterTypes()[0].equals(String.class)) {
+ method.invoke(getInstance(method), value);
+ } else {
+ final Object reference = getReference(value,
identifiers.get(method.getParameterTypes()[0]));
+ if (reference == null)
+ return;
+ method.invoke(getInstance(method), reference);
+ }
+
+ increment(method);
+ }

@SuppressWarnings("unchecked")
public <T> List<T> getObjects(Class<T> type, List<Object> objects) {



  • [pS-dev] [GEANT/SA2/ps-java-services] r6246 - trunk/perfsonar-base/messaging/src/main/java/net/geant/perfsonar/messaging, svn-noreply, 03/25/2013

Archive powered by MHonArc 2.6.16.

Top of Page