6dda31909e6df9c6eb362a14bf5a07f10f1da035
[jFCPlib.git] / src / net / pterodactylus / fcp / ARK.java
1 /*
2  * jSite2 - ARK.java -
3  * Copyright © 2008 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package net.pterodactylus.fcp;
21
22 /**
23  * Container for ARKs (address resolution keys).
24  * 
25  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
26  */
27 public class ARK {
28
29         /** The public URI of the ARK. */
30         private final String publicURI;
31
32         /** The private URI of the ARK. */
33         private final String privateURI;
34
35         /** The number of the ARK. */
36         private final int number;
37
38         /**
39          * Creates a new ARK with the given URI and number.
40          * 
41          * @param publicURI
42          *            The public URI of the ARK
43          * @param number
44          *            The number of the ARK
45          */
46         public ARK(String publicURI, String number) {
47                 this(publicURI, null, number);
48         }
49
50         /**
51          * Creates a new ARK with the given URIs and number.
52          * 
53          * @param publicURI
54          *            The public URI of the ARK
55          * @param privateURI
56          *            The private URI of the ARK
57          * @param number
58          *            The number of the ARK
59          */
60         public ARK(String publicURI, String privateURI, String number) {
61                 if ((publicURI == null) || (number == null)) {
62                         throw new NullPointerException(((publicURI == null) ? "publicURI" : "number") + " must not be null");
63                 }
64                 this.publicURI = publicURI;
65                 this.privateURI = privateURI;
66                 try {
67                         this.number = Integer.valueOf(number);
68                 } catch (NumberFormatException nfe1) {
69                         throw new IllegalArgumentException("number must be numeric", nfe1);
70                 }
71         }
72
73         /**
74          * Returns the public URI of the ARK.
75          * 
76          * @return The public URI of the ARK
77          */
78         public String getPublicURI() {
79                 return publicURI;
80         }
81
82         /**
83          * Returns the private URI of the ARK.
84          * 
85          * @return The private URI of the ARK
86          */
87         public String getPrivateURI() {
88                 return privateURI;
89         }
90
91         /**
92          * Returns the number of the ARK.
93          * 
94          * @return The number of the ARK
95          */
96         public int getNumber() {
97                 return number;
98         }
99
100 }