@SuppressWarnings("unchecked")
 @Override
 public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
   List<Measure<?, Quantity>> measures = new LimpetList<>();
   Unit<Quantity> unit = null;
   Object item = null;
   if (reader.hasMoreChildren()) {
     reader.moveDown();
     item = readItem(reader, context, measures);
     if (item instanceof Unit) {
       unit = (Unit<Quantity>) item;
     }
     reader.moveUp();
   }
   if (unit == null) {
     @SuppressWarnings("rawtypes")
     Collection collection = (Collection) createCollection(context.getRequiredType());
     if (item != null) {
       collection.add(item);
     }
     populateCollection(reader, context, collection);
     return collection;
   }
   while (reader.hasMoreChildren()) {
     reader.moveDown();
     item = readItem(reader, context, measures);
     Double dbl = new Double(item.toString());
     Measure<Double, Quantity> value = Measure.valueOf(dbl, unit);
     measures.add(value);
     reader.moveUp();
   }
   return measures;
 }
  public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    final Enhancer enhancer = new Enhancer();
    reader.moveDown();
    enhancer.setSuperclass((Class) context.convertAnother(null, Class.class));
    reader.moveUp();
    reader.moveDown();
    List interfaces = new ArrayList();
    while (reader.hasMoreChildren()) {
      reader.moveDown();
      interfaces.add(context.convertAnother(null, mapper.realClass(reader.getNodeName())));
      reader.moveUp();
    }
    enhancer.setInterfaces((Class[]) interfaces.toArray(new Class[interfaces.size()]));
    reader.moveUp();
    reader.moveDown();
    boolean useFactory = Boolean.valueOf(reader.getValue()).booleanValue();
    enhancer.setUseFactory(useFactory);
    reader.moveUp();

    List callbacksToEnhance = new ArrayList();
    List callbacks = new ArrayList();
    Map callbackIndexMap = null;
    reader.moveDown();
    if ("callbacks".equals(reader.getNodeName())) {
      reader.moveDown();
      callbackIndexMap = (Map) context.convertAnother(null, HashMap.class);
      reader.moveUp();
      while (reader.hasMoreChildren()) {
        reader.moveDown();
        readCallback(reader, context, callbacksToEnhance, callbacks);
        reader.moveUp();
      }
    } else {
      readCallback(reader, context, callbacksToEnhance, callbacks);
    }
    enhancer.setCallbacks(
        (Callback[]) callbacksToEnhance.toArray(new Callback[callbacksToEnhance.size()]));
    if (callbackIndexMap != null) {
      enhancer.setCallbackFilter(new ReverseEngineeredCallbackFilter(callbackIndexMap));
    }
    reader.moveUp();
    Object result = null;
    while (reader.hasMoreChildren()) {
      reader.moveDown();
      if (reader.getNodeName().equals("serialVersionUID")) {
        enhancer.setSerialVersionUID(Long.valueOf(reader.getValue()));
      } else if (reader.getNodeName().equals("instance")) {
        result = create(enhancer, callbacks, useFactory);
        super.doUnmarshalConditionally(result, reader, context);
      }
      reader.moveUp();
    }
    if (result == null) {
      result = create(enhancer, callbacks, useFactory);
    }
    return serializationMethodInvoker.callReadResolve(result);
  }
    @Override
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
      reader.moveDown();
      TurnXML turn = (TurnXML) context.convertAnother(null, TurnXML.class);

      reader.moveUp();

      reader.moveDown();
      List<IAdminResponse> responses = new ArrayList<IAdminResponse>();
      while (reader.hasMoreChildren()) {
        reader.moveDown();
        String tag = reader.getNodeName();
        /*AdminResponse	is:
        -- Tile of false
        -- Boolean
        -- Tiles */
        IAdminResponse response = null;
        if (tag.equals(Constants.TAG_TILE))
          response = (TileXML) context.convertAnother(null, TileXML.class);
        else if (tag.equals(Constants.TAG_FALSE))
          response = (FalseXML) context.convertAnother(null, FalseXML.class);
        else if (tag.equals(Constants.TAG_TRUE))
          response = (TrueXML) context.convertAnother(null, TrueXML.class);
        else if (tag.equals(Constants.TAG_RERACK))
          response = (RerackXML) context.convertAnother(null, RerackXML.class);
        responses.add(response);
        reader.moveUp();
      }
      reader.moveUp();

      reader.moveDown();
      List<ITurnAction> actions = new ArrayList<ITurnAction>();
      while (reader.hasMoreChildren()) {
        reader.moveDown();

        String tag = reader.getNodeName();
        ITurnAction action = null;
        if (tag.equals(Constants.TAG_PLACEMENT))
          action = (PlacementXML) context.convertAnother(null, PlacementXML.class);
        else if (tag.equals(Constants.TAG_RERACKABLE))
          action = (RerackableXML) context.convertAnother(null, RerackableXML.class);
        else if (tag.equals(Constants.TAG_RERACK))
          action = (RerackXML) context.convertAnother(null, RerackXML.class);

        actions.add(action);
        reader.moveUp();
      }
      reader.moveUp();

      TurnTestXML pojo = new TurnTestXML(turn, actions, responses);
      return pojo;
    }
Beispiel #4
0
  @Override
  public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    Birthday birthday = new Birthday();
    String gender = reader.getAttribute("gender");
    if (gender != null) {
      if (gender.length() > 0) {

        if (gender.startsWith("f")) {
          birthday.setGenderFemale();
        } else if (gender.startsWith("m")) {
          birthday.setGenderMale();
        } else {
          throw new ConversionException("Invalid gender value: " + gender);
        }
      } else {
        throw new ConversionException("Empty string is invalid gender value");
      }
    }
    while (reader.hasMoreChildren()) {
      reader.moveDown();
      if ("person".equals(reader.getNodeName())) {
        Person person = (Person) context.convertAnother(birthday, Person.class);
        birthday.setPerson(person);
      } else if ("birth".equals(reader.getNodeName())) {
        Calendar date = (Calendar) context.convertAnother(birthday, Calendar.class);
        birthday.setDate(date);
      }
      reader.moveUp();
    }
    return birthday;
  }
  protected void unmarshallAttributes(
      Object current, HierarchicalStreamReader reader, UnmarshallingContext context) {

    while (reader.hasMoreChildren()) {
      Attribute attribute = readChildItem(reader, context, current);
      addAttribute(current, attribute);
    }
  }
Beispiel #6
0
 private Map<String, String> readNode(HierarchicalStreamReader reader) {
   Map<String, String> values = new HashMap<String, String>();
   while (reader.hasMoreChildren()) {
     reader.moveDown();
     values.put(reader.getNodeName(), reader.getValue());
     reader.moveUp();
   }
   return values;
 }
 @Override
 public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
   Map<String, String> map = new HashMap<String, String>();
   while (reader.hasMoreChildren()) {
     reader.moveDown();
     map.put(reader.getNodeName(), reader.getValue());
     reader.moveUp();
   }
   return map;
 }
 @SuppressWarnings("unchecked")
 public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
   List list = new ArrayList();
   while (reader.hasMoreChildren()) {
     reader.moveDown();
     list.add(context.convertAnother(list, type));
     reader.moveUp();
   }
   return list;
 }
 @Override
 public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
   List<String> names = new ArrayList<String>();
   while (reader.hasMoreChildren()) {
     reader.moveDown();
     names.add(reader.getAttribute(Constants.ATTRIBUTE_PLAYER_NAME));
     reader.moveUp();
   }
   return new PlayersXML(names);
 }
 @Override
 public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
   List<Tile> tiles = new ArrayList<Tile>();
   while (reader.hasMoreChildren()) {
     reader.moveDown();
     TileXML tileXML = (TileXML) context.convertAnother(null, TileXML.class);
     tiles.add(tileXML.getTile());
     reader.moveUp();
   }
   return new RerackXML(tiles);
 }
 private List<Tile> parsePlayerHand(
     HierarchicalStreamReader reader, UnmarshallingContext context) {
   List<Tile> tiles = new ArrayList<Tile>();
   while (reader.hasMoreChildren()) {
     reader.moveDown();
     TileXML tileXML = (TileXML) context.convertAnother(null, TileXML.class);
     tiles.add(tileXML.getTile());
     reader.moveUp();
   }
   return tiles;
 }
Beispiel #12
0
 protected void populateMap(
     final HierarchicalStreamReader reader,
     final UnmarshallingContext context,
     final Map<?, ?> map,
     final Map<?, ?> target) {
   while (reader.hasMoreChildren()) {
     reader.moveDown();
     putCurrentEntryIntoMap(reader, context, map, target);
     reader.moveUp();
   }
 }
 @Override
 public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
   String name = reader.getAttribute(Constants.ATTRIBUTE_RESULT_NAME);
   List<Placement> placements = new ArrayList<Placement>();
   while (reader.hasMoreChildren()) {
     reader.moveDown();
     PlacementXML placementXML = (PlacementXML) context.convertAnother(null, PlacementXML.class);
     placements.add(placementXML.getPlacement());
     reader.moveUp();
   }
   return new ResultXML(name, placements);
 }
  public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    Murmurs murmurs = new Murmurs();

    while (reader.hasMoreChildren()) {
      reader.moveDown();
      Murmur project = (Murmur) context.convertAnother(murmurs, Murmur.class);
      murmurs.add(project);
      reader.moveUp();
    }

    return murmurs;
  }
Beispiel #15
0
    /*
     * (non-Javadoc)
     *
     * @see
     * com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks
     * .xstream.io.HierarchicalStreamReader,
     * com.thoughtworks.xstream.converters.UnmarshallingContext)
     */
    @Override
    @SuppressWarnings("unchecked")
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
      InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder();

      while (reader.hasMoreChildren()) {
        reader.moveDown();

        String nodeName = reader.getNodeName();

        if (ELEM_HOST.equals(nodeName)) {
          builder.setHostName(reader.getValue());
        } else if (ELEM_INSTANCE_ID.equals(nodeName)) {
          builder.setInstanceId(reader.getValue());
        } else if (ELEM_APP.equals(nodeName)) {
          builder.setAppName(reader.getValue());
        } else if (ELEM_IP.equals(nodeName)) {
          builder.setIPAddr(reader.getValue());
        } else if (ELEM_SID.equals(nodeName)) {
          builder.setSID(reader.getValue());
        } else if (ELEM_IDENTIFYING_ATTR.equals(nodeName)) {
          // nothing;
        } else if (ELEM_STATUS.equals(nodeName)) {
          builder.setStatus(InstanceStatus.toEnum(reader.getValue()));
        } else if (ELEM_OVERRIDDEN_STATUS.equals(nodeName)) {
          builder.setOverriddenStatus(InstanceStatus.toEnum(reader.getValue()));
        } else if (ELEM_PORT.equals(nodeName)) {
          builder.setPort(Integer.valueOf(reader.getValue()).intValue());
          // Defaults to true
          builder.enablePort(PortType.UNSECURE, !"false".equals(reader.getAttribute(ATTR_ENABLED)));
        } else if (ELEM_SECURE_PORT.equals(nodeName)) {
          builder.setSecurePort(Integer.valueOf(reader.getValue()).intValue());
          // Defaults to false
          builder.enablePort(PortType.SECURE, "true".equals(reader.getAttribute(ATTR_ENABLED)));
        } else if (ELEM_COUNTRY_ID.equals(nodeName)) {
          builder.setCountryId(Integer.valueOf(reader.getValue()).intValue());
        } else if (NODE_DATACENTER.equals(nodeName)) {
          builder.setDataCenterInfo(
              (DataCenterInfo) context.convertAnother(builder, DataCenterInfo.class));
        } else if (NODE_LEASE.equals(nodeName)) {
          builder.setLeaseInfo((LeaseInfo) context.convertAnother(builder, LeaseInfo.class));
        } else if (NODE_METADATA.equals(nodeName)) {
          builder.setMetadata((Map<String, String>) context.convertAnother(builder, Map.class));
        } else {
          autoUnmarshalEligible(reader, builder.getRawInstance());
        }

        reader.moveUp();
      }

      return builder.build();
    }
Beispiel #16
0
 public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingContext context) {
   if (reader.hasMoreChildren()) {
     /* old format where <range> elements are nested like
            <range>
              <start>1337</start>
              <end>1479</end>
            </range>
     */
     return new RangeSet((List<Range>) (collectionConv.unmarshal(reader, context)));
   } else {
     return RangeSet.fromString(reader.getValue(), true);
   }
 }
  @Override
  public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    Wfs20FeatureCollection featureCollection = new Wfs20FeatureCollection();
    while (reader.hasMoreChildren()) {
      reader.moveDown();
      String nodeName = reader.getNodeName();

      // Its important to note that the reader appears to drop the
      // namespace.
      if (FEATURE_MEMBER.equals(nodeName)) {
        reader.moveDown();
        String subNodeName = reader.getNodeName();
        // If the member contains a sub feature collection, step in and get members
        if (subNodeName.equals(FEATURE_COLLECTION)) {

          while (reader.hasMoreChildren()) {
            reader.moveDown();
            String subNodeName2 = reader.getNodeName();
            if (FEATURE_MEMBER.equals(subNodeName2)) {
              reader.moveDown();
              // lookup the converter for this featuretype
              featureCollection =
                  addMetacardToFeatureCollection(featureCollection, context, reader);
              reader.moveUp();
            }
            reader.moveUp();
          }

        } else {
          // lookup the converter for this featuretype
          featureCollection = addMetacardToFeatureCollection(featureCollection, context, reader);
        }
        reader.moveUp();
      }
      reader.moveUp();
    }
    return featureCollection;
  }
  @Override
  public FIXMLRoot unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {

    FIXMLRoot root = new FIXMLRoot();
    root.setVersion(reader.getAttribute("v"));
    root.setReleaseDate(reader.getAttribute("r"));
    root.setSchemaDate(reader.getAttribute("s"));

    if (reader.hasMoreChildren()) {
      reader.moveDown();
      root.setMessage((Message) context.convertAnother(root, Message.class));
      reader.moveUp();
    }

    return root;
  }
    @Override
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {

      String players = reader.getAttribute(Constants.ATTRIBUTE_BOARD_PLAYERS);
      int numberOfPlayers = new Integer(players).intValue();

      List<Placement> currentPlacements = new ArrayList<Placement>();
      while (reader.hasMoreChildren()) {
        reader.moveDown();
        PlacementXML placementXML = (PlacementXML) context.convertAnother(null, PlacementXML.class);
        currentPlacements.add(placementXML.getPlacement());
        reader.moveUp();
      }

      return new BoardXML(numberOfPlayers, currentPlacements);
    }
 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();
 }
Beispiel #21
0
    /*
     * (non-Javadoc)
     *
     * @see
     * com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks
     * .xstream.io.HierarchicalStreamReader,
     * com.thoughtworks.xstream.converters.UnmarshallingContext)
     */
    @Override
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
      Application app = new Application();

      while (reader.hasMoreChildren()) {
        reader.moveDown();

        String nodeName = reader.getNodeName();

        if (ELEM_NAME.equals(nodeName)) {
          app.setName(reader.getValue());
        } else if (NODE_INSTANCE.equals(nodeName)) {
          app.addInstance((InstanceInfo) context.convertAnother(app, InstanceInfo.class));
        }
        reader.moveUp();
      }
      return app;
    }
Beispiel #22
0
    private Map<String, String> unmarshalMap(
        HierarchicalStreamReader reader, UnmarshallingContext context) {

      Map<String, String> map = Collections.emptyMap();

      while (reader.hasMoreChildren()) {
        if (map == Collections.EMPTY_MAP) {
          map = new HashMap<String, String>();
        }
        reader.moveDown();
        String key = reader.getNodeName();
        String value = reader.getValue();
        reader.moveUp();

        map.put(StringCache.intern(key), value);
      }
      return map;
    }
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {

      String node = reader.getNodeName();

      reader.moveDown();

      GithubSecurityRealm realm = new GithubSecurityRealm();

      node = reader.getNodeName();

      String value = reader.getValue();

      setValue(realm, node, value);

      reader.moveUp();

      reader.moveDown();

      node = reader.getNodeName();

      value = reader.getValue();

      setValue(realm, node, value);

      reader.moveUp();

      if (reader.hasMoreChildren()) {
        reader.moveDown();

        node = reader.getNodeName();

        value = reader.getValue();

        setValue(realm, node, value);

        reader.moveUp();
      }

      if (realm.getGithubUri() == null) {
        realm.setGithubUri(DEFAULT_URI);
      }

      return realm;
    }
    @Override
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {

      String numberOfPlayersStr = reader.getAttribute(Constants.ATTRIBUTE_ACCEPT_PLAYER);
      int numberOfPlayers;
      try {
        numberOfPlayers = Integer.parseInt(numberOfPlayersStr);
      } catch (NumberFormatException e) {
        return null;
      }
      List<Tile> tiles = new ArrayList<Tile>();
      while (reader.hasMoreChildren()) {
        reader.moveDown();
        TileXML tileXML = (TileXML) context.convertAnother(null, TileXML.class);
        tiles.add(tileXML.getTile());
        reader.moveUp();
      }
      return new AcceptXML(numberOfPlayers, tiles);
    }
 protected void unmarshalStringKey(
     HierarchicalStreamReader reader, UnmarshallingContext context, Map map, String key) {
   String type = reader.getAttribute("type");
   Object value;
   if (type == null && reader.hasMoreChildren()) {
     reader.moveDown();
     value = readItem(reader, context, map);
     reader.moveUp();
   } else {
     Class typeC = type != null ? mapper().realClass(type) : String.class;
     try {
       value = TypeCoercions.coerce(reader.getValue(), typeC);
     } catch (Exception e) {
       log.warn("FAILED to coerce " + reader.getValue() + " to " + typeC + ": " + e);
       throw Exceptions.propagate(e);
     }
   }
   map.put(key, value);
 }
Beispiel #26
0
    /*
     * (non-Javadoc)
     *
     * @see
     * com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks
     * .xstream.io.HierarchicalStreamReader,
     * com.thoughtworks.xstream.converters.UnmarshallingContext)
     */
    @Override
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
      Applications apps = new Applications();
      while (reader.hasMoreChildren()) {
        reader.moveDown();

        String nodeName = reader.getNodeName();

        if (NODE_APP.equals(nodeName)) {
          apps.addApplication((Application) context.convertAnother(apps, Application.class));
        } else if (VERSIONS_DELTA.equals(nodeName)) {
          apps.setVersion(Long.valueOf(reader.getValue()));
        } else if (APPS_HASHCODE.equals(nodeName)) {
          apps.setAppsHashCode(reader.getValue());
        }
        reader.moveUp();
      }
      return apps;
    }
 public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
   EasyApiMessageDto dto = null;
   String nodeName = reader.getNodeName();
   if (StringUtil.equals(nodeName, "request")) {
     dto = new RequestDto();
   } else if (StringUtil.equals(nodeName, "response")) {
     dto = new ResponseDto();
   } else {
     throw new XStreamException("unknown node name");
   }
   while (reader.hasMoreChildren()) {
     reader.moveDown();
     if (StringUtil.equals(reader.getNodeName(), "head")) {
       dto.header = (HeaderDto) context.convertAnother(dto, HeaderDto.class);
     } else if (StringUtil.equals(reader.getNodeName(), "body")) {
       dto.body = context.convertAnother(dto, bodyDtoClass.get());
     }
     reader.moveUp();
   }
   return dto;
 }
 @SuppressWarnings("unchecked")
 public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
   List interfaces = new ArrayList();
   InvocationHandler handler = null;
   while (reader.hasMoreChildren()) {
     reader.moveDown();
     String elementName = reader.getNodeName();
     if (elementName.equals("interface")) {
       interfaces.add(mapper.realClass(reader.getValue()));
     } else if (elementName.equals("handler")) {
       Class handlerType = mapper.realClass(reader.getAttribute("class"));
       handler = (InvocationHandler) context.convertAnother(null, handlerType);
     }
     reader.moveUp();
   }
   if (handler == null) {
     throw new ConversionException("No InvocationHandler specified for dynamic proxy");
   }
   Class[] interfacesAsArray = new Class[interfaces.size()];
   interfaces.toArray(interfacesAsArray);
   return Proxy.newProxyInstance(classLoader, interfacesAsArray, handler);
 }
Beispiel #29
0
    /*
     * (non-Javadoc)
     *
     * @see
     * com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks
     * .xstream.io.HierarchicalStreamReader,
     * com.thoughtworks.xstream.converters.UnmarshallingContext)
     */
    @Override
    @SuppressWarnings("unchecked")
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
      DataCenterInfo info = null;
      while (reader.hasMoreChildren()) {
        reader.moveDown();

        if (ELEM_NAME.equals(reader.getNodeName())) {
          final String dataCenterName = reader.getValue();
          if (DataCenterInfo.Name.Amazon.name().equalsIgnoreCase(dataCenterName)) {
            info = new AmazonInfo();
          } else {
            final DataCenterInfo.Name name = DataCenterInfo.Name.valueOf(dataCenterName);
            info =
                new DataCenterInfo() {

                  @Override
                  public Name getName() {
                    return name;
                  }
                };
          }
        } else if (NODE_METADATA.equals(reader.getNodeName())) {
          if (info.getName() == Name.Amazon) {
            Map<String, String> metadataMap =
                (Map<String, String>) context.convertAnother(info, Map.class);
            Map<String, String> metadataMapInter = new HashMap<String, String>(metadataMap.size());
            for (Map.Entry<String, String> entry : metadataMap.entrySet()) {
              metadataMapInter.put(
                  StringCache.intern(entry.getKey()), StringCache.intern(entry.getValue()));
            }
            ((AmazonInfo) info).setMetadata(metadataMapInter);
          }
        }

        reader.moveUp();
      }
      return info;
    }
Beispiel #30
0
    /*
     * (non-Javadoc)
     *
     * @see
     * com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks
     * .xstream.io.HierarchicalStreamReader,
     * com.thoughtworks.xstream.converters.UnmarshallingContext)
     */
    @Override
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {

      LeaseInfo.Builder builder = LeaseInfo.Builder.newBuilder();

      while (reader.hasMoreChildren()) {
        reader.moveDown();

        String nodeName = reader.getNodeName();
        String nodeValue = reader.getValue();
        if (nodeValue == null) {
          continue;
        }

        long longValue = 0;
        try {
          longValue = Long.valueOf(nodeValue).longValue();
        } catch (NumberFormatException ne) {
          continue;
        }

        if (ELEM_DURATION.equals(nodeName)) {
          builder.setDurationInSecs((int) longValue);
        } else if (ELEM_EVICTION_TIMESTAMP.equals(nodeName)) {
          builder.setEvictionTimestamp(longValue);
        } else if (ELEM_LAST_RENEW_TIMETSTAMP.equals(nodeName)) {
          builder.setRenewalTimestamp(longValue);
        } else if (ELEM_REG_TIMESTAMP.equals(nodeName)) {
          builder.setRegistrationTimestamp(longValue);
        } else if (ELEM_RENEW_INT.equals(nodeName)) {
          builder.setRenewalIntervalInSecs((int) longValue);
        } else if (ELEM_SERVICE_UP_TIMESTAMP.equals(nodeName)) {
          builder.setServiceUpTimestamp(longValue);
        }
        reader.moveUp();
      }
      return builder.build();
    }