1 /*
2 * JBoss, Home of Professional Open Source
3 *
4 * Copyright 2010 Red Hat, Inc. and/or its affiliates, and individual
5 * contributors as indicated by the @author tags.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20 package org.xnio;
21
22 import java.net.SocketAddress;
23
24 import static org.xnio._private.Messages.msg;
25
26 /**
27 * A socket address which is a local (UNIX domain) socket.
28 *
29 * @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
30 */
31 public final class LocalSocketAddress extends SocketAddress {
32
33 private static final long serialVersionUID = -596342428809783686L;
34
35 private final String name;
36
37 /**
38 * Construct a new instance.
39 *
40 * @param name the name of this socket address
41 */
42 public LocalSocketAddress(final String name) {
43 if (name == null) {
44 throw msg.nullParameter("name");
45 }
46 this.name = name;
47 }
48
49 /**
50 * Get the name (filesystem path) of this local socket address.
51 *
52 * @return the name
53 */
54 public String getName() {
55 return name;
56 }
57
58 /**
59 * Get the string representation of this socket address (its name).
60 *
61 * @return the string representation
62 */
63 public String toString() {
64 return getName();
65 }
66 }
67