blob: 47d6ec609fcf1537ea9644e167cd97ca201f94d6 [file] [log] [blame]
Irfan Sherifffa291e62012-04-04 13:18:17 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.net.nsd;
18
19import android.os.Parcelable;
20import android.os.Parcel;
21
22/**
23 * Defines a service based on DNS service discovery
24 * {@hide}
25 */
26public class DnsSdServiceInfo implements NetworkServiceInfo, Parcelable {
27
28 private String mServiceName;
29
30 private String mRegistrationType;
31
32 private DnsSdTxtRecord mTxtRecord;
33
34 private String mHostname;
35
36 private int mPort;
37
38 DnsSdServiceInfo() {
39 }
40
41 DnsSdServiceInfo(String sn, String rt, DnsSdTxtRecord tr) {
42 mServiceName = sn;
43 mRegistrationType = rt;
44 mTxtRecord = tr;
45 }
46
47 @Override
48 /** @hide */
49 public String getServiceName() {
50 return mServiceName;
51 }
52
53 @Override
54 /** @hide */
55 public void setServiceName(String s) {
56 mServiceName = s;
57 }
58
59 @Override
60 /** @hide */
61 public String getServiceType() {
62 return mRegistrationType;
63 }
64
65 @Override
66 /** @hide */
67 public void setServiceType(String s) {
68 mRegistrationType = s;
69 }
70
71 public DnsSdTxtRecord getTxtRecord() {
72 return mTxtRecord;
73 }
74
75 public void setTxtRecord(DnsSdTxtRecord t) {
76 mTxtRecord = new DnsSdTxtRecord(t);
77 }
78
79 public String getHostName() {
80 return mHostname;
81 }
82
83 public void setHostName(String s) {
84 mHostname = s;
85 }
86
87 public int getPort() {
88 return mPort;
89 }
90
91 public void setPort(int p) {
92 mPort = p;
93 }
94
95 public String toString() {
96 StringBuffer sb = new StringBuffer();
97
98 sb.append("name: ").append(mServiceName).
99 append("type: ").append(mRegistrationType).
100 append("txtRecord: ").append(mTxtRecord);
101 return sb.toString();
102 }
103
104 /** Implement the Parcelable interface */
105 public int describeContents() {
106 return 0;
107 }
108
109 /** Implement the Parcelable interface */
110 public void writeToParcel(Parcel dest, int flags) {
111 dest.writeString(mServiceName);
112 dest.writeString(mRegistrationType);
113 dest.writeParcelable(mTxtRecord, flags);
114 dest.writeString(mHostname);
115 dest.writeInt(mPort);
116 }
117
118 /** Implement the Parcelable interface */
119 public static final Creator<DnsSdServiceInfo> CREATOR =
120 new Creator<DnsSdServiceInfo>() {
121 public DnsSdServiceInfo createFromParcel(Parcel in) {
122 DnsSdServiceInfo info = new DnsSdServiceInfo();
123 info.mServiceName = in.readString();
124 info.mRegistrationType = in.readString();
125 info.mTxtRecord = in.readParcelable(null);
126 info.mHostname = in.readString();
127 info.mPort = in.readInt();
128 return info;
129 }
130
131 public DnsSdServiceInfo[] newArray(int size) {
132 return new DnsSdServiceInfo[size];
133 }
134 };
135
136}