2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.tr064.internal.soap;
15 import java.text.ParseException;
16 import java.text.SimpleDateFormat;
17 import java.util.Date;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.tr064.internal.dto.additions.Call;
24 * The {@link CallListEntry} is used for post-processing the retrieved call
27 * @author Jan N. Klug - Initial contribution
30 public class CallListEntry {
31 private static final SimpleDateFormat DATE_FORMAT_PARSER = new SimpleDateFormat("dd.MM.yy HH:mm");
32 public @Nullable String localNumber;
33 public @Nullable String remoteNumber;
34 public @Nullable Date date;
35 public @Nullable Integer type;
36 public @Nullable Integer duration;
38 public CallListEntry(Call call) {
40 synchronized (DATE_FORMAT_PARSER) {
41 date = DATE_FORMAT_PARSER.parse(call.getDate());
43 } catch (ParseException e) {
44 // ignore parsing error
47 String[] durationParts = call.getDuration().split(":");
48 duration = Integer.parseInt(durationParts[0]) * 60 + Integer.parseInt(durationParts[1]);
49 type = Integer.parseInt(call.getType());
50 if (CallListType.OUTBOUND_COUNT.typeString().equals(call.getType())) {
51 localNumber = call.getCallerNumber();
52 remoteNumber = call.getCalled();
54 localNumber = call.getCalledNumber();
55 remoteNumber = call.getCaller();