Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
e46cda93
Commit
e46cda93
authored
Nov 17, 2015
by
daryl herzmann
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #376 from sco0ter/channel
Delete ChannelInputStream.java.
parents
3e86f9fc
ac24f060
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
108 deletions
+0
-108
ChannelInputStream.java
...ava/org/jivesoftware/openfire/net/ChannelInputStream.java
+0
-108
No files found.
src/java/org/jivesoftware/openfire/net/ChannelInputStream.java
deleted
100644 → 0
View file @
3e86f9fc
/**
* $RCSfile$
* $Revision: $
* $Date: $
*
* Copyright (C) 2005-2008 Jive Software. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
jivesoftware
.
openfire
.
net
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.ByteBuffer
;
import
java.nio.channels.ReadableByteChannel
;
/**
* Class that simulate an InputStream given a un-blocking channel.
*
* @author Daniele Piras
*/
class
ChannelInputStream
extends
InputStream
{
ByteBuffer
buf
=
ByteBuffer
.
allocate
(
1024
);
ReadableByteChannel
inputChannel
;
public
ChannelInputStream
(
ReadableByteChannel
ic
)
{
inputChannel
=
ic
;
}
private
void
doRead
()
throws
IOException
{
final
int
cnt
=
inputChannel
.
read
(
buf
);
if
(
cnt
>
0
)
{
buf
.
flip
();
}
else
{
if
(
cnt
==
-
1
)
{
buf
.
flip
();
}
}
}
@Override
public
synchronized
int
read
(
byte
[]
bytes
,
int
off
,
int
len
)
throws
IOException
{
if
(
buf
.
position
()
==
0
)
{
doRead
();
}
else
{
buf
.
flip
();
}
len
=
Math
.
min
(
len
,
buf
.
remaining
());
if
(
len
==
0
)
{
return
-
1
;
}
buf
.
get
(
bytes
,
off
,
len
);
if
(
buf
.
hasRemaining
())
{
// Discard read data and move unread data to the begining of the buffer.
// Leave
// the position at the end of the buffer as a way to indicate that there
// is
// unread data
buf
.
compact
();
}
else
{
buf
.
clear
();
}
return
len
;
}
@Override
public
int
read
()
throws
IOException
{
byte
[]
tmpBuf
=
new
byte
[
1
];
int
byteRead
=
read
(
tmpBuf
,
0
,
1
);
if
(
byteRead
<
1
)
{
return
-
1
;
}
else
{
return
tmpBuf
[
0
];
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment