1482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes/* 2482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * Copyright (C) 2013 The Android Open Source Project 3482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * 4482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 5482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * you may not use this file except in compliance with the License. 6482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * You may obtain a copy of the License at 7482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * 8482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 9482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * 10482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * Unless required by applicable law or agreed to in writing, software 11482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 12482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * See the License for the specific language governing permissions and 14482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * limitations under the License. 15482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes */ 16482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes 17482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughespackage java.net; 18482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes 192a6f23ff8690ac2f025588a360547ce96cde0943Elliott Hughesimport java.nio.charset.StandardCharsets; 20482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes 215d930cadc8f62aee5f18e7921296fe66a54f18abElliott Hughesimport static android.system.OsConstants.*; 22482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes 23482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes/** 24482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * An AF_UNIX address. See {@link InetAddress}. 25482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * @hide 26482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes */ 27482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughespublic final class InetUnixAddress extends InetAddress { 28482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes /** 29482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * Constructs an AF_UNIX InetAddress for the given path. 30482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes */ 31482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes public InetUnixAddress(String path) { 322a6f23ff8690ac2f025588a360547ce96cde0943Elliott Hughes this(path.getBytes(StandardCharsets.UTF_8)); 33482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes } 34482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes 35482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes /** 36482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * Constructs an AF_UNIX InetAddress for the given path. 37482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes */ 38482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes public InetUnixAddress(byte[] path) { 39482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes super(AF_UNIX, path, null); 40482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes } 41482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes 42482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes /** 43482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes * Returns a string form of this InetAddress. 44482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes */ 45482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes @Override public String toString() { 462a6f23ff8690ac2f025588a360547ce96cde0943Elliott Hughes return "InetUnixAddress[" + new String(ipaddress, StandardCharsets.UTF_8) + "]"; 47482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes } 48482a3fc5635ac431b8a7476d7fe3397af4c2e8ecElliott Hughes} 49