]>
iEval git - fonbot.git/blob - Address.java
5777cfe54978799a41e3582222adc3150f465429
1 package ro
. ieval
. fonbot
;
3 import org
. eclipse
. jdt
. annotation
. Nullable
;
6 * Copyright © 2013 Marius Gavrilescu
8 * This file is part of FonBot.
10 * FonBot is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * FonBot is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FonBot. If not, see <http://www.gnu.org/licenses/>.
25 * An address to which messages can be sent using {@link Utils#sendMessage(android.content.Context, Address, int)}
27 * Addresses are defined by a protocol and a data part. The data is a protocol-dependent opaque String.
29 * @author Marius Gavrilescu <marius@ieval.ro>
33 * The protocol of an Address.
34 * @author Marius Gavrilescu <marius@ieval.ro>
36 public static enum Protocol
{
38 * The protocol used for sending messages via short text messages. The data for a SMS address is the phone number.
42 * The protocol used for sending messages via anything handled by the iEval server. The data is an opaque String supplied by the iEval server.
46 * The protocol used for sending messages to {@link FonBotLocalActivity}
50 * The protocol used for suppressing messages.
56 * An address for suppressing messages
58 public static final Address BLACKHOLE
= new Address ( Utils
. toNonNull ( Protocol
. NULL
), null );
60 * The protocol part of the Address.
62 public final Protocol protocol
;
64 * The data part of the Address. Can be null
66 public final String data
;
68 /** The ID of this request. Used in annotations. Can be null */
69 public final transient String requestId
;
72 * Construct an Address from its parts
74 * @param protocol the protocol part of the Address
75 * @param data the data part of the Address
77 public Address ( final Protocol protocol
, final @Nullable String data
){
78 this . protocol
= protocol
;
84 * Construct an Address from its parts
86 * @param protocol the protocol part of the Address
87 * @param data the data part of the Address
88 * @param requestId the request ID
90 public Address ( final Protocol protocol
, final @Nullable String data
, final String requestId
){
91 this . protocol
= protocol
;
93 this . requestId
= requestId
;
97 * Construct an Address from its string representation (the protocol and data in this order separated by a single space character). Does the reverse of {@link #toString()}
99 * @param address the Address string representation
100 * @throws IllegalArgumentException if the protocol part is not a member of the {@link Protocol} enum
102 public Address ( final String address
) throws IllegalArgumentException
{
103 final String
[] parts
= address
. split ( " " , 2 );
104 this . protocol
= Protocol
. valueOf ( parts
[ 0 ]);
110 * Returns the string representation of an Address, which is the protocol and data in this order separated by a single space character
113 public String
toString (){
114 return protocol
+ " " + data
;
This page took 0.045001 seconds and 3 git commands to generate.