6fc3da9d22ad7252d8a02b4e0d9f9f515f0c8a39
[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  * @version $Id$
27  */
28 public class ARK {
29
30         /** The public URI of the ARK. */
31         private final String publicURI;
32
33         /** The private URI of the ARK. */
34         private final String privateURI;
35
36         /** The number of the ARK. */
37         private final int number;
38
39         /**
40          * Creates a new ARK with the given URI and number.
41          * 
42          * @param publicURI
43          *            The public URI of the ARK
44          * @param number
45          *            The number of the ARK
46          */
47         public ARK(String publicURI, String number) {
48                 this(publicURI, null, number);
49         }
50
51         /**
52          * Creates a new ARK with the given URIs and number.
53          * 
54          * @param publicURI
55          *            The public URI of the ARK
56          * @param privateURI
57          *            The private URI of the ARK
58          * @param number
59          *            The number of the ARK
60          */
61         public ARK(String publicURI, String privateURI, String number) {
62                 if ((publicURI == null) || (number == null)) {
63                         throw new NullPointerException(((publicURI == null) ? "publicURI" : "number") + " must not be null");
64                 }
65                 this.publicURI = publicURI;
66                 this.privateURI = privateURI;
67                 try {
68                         this.number = Integer.valueOf(number);
69                 } catch (NumberFormatException nfe1) {
70                         throw new IllegalArgumentException("number must be numeric", nfe1);
71                 }
72         }
73
74         /**
75          * Returns the public URI of the ARK.
76          * 
77          * @return The public URI of the ARK
78          */
79         public String getPublicURI() {
80                 return publicURI;
81         }
82
83         /**
84          * Returns the private URI of the ARK.
85          * 
86          * @return The private URI of the ARK
87          */
88         public String getPrivateURI() {
89                 return privateURI;
90         }
91
92         /**
93          * Returns the number of the ARK.
94          * 
95          * @return The number of the ARK
96          */
97         public int getNumber() {
98                 return number;
99         }
100
101 }