2 * Copyright 2008 ZXing authors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.google.zxing.client.result;
22 public final class SMSParsedResult extends ParsedResult {
24 private final String[] numbers;
25 private final String[] vias;
26 private final String subject;
27 private final String body;
29 public SMSParsedResult(String number, String via, String subject, String body) {
30 super(ParsedResultType.SMS);
31 this.numbers = new String[] {number};
32 this.vias = new String[] {via};
33 this.subject = subject;
37 public SMSParsedResult(String[] numbers, String[] vias, String subject, String body) {
38 super(ParsedResultType.SMS);
39 this.numbers = numbers;
41 this.subject = subject;
45 public String getSMSURI() {
46 StringBuffer result = new StringBuffer();
47 result.append("sms:");
49 for (int i = 0; i < numbers.length; i++) {
55 result.append(numbers[i]);
56 if (vias[i] != null) {
57 result.append(";via=");
58 result.append(vias[i]);
61 boolean hasBody = body != null;
62 boolean hasSubject = subject != null;
63 if (hasBody || hasSubject) {
66 result.append("body=");
73 result.append("subject=");
74 result.append(subject);
77 return result.toString();
80 public String[] getNumbers() {
84 public String[] getVias() {
88 public String getSubject() {
92 public String getBody() {
96 public String getDisplayResult() {
97 StringBuffer result = new StringBuffer(100);
98 maybeAppend(numbers, result);
99 maybeAppend(subject, result);
100 maybeAppend(body, result);
101 return result.toString();