author | jlaskey |
Thu, 14 Nov 2019 12:39:49 -0400 | |
branch | JDK-8193209-branch |
changeset 59086 | 214afc7a1e02 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2542 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
11823
diff
changeset
|
2 |
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
2542 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2542 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2542 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2542 | 24 |
*/ |
11823
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
25 |
package sun.nio.ch.sctp; |
2542 | 26 |
|
27 |
import java.net.SocketAddress; |
|
28 |
import com.sun.nio.sctp.MessageInfo; |
|
29 |
import com.sun.nio.sctp.Association; |
|
30 |
||
31 |
/** |
|
32 |
* An implementation of a MessageInfo. |
|
33 |
*/ |
|
11823
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
34 |
public class MessageInfoImpl extends MessageInfo { |
2542 | 35 |
private final SocketAddress address; |
36 |
private final int bytes; /* 0 */ |
|
37 |
||
38 |
private Association association; |
|
39 |
private int assocId; |
|
40 |
private int streamNumber; |
|
41 |
private boolean complete = true; |
|
42 |
private boolean unordered; /* false */ |
|
43 |
private long timeToLive; /* 0L */ |
|
44 |
private int ppid; /* 0 */ |
|
45 |
||
11823
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
46 |
public MessageInfoImpl(Association association, |
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
47 |
SocketAddress address, |
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
48 |
int streamNumber) { |
2542 | 49 |
this.association = association; |
50 |
this.address = address; |
|
51 |
this.streamNumber = streamNumber; |
|
52 |
bytes = 0; |
|
53 |
} |
|
54 |
||
55 |
/* Invoked from native */ |
|
11823
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
56 |
private MessageInfoImpl(int assocId, |
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
57 |
SocketAddress address, |
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
58 |
int bytes, |
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
59 |
int streamNumber, |
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
60 |
boolean complete, |
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
61 |
boolean unordered, |
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
62 |
int ppid) { |
2542 | 63 |
this.assocId = assocId; |
64 |
this.address = address; |
|
65 |
this.bytes = bytes; |
|
66 |
this.streamNumber = streamNumber; |
|
67 |
this.complete = complete; |
|
68 |
this.unordered = unordered; |
|
69 |
this.ppid = ppid; |
|
70 |
} |
|
71 |
||
72 |
@Override |
|
73 |
public Association association() { |
|
74 |
return association; |
|
75 |
} |
|
76 |
||
77 |
/** |
|
11823
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
5506
diff
changeset
|
78 |
* MessageInfoImpl instances created from native will need to have their |
2542 | 79 |
* association set from the channel. |
80 |
*/ |
|
81 |
void setAssociation(Association association) { |
|
82 |
this.association = association; |
|
83 |
} |
|
84 |
||
85 |
int associationID() { |
|
86 |
return assocId; |
|
87 |
} |
|
88 |
||
89 |
@Override |
|
90 |
public SocketAddress address() { |
|
91 |
return address; |
|
92 |
} |
|
93 |
||
94 |
@Override |
|
95 |
public int bytes() { |
|
96 |
return bytes; |
|
97 |
} |
|
98 |
||
99 |
@Override |
|
100 |
public int streamNumber() { |
|
101 |
return streamNumber; |
|
102 |
} |
|
103 |
||
104 |
@Override |
|
105 |
public MessageInfo streamNumber(int streamNumber) { |
|
106 |
if (streamNumber < 0 || streamNumber > 65536) |
|
107 |
throw new IllegalArgumentException("Invalid stream number"); |
|
108 |
||
109 |
this.streamNumber = streamNumber; |
|
110 |
return this; |
|
111 |
} |
|
112 |
||
113 |
@Override |
|
114 |
public int payloadProtocolID() { |
|
115 |
return ppid; |
|
116 |
} |
|
117 |
||
118 |
@Override |
|
119 |
public MessageInfo payloadProtocolID(int ppid) { |
|
120 |
this.ppid = ppid; |
|
121 |
return this; |
|
122 |
} |
|
123 |
||
124 |
@Override |
|
125 |
public boolean isComplete() { |
|
126 |
return complete; |
|
127 |
} |
|
128 |
||
129 |
@Override |
|
130 |
public MessageInfo complete(boolean complete) { |
|
131 |
this.complete = complete; |
|
132 |
return this; |
|
133 |
} |
|
134 |
||
135 |
@Override |
|
136 |
public boolean isUnordered() { |
|
137 |
return unordered; |
|
138 |
} |
|
139 |
||
140 |
@Override |
|
141 |
public MessageInfo unordered(boolean unordered) { |
|
142 |
this.unordered = unordered; |
|
143 |
return this; |
|
144 |
} |
|
145 |
||
146 |
@Override |
|
147 |
public long timeToLive() { |
|
148 |
return timeToLive; |
|
149 |
} |
|
150 |
||
151 |
@Override |
|
152 |
public MessageInfo timeToLive(long millis) { |
|
153 |
timeToLive = millis; |
|
154 |
return this; |
|
155 |
} |
|
156 |
||
157 |
@Override |
|
158 |
public String toString() { |
|
159 |
StringBuilder sb = new StringBuilder(super.toString()); |
|
160 |
sb.append( "[Address: ").append(address) |
|
161 |
.append(", Association: ").append(association) |
|
162 |
.append(", Assoc ID: ").append(assocId) |
|
163 |
.append(", Bytes: ").append(bytes) |
|
164 |
.append(", Stream Number: ").append(streamNumber) |
|
165 |
.append(", Complete: ").append(complete) |
|
166 |
.append(", isUnordered: ").append(unordered) |
|
167 |
.append("]"); |
|
168 |
return sb.toString(); |
|
169 |
} |
|
170 |
} |